sanmar_sdk

A typed Python SDK for SanMar’s web services and SFTP data files.

Submodules

Attributes

WarehouseNumber

A warehouse number as SanMar reports it.

Exceptions

AuthenticationError

SanMar rejected the credentials.

AuthorizationError

The account is not authorized to use this service (PromoStandards code 104).

FileFormatError

A SanMar data file did not have the layout the SDK expects.

NotFoundError

SanMar has no record matching the request.

RequestError

SanMar rejected the request as malformed or out of range.

ResponseError

SanMar's response could not be parsed, or did not match its own WSDL.

SanMarConnectionError

SanMar could not be reached, or answered with an HTTP error status.

SanMarError

Base class for every error the SDK raises.

ServiceError

SanMar reported an error for the request.

SoapFaultError

SanMar answered with a SOAP fault.

Classes

SanMar

A client for SanMar's web services, both SanMar's own and PromoStandards.

Environment

Which of SanMar's two web service environments to call.

ShipMethod

How SanMar ships an order.

ShipTo

Where an order ships.

SkuKey

SanMar's own key for one style, color and size.

StyleColorSize

One style, color and size, named the way SanMar's order services expect.

StyleQuery

A style to look up, optionally narrowed to one catalog color, one size, or both.

Warehouse

A SanMar warehouse, numbered as SanMar numbers them.

WillCall

Pick an order up from a warehouse instead of having it shipped.

Package Contents

class sanmar_sdk.SanMar(customer_number: int, username: str, password: str, *, environment: sanmar_sdk.common.Environment = Environment.PRODUCTION, timeout: float = 30.0, transport: zeep.Transport | None = None)[source]

A client for SanMar’s web services, both SanMar’s own and PromoStandards.

Parameters:
  • customer_number – The SanMar customer number. SanMar’s own services require it; PromoStandards services do not use it.

  • username – A SanMar.com login. Create one at https://www.sanmar.com/signup/webuser, then ask sanmarintegrations@sanmar.com to enable web service access. EDEV logins are separate from production ones, and neither works on SanMar’s SFTP server.

  • password – A SanMar.com login. Create one at https://www.sanmar.com/signup/webuser, then ask sanmarintegrations@sanmar.com to enable web service access. EDEV logins are separate from production ones, and neither works on SanMar’s SFTP server.

  • environment – Production, or SanMar’s EDEV test environment.

  • timeout – Seconds to wait for a WSDL to load or a call to finish.

  • transport – A zeep Transport to use instead of the default one, for example to cache WSDLs or go through a proxy. It is used as-is, so timeout does not apply.

products[source]

SanMar’s own product information service.

inventory[source]

SanMar’s own inventory service.

pricing[source]

SanMar’s own pricing service, including this account’s prices.

invoices[source]

SanMar’s own invoicing service.

purchase_orders[source]

SanMar’s own purchase order service.

packing_slips[source]

The packing slip service, which looks boxes up by license plate number.

promostandards[source]

SanMar’s PromoStandards services.

property environment: sanmar_sdk.common.Environment[source]

The environment this client calls.

class sanmar_sdk.Environment[source]

Bases: enum.StrEnum

Which of SanMar’s two web service environments to call.

PRODUCTION = 'https://ws.sanmar.com:8080'[source]
EDEV = 'https://edev-ws.sanmar.com:8080'[source]

SanMar’s test environment. It needs its own credentials, requested from sanmarintegrations@sanmar.com, and its products, prices and inventory may not match production.

class sanmar_sdk.ShipMethod[source]

Bases: enum.StrEnum

How SanMar ships an order.

The value is the ship method as SanMar’s own order services and order files spell it. PromoStandards orders split it into a carrier and a service; see promostandards_freight().

UPS_GROUND = 'UPS'[source]
UPS_2ND_DAY = 'UPS 2ND DAY'[source]
UPS_2ND_DAY_AM = 'UPS 2ND DAY AM'[source]
UPS_3RD_DAY = 'UPS 3RD DAY'[source]
UPS_NEXT_DAY = 'UPS NEXT DAY'[source]
UPS_NEXT_DAY_EARLY_AM = 'UPS NEXT DAY EA'[source]
UPS_NEXT_DAY_SAVER = 'UPS NEXT DAY SV'[source]
UPS_SATURDAY = 'UPS SATURDAY'[source]
USPS_GROUND_ADVANTAGE = 'USPS PP'[source]
USPS_PRIORITY_MAIL = 'USPS APP'[source]
PSST = 'PSST'[source]

SanMar’s Pack Separately, Ship Together program. The ship-to must exactly match the address SanMar has on file.

TRUCK = 'TRUCK'[source]

Truck freight, for orders over 500 pounds. Not available through PromoStandards.

promostandards_freight() → tuple[str, str][source]

Return the PromoStandards (carrier, service) pair for this ship method.

Raises:

ValueError – If SanMar does not offer the ship method through PromoStandards.

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

Bases: sanmar_sdk.base.Model

Where an order ships.

Field lengths are the tightest limits across SanMar’s order services and order files.

address1: Annotated[str, Field(min_length=1, max_length=35), sanmar_sdk.base.ORDER_TEXT][source]

The street address. SanMar asks for the abbreviations ST, AVE, RD, DR and BLVD.

city: Annotated[str, Field(min_length=1, max_length=28), sanmar_sdk.base.ORDER_TEXT][source]
state: str = None[source]

The two-letter state abbreviation.

zip_code: str = None[source]

A five-digit ZIP code, or ZIP+4 with or without the dash.

company: Annotated[str, Field(min_length=1, max_length=28), sanmar_sdk.base.ORDER_TEXT] | None = None[source]
attention: Annotated[str, Field(min_length=1, max_length=35), sanmar_sdk.base.ORDER_TEXT] | None = None[source]

The receiver’s name, or the PO number.

address2: Annotated[str, Field(min_length=1, max_length=35), sanmar_sdk.base.ORDER_TEXT] | None = None[source]

The suite or apartment number.

email: Annotated[str, Field(min_length=3, max_length=105), sanmar_sdk.base.ORDER_TEXT] | None = None[source]

Where SanMar sends the order confirmation and shipping notification.

When omitted, SanMar uses the default email on the account.

phone: Annotated[str, Field(min_length=1, max_length=32), sanmar_sdk.base.ORDER_TEXT] | None = None[source]

The receiver’s phone number. Only PromoStandards orders carry it.

residential: bool = False[source]
country: str = None[source]
class sanmar_sdk.SkuKey(/, **data: Any)[source]

Bases: sanmar_sdk.base.Model

SanMar’s own key for one style, color and size.

INVENTORY_KEY and SIZE_INDEX are in every SanMar product file. The inventory key is not the style number. SanMar recommends ordering by key rather than by style, color and size, because it cannot be misspelled.

inventory_key: int = None[source]
size_index: int = None[source]
class sanmar_sdk.StyleColorSize(/, **data: Any)[source]

Bases: sanmar_sdk.base.Model

One style, color and size, named the way SanMar’s order services expect.

style: str = None[source]

The style number, as printed in SanMar’s catalog (K500).

catalog_color: str = None[source]

The catalog (mainframe) color, not the display color name.

size: str = None[source]
class sanmar_sdk.StyleQuery(/, **data: Any)[source]

Bases: sanmar_sdk.base.Model

A style to look up, optionally narrowed to one catalog color, one size, or both.

style: str = None[source]

The style number, as printed in SanMar’s catalog (K500).

catalog_color: Annotated[str, Field(min_length=1, max_length=50)] | None = None[source]

The catalog (mainframe) color, not the display color name.

size: Annotated[str, Field(min_length=1, max_length=50)] | None = None[source]
class sanmar_sdk.Warehouse[source]

Bases: enum.IntEnum

A SanMar warehouse, numbered as SanMar numbers them.

The number is also the warehouse’s PromoStandards FOB id.

SEATTLE = 1[source]
CINCINNATI = 2[source]
DALLAS = 3[source]
RENO = 4[source]
ROBBINSVILLE = 5[source]
JACKSONVILLE = 6[source]
MINNEAPOLIS = 7[source]
PHOENIX = 12[source]
RICHMOND = 31[source]
property code: str[source]

The warehouse’s will-call code, which goes in the ship method field.

property city: str[source]

The city the warehouse is in.

property state: str[source]

The two-letter state the warehouse is in.

sanmar_sdk.WarehouseNumber[source]

A warehouse number as SanMar reports it.

A known warehouse parses to Warehouse. A number SanMar has added since this SDK was released stays a plain int rather than failing the whole response.

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

Bases: sanmar_sdk.base.Model

Pick an order up from a warehouse instead of having it shipped.

Only SanMar’s own order services and order files support will call, and only for accounts SanMar has set up for warehouse selection.

warehouse: Warehouse[source]
property ship_method: str[source]

The value SanMar expects in the ship method field.

exception sanmar_sdk.AuthenticationError(message: str, code: int | None = None)[source]

Bases: ServiceError

SanMar rejected the credentials.

Web services use a SanMar.com username and password (plus the customer number for SanMar’s own services). EDEV has separate credentials from production, and the SFTP server has its own password.

exception sanmar_sdk.AuthorizationError(message: str, code: int | None = None)[source]

Bases: ServiceError

The account is not authorized to use this service (PromoStandards code 104).

exception sanmar_sdk.FileFormatError(message: str, line_number: int | None = None)[source]

Bases: SanMarError

A SanMar data file did not have the layout the SDK expects.

message[source]
line_number = None[source]
exception sanmar_sdk.NotFoundError(message: str, code: int | None = None)[source]

Bases: ServiceError

SanMar has no record matching the request.

exception sanmar_sdk.RequestError(message: str, code: int | None = None)[source]

Bases: ServiceError

SanMar rejected the request as malformed or out of range.

exception sanmar_sdk.ResponseError[source]

Bases: SanMarError

SanMar’s response could not be parsed, or did not match its own WSDL.

exception sanmar_sdk.SanMarConnectionError[source]

Bases: SanMarError

SanMar could not be reached, or answered with an HTTP error status.

SanMar’s web services listen on port 8080, which some networks block outright.

exception sanmar_sdk.SanMarError[source]

Bases: Exception

Base class for every error the SDK raises.

exception sanmar_sdk.ServiceError(message: str, code: int | None = None)[source]

Bases: SanMarError

SanMar reported an error for the request.

code is the PromoStandards error code. SanMar’s own services report a message without a code, so it is None for them.

message[source]
code = None[source]
exception sanmar_sdk.SoapFaultError(message: str, code: str | None = None)[source]

Bases: SanMarError

SanMar answered with a SOAP fault.

message[source]
code = None[source]