Base Models & Mixins

Base Models

class ab.api.models.base.ABConnectBaseModel[source]

Root base class for all ABConnect models.

All fields use snake_case in Python with camelCase aliases for JSON serialization. populate_by_name=True allows construction using either convention.

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod check(data, exclude_unset=True)[source]

Validate data and return a JSON-ready dict (or list of dicts).

Keys are camelCase (by_alias=True) and special types (datetime, UUID, …) are serialized to JSON-compatible formats.

Parameters:
Return type:

Dict[str, Any] | List[Dict[str, Any]]

class ab.api.models.base.RequestModel[source]

Bases: ABConnectBaseModel

Base for outbound request bodies.

extra="forbid" catches typos and invalid fields at construction time.

model_config = {'alias_generator': <function _to_camel>, 'extra': 'forbid', 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.base.ResponseModel(**extra_data)[source]

Bases: ABConnectBaseModel

Base for inbound API response bodies.

extra="allow" keeps deserialization resilient when the API adds new fields. Unknown fields are stored in model_extra and a logger.warning is emitted for each one so drift is immediately visible.

Parameters:

extra_data (Any)

model_config = {'alias_generator': <function _to_camel>, 'extra': 'allow', 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(_ResponseModel__context)[source]

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Parameters:

_ResponseModel__context (Any)

Return type:

None

Design Notes

  • RequestModel uses extra="forbid" — unknown fields cause a validation error

  • ResponseModel uses extra="allow" — unknown fields are stored in model_extra and logged as warnings (drift detection)

  • All models use populate_by_name=True and alias_generator=to_camel for camelCase JSON interop

Mixins

class ab.api.models.mixins.IdentifiedModel(*, id=None)[source]

Mixin for models with an id field.

Parameters:

id (str | int | None)

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.TimestampedModel(*, createdDate=None, modifiedDate=None, createdBy=None, modifiedBy=None)[source]

Mixin for models with created/modified audit timestamps.

Parameters:
model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.ActiveModel(*, isActive=None)[source]

Mixin for models with an is_active flag.

Parameters:

isActive (bool | None)

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.CompanyRelatedModel(*, companyId=None, companyName=None)[source]

Mixin for models associated with a company.

Parameters:
  • companyId (str | None)

  • companyName (str | None)

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.JobRelatedModel(*, jobId=None)[source]

Mixin for models associated with a job.

Parameters:

jobId (str | None)

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.FullAuditModel(*, isActive=None, createdDate=None, modifiedDate=None, createdBy=None, modifiedBy=None, id=None)[source]

Bases: IdentifiedModel, TimestampedModel, ActiveModel

ID + timestamps + active status.

Parameters:
model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.CompanyAuditModel(*, companyId=None, companyName=None, isActive=None, createdDate=None, modifiedDate=None, createdBy=None, modifiedBy=None, id=None)[source]

Bases: FullAuditModel, CompanyRelatedModel

Full audit trail + company association.

Parameters:
  • companyId (str | None)

  • companyName (str | None)

  • isActive (bool | None)

  • createdDate (datetime | None)

  • modifiedDate (datetime | None)

  • createdBy (str | None)

  • modifiedBy (str | None)

  • id (str | int | None)

model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.mixins.JobAuditModel(*, jobId=None, isActive=None, createdDate=None, modifiedDate=None, createdBy=None, modifiedBy=None, id=None)[source]

Bases: FullAuditModel, JobRelatedModel

Full audit trail + job association.

Parameters:
model_config = {'alias_generator': <function _to_camel>, 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Shared Models

class ab.api.models.shared.ServiceBaseResponse(*, success=None, errorMessage=None, jobSubManagementStatus=None, documents=None, errors=None, confirmRequired=None, notifications=None, shipmentId=None, shipmentAcceptIdentifier=None, weight=None, totalNetChargeAmount=None, currencyCode=None, internationalInfoRequired=None, shipOutDateRequired=None, fedExExpressFreightDetailRequired=None, carrierAPI=None, **extra_data)[source]

Standard success/error wrapper returned by many ABConnect endpoints.

Supports boolean evaluation:

resp = api.some_endpoint(...)
if resp:
    print("Success")
else:
    resp.raise_for_error()
Parameters:
  • success (bool | None)

  • errorMessage (str | None)

  • jobSubManagementStatus (dict | None)

  • documents (List[str] | None)

  • errors (dict | None)

  • confirmRequired (bool | None)

  • notifications (List[str] | None)

  • shipmentId (str | None)

  • shipmentAcceptIdentifier (str | None)

  • weight (ShipmentWeight | None)

  • totalNetChargeAmount (float | None)

  • currencyCode (str | None)

  • internationalInfoRequired (bool | None)

  • shipOutDateRequired (bool | None)

  • fedExExpressFreightDetailRequired (bool | None)

  • carrierAPI (int | None)

  • extra_data (Any)

raise_for_error()[source]

Raise ValueError when success is False.

Return type:

None

model_config = {'alias_generator': <function _to_camel>, 'extra': 'allow', 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.shared.PaginatedList(*, items=<factory>, pageNumber=0, totalPages=0, totalItems=0, hasPreviousPage=False, hasNextPage=False, **extra_data)[source]

Generic pagination wrapper used by the Catalog API.

Example:

result: PaginatedList[CatalogExpandedDto] = api.catalog.list(page_number=1)
for item in result.items:
    print(item.title)
Parameters:
  • items (List[T])

  • pageNumber (int)

  • totalPages (int)

  • totalItems (int)

  • hasPreviousPage (bool)

  • hasNextPage (bool)

  • extra_data (Any)

model_config = {'alias_generator': <function _to_camel>, 'extra': 'allow', 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ab.api.models.shared.ListRequest(*, sortBy=None, sortDir=None, page=None, pageSize=None, filters=None)[source]

Shared request body for paginated list endpoints (Companies, Users).

Parameters:
  • sortBy (str | None)

  • sortDir (bool | None)

  • page (int | None)

  • pageSize (int | None)

  • filters (dict | None)

model_config = {'alias_generator': <function _to_camel>, 'extra': 'forbid', 'populate_by_name': True, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].