api.domain.catalog

Airtable catalog domain model.

Maps the real Airtable base rather than a flat product list: Model -> Variation -> Toutes les unités (physical units), with Annonces Shopify holding the Shopify listing tied to a Model. Field names below are the literal Airtable field names confirmed against that base’s schema.

Attributes

Classes

Functions

is_excluded_condition(condition) → bool

Whether a unit's "Etat esthétique" keeps it off Shopify.

is_positive_price(value) → bool

Whether a "Prix de vente HT" (Airtable) or a variant price (Shopify,

pick_pdf_attachment(value) → dict[str, Any] | None

The first PDF in an Airtable attachment field's value, or None.

added_since(current_ids, previous_ids) → int

How many of current_ids are new compared to a prior run's snapshot.

fetch_models() → list[Model]

fetch_variations() → list[Variation]

fetch_units() → list[Unit]

fetch_shopify_listings() → list[ShopifyListing]

record_url(table, record_id) → str | None

A link that opens record_id in Airtable's web UI, or None.

Module Contents

api.domain.catalog.SELLABLE_COMMERCIAL_STATUS = 'A vendre'
api.domain.catalog.DEFAULT_CONDITION = 'Très bon'
api.domain.catalog.DECLASSE_CONDITION = 'Neuf déclassé'
api.domain.catalog.EXCLUDED_CONDITIONS = ['Abimé', 'Très abimé']
api.domain.catalog.is_excluded_condition(condition: Any) → bool

Whether a unit’s “Etat esthétique” keeps it off Shopify.

api.domain.catalog.is_positive_price(value: Any) → bool

Whether a “Prix de vente HT” (Airtable) or a variant price (Shopify, a decimal string) is a real price – False for 0, negative, empty or non-numeric values.

api.domain.catalog.pick_pdf_attachment(value: Any) → dict[str, Any] | None

The first PDF in an Airtable attachment field’s value, or None.

Recognized by MIME type, or by a .pdf filename when Airtable didn’t record one. Non-PDF attachments (a photo dropped into the field by mistake) are ignored rather than uploaded as “the PDF”.

class api.domain.catalog.Model
record_id: str
name: str
shopify_id: str | None
to_sell_on_shopify: bool
variation_ids: list[str] = []
shopify_listing_ids: list[str] = []
documentation_attachment_id: str | None = None
class api.domain.catalog.Variation
record_id: str
name: str
model_id: str | None
to_sell_on_shopify: bool
variant_values: list[str] = []
unit_ids: list[str] = []
class api.domain.catalog.Unit
record_id: str
variation_id: str | None
commercial_status: str | None
aesthetic_condition: str | None
variation_ids: list[str] = []
sale_price: Any = None
name: str | None = None
class api.domain.catalog.ShopifyListing
record_id: str
model_id: str | None
shopify_id: str | None
status: str | None
name: str | None = None
api.domain.catalog.added_since(current_ids: set[str], previous_ids: list[str] | None) → int

How many of current_ids are new compared to a prior run’s snapshot.

previous_ids being None means “no prior run” (first run ever), reported as zero additions rather than the size of the whole catalog.

api.domain.catalog.fetch_models() → list[Model]
api.domain.catalog.fetch_variations() → list[Variation]
api.domain.catalog.fetch_units() → list[Unit]
api.domain.catalog.fetch_shopify_listings() → list[ShopifyListing]
api.domain.catalog.record_url(table: str, record_id: str) → str | None

A link that opens record_id in Airtable’s web UI, or None.

Returns None rather than raising when the table’s real id/view can’t be resolved (e.g. a token that loses schema-read access later) – this is a display nicety, never allowed to break a run.