sanmar_sdk.base

Base classes and field types shared by every model in the SDK.

There are two kinds of model:

  • Model is anything a caller builds and hands to the SDK: a purchase order, a lookup. It is strict — a string is not coerced into a number, a float is not accepted as money — so a mistake fails when the model is built, before anything is sent to SanMar.

  • Record is anything the SDK parses out of a SanMar response or data file. SanMar types almost everything as text, so records coerce leniently, ignore fields they do not model, and treat a missing or blank value as absent.

Attributes

SanMarDate

A date in any of the formats SanMar sends.

OneOrMany

A list that SanMar may send as a single item when there is only one.

Price

A dollar amount, or None where SanMar has none (a blank, NA or NLA).

CommaSeparated

A comma-separated list, split into its parts.

SemicolonSeparated

A semicolon-separated list, split into its parts.

ORDER_TEXT

Marks a string as text that goes into a SanMar order, which takes printable ASCII without commas.

FROZEN

Stores a validated collection as a tuple, so a frozen model's collection cannot change.

Classes

Model

A strict, immutable model that a caller builds.

Record

An immutable model parsed from something SanMar sent.

Module Contents

class sanmar_sdk.base.Model(/, **data: Any)[source]

Bases: pydantic.BaseModel

A strict, immutable model that a caller builds.

model_config[source]

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

class sanmar_sdk.base.Record(/, **data: Any)[source]

Bases: pydantic.BaseModel

An immutable model parsed from something SanMar sent.

model_config[source]

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

sanmar_sdk.base.SanMarDate[source]

A date in any of the formats SanMar sends.

type sanmar_sdk.base.OneOrMany = Annotated[list[T], BeforeValidator(_as_list)][source]

A list that SanMar may send as a single item when there is only one.

sanmar_sdk.base.Price[source]

A dollar amount, or None where SanMar has none (a blank, NA or NLA).

sanmar_sdk.base.CommaSeparated[source]

A comma-separated list, split into its parts.

sanmar_sdk.base.SemicolonSeparated[source]

A semicolon-separated list, split into its parts.

sanmar_sdk.base.ORDER_TEXT[source]

Marks a string as text that goes into a SanMar order, which takes printable ASCII without commas.

It goes after the field’s length limits, so a too-long value is reported in characters:

city: Annotated[str, Field(max_length=28), ORDER_TEXT]
sanmar_sdk.base.FROZEN[source]

Stores a validated collection as a tuple, so a frozen model’s collection cannot change.

Callers may pass any sequence, a list included; without this, a list would be kept as the same mutable list, and emptying it would get past the model’s validation:

lines: Annotated[Sequence[OrderLine], Field(min_length=1), FROZEN]