Models¶
Domain types are organised under :mod:pysainsburys.models, grouped by business
area. Each submodule exposes dataclasses with from_dict / to_dict
helpers for API JSON.
Package layout¶
pysainsburys.models
├── common/ # Shared value types
│ ├── Price
│ └── PageControls
├── product/ # Online catalogue
│ ├── Product, ProductList, ProductReviews
│ └── nutrition # NutritionInfo, parsers
├── basket/ # Basket, BasketItem
├── customer/ # Customer profile
├── order/ # OrderSummary, OrderList, OrderStatus
├── slot/ # DeliverySlot, SlotWeek, SlotReservation
└── store/ # Store, StoreProduct, Product Finder pagination
Importing¶
Prefer the models package for new code:
from pysainsburys.models import Product, Basket, Customer, NutritionInfo
from pysainsburys.models.product import parse_nutrition_from_details_html
from pysainsburys.models.common import Price, PageControls
Top-level names (from pysainsburys import Product) are also re-exported from
the root package for convenience.
Common¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.common.price.Price |
Monetary amount with optional unit of measure |
:class:~pysainsburys.models.common.pagination.PageControls |
Grocery API list pagination metadata |
Product¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.product.product.Product |
Catalogue product; supports basket mutations when bound to a client |
:class:~pysainsburys.models.product.product.ProductList |
Paginated search or favourites results |
:class:~pysainsburys.models.product.product.ProductReviews |
Review count and average rating |
:class:~pysainsburys.models.product.nutrition.NutritionInfo |
Parsed nutrition summary, tables, and footnotes |
:class:~pysainsburys.models.product.details.ProductDetails |
Description, storage, and other product-text sections |
:class:~pysainsburys.models.product.product.Promotion |
Catalogue offer attached to a product |
:class:~pysainsburys.models.product.product.NectarPrice |
Nectar member price for a product |
:class:~pysainsburys.models.product.catalogue.ProductLabel |
Merchandising label such as British or Chilled |
:class:~pysainsburys.models.product.catalogue.ProductCategory |
Catalogue category membership |
:class:~pysainsburys.models.product.catalogue.ProductImage |
Sized product image |
Nutrition, storage, and the other product-text headings are extracted from
the details_html field on product detail responses (base64-encoded HTML
from the website). Search results omit that field, so
:attr:~pysainsburys.models.product.product.Product.details stays empty
until the product is loaded with get_product. When the HTML has no
Description section, description falls back to the JSON description
list. Catalogue offers and the Nectar member price are copied from the
promotions and nectar_price fields on the same product JSON, including
search results. The same payload also supplies brand, labels, categories,
breadcrumbs, images, the pre-offer unit price, health rating, and loose-item
average weight. important_information is the same legal disclaimer on
every product and is not stored. Use
:func:~pysainsburys.models.product.nutrition.parse_nutrition_from_details_html
to parse nutrition from a raw payload directly.
Basket¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.basket.basket.Basket |
Basket totals and line items |
:class:~pysainsburys.models.basket.basket.BasketItem |
Single basket line |
Authenticated fetch/clear operations are provided by
:class:~pysainsburys.basket.BasketAccess on
customer.basket.
Customer¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.customer.customer.Customer |
Signed-in profile with basket, favourites, orders, and slots accessors |
Slot¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.slot.slot.DeliverySlot |
Single delivery or collection time window |
:class:~pysainsburys.models.slot.slot.SlotDay |
Slots grouped for one calendar day |
:class:~pysainsburys.models.slot.slot.SlotWeek |
Week view returned by the slot listing API |
:class:~pysainsburys.models.slot.slot.SlotReservation |
Current reserved slot state |
:class:~pysainsburys.models.slot.slot.LocationContext |
Location context for slot queries |
Listing, reservation, and validation helpers live in
:class:~pysainsburys.slots.Slots on customer.slots.
Note: The slot week list endpoint was mapped from static analysis but not live-captured in Phase 1. Some accounts or environments may block direct API access. The reservation write payload is also inferred and remains experimental until live-captured; see the reverse-engineering docs for limitations.
Order¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.order.order.OrderSummary |
Order in a history list |
:class:~pysainsburys.models.order.order.OrderList |
Paginated order history |
:class:~pysainsburys.models.order.order.OrderStatus |
Live status for the active slot |
Per-order helpers live in :class:~pysainsburys.orders.OrderHandle and
:class:~pysainsburys.orders.Orders.
Store¶
| Type | Purpose |
|---|---|
:class:~pysainsburys.models.store.store.Store |
Physical store; supports in-store search when bound |
:class:~pysainsburys.models.store.store.StoreList |
Paginated store search results |
:class:~pysainsburys.models.store.store.StoreProduct |
In-store product with aisle and stock |
:class:~pysainsburys.models.store.store.StoreProductList |
In-store search results |
:class:~pysainsburys.models.store.store.FinderPage |
Product Finder pagination metadata |
Serialisation¶
All models support to_dict() and many support dict(model) via
__iter__. Round-trip parsing uses from_dict class methods on each type.