api.domain.catalog ================== .. py:module:: api.domain.catalog .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: api.domain.catalog.SELLABLE_COMMERCIAL_STATUS api.domain.catalog.DEFAULT_CONDITION api.domain.catalog.DECLASSE_CONDITION api.domain.catalog.EXCLUDED_CONDITIONS Classes ------- .. autoapisummary:: api.domain.catalog.Model api.domain.catalog.Variation api.domain.catalog.Unit api.domain.catalog.ShopifyListing Functions --------- .. autoapisummary:: api.domain.catalog.is_excluded_condition api.domain.catalog.is_positive_price api.domain.catalog.pick_pdf_attachment api.domain.catalog.added_since api.domain.catalog.fetch_models api.domain.catalog.fetch_variations api.domain.catalog.fetch_units api.domain.catalog.fetch_shopify_listings api.domain.catalog.record_url Module Contents --------------- .. py:data:: SELLABLE_COMMERCIAL_STATUS :value: 'A vendre' .. py:data:: DEFAULT_CONDITION :value: 'Très bon' .. py:data:: DECLASSE_CONDITION :value: 'Neuf déclassé' .. py:data:: EXCLUDED_CONDITIONS :value: ['Abimé', 'Très abimé'] .. py:function:: is_excluded_condition(condition: Any) -> bool Whether a unit's "Etat esthétique" keeps it off Shopify. .. py:function:: 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. .. py:function:: 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". .. py:class:: Model .. py:attribute:: record_id :type: str .. py:attribute:: name :type: str .. py:attribute:: shopify_id :type: str | None .. py:attribute:: to_sell_on_shopify :type: bool .. py:attribute:: variation_ids :type: list[str] :value: [] .. py:attribute:: shopify_listing_ids :type: list[str] :value: [] .. py:attribute:: documentation_attachment_id :type: str | None :value: None .. py:class:: Variation .. py:attribute:: record_id :type: str .. py:attribute:: name :type: str .. py:attribute:: model_id :type: str | None .. py:attribute:: to_sell_on_shopify :type: bool .. py:attribute:: variant_values :type: list[str] :value: [] .. py:attribute:: unit_ids :type: list[str] :value: [] .. py:class:: Unit .. py:attribute:: record_id :type: str .. py:attribute:: variation_id :type: str | None .. py:attribute:: commercial_status :type: str | None .. py:attribute:: aesthetic_condition :type: str | None .. py:attribute:: variation_ids :type: list[str] :value: [] .. py:attribute:: sale_price :type: Any :value: None .. py:attribute:: name :type: str | None :value: None .. py:class:: ShopifyListing .. py:attribute:: record_id :type: str .. py:attribute:: model_id :type: str | None .. py:attribute:: shopify_id :type: str | None .. py:attribute:: status :type: str | None .. py:attribute:: name :type: str | None :value: None .. py:function:: 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. .. py:function:: fetch_models() -> list[Model] .. py:function:: fetch_variations() -> list[Variation] .. py:function:: fetch_units() -> list[Unit] .. py:function:: fetch_shopify_listings() -> list[ShopifyListing] .. py:function:: 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.