sanmar_sdk.base¶
Base classes and field types shared by every model in the SDK.
There are two kinds of model:
Modelis 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.Recordis 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¶
A date in any of the formats SanMar sends. |
|
A list that SanMar may send as a single item when there is only one. |
|
A dollar amount, or |
|
A comma-separated list, split into its parts. |
|
A semicolon-separated list, split into its parts. |
|
Marks a string as text that goes into a SanMar order, which takes printable ASCII without commas. |
|
Stores a validated collection as a tuple, so a frozen model's collection cannot change. |
Classes¶
Module Contents¶
- class sanmar_sdk.base.Model(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelA strict, immutable model that a caller builds.
- class sanmar_sdk.base.Record(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelAn immutable model parsed from something SanMar sent.
- 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.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]