api.routes.internal.catalog.units ================================= .. py:module:: api.routes.internal.catalog.units .. autoapi-nested-parse:: The Unit of one received item, written as soon as operations finish it: its fields, its reprise, and the operations' photos (``Photos interne``). See the catalog-intake guide in the public documentation site. Attributes ---------- .. autoapisummary:: api.routes.internal.catalog.units.logger api.routes.internal.catalog.units.router api.routes.internal.catalog.units.PHOTO_FILENAME api.routes.internal.catalog.units.PHOTO_TYPES Classes ------- .. autoapisummary:: api.routes.internal.catalog.units.PhotoUpload api.routes.internal.catalog.units.PhotoRemoval api.routes.internal.catalog.units.UnitRestoreRequest Functions --------- .. autoapisummary:: api.routes.internal.catalog.units.sync_unit api.routes.internal.catalog.units.upload_photo api.routes.internal.catalog.units.remove_photos api.routes.internal.catalog.units.remove_unit api.routes.internal.catalog.units.restore_unit Module Contents --------------- .. py:data:: logger .. py:data:: router .. py:data:: PHOTO_FILENAME .. py:data:: PHOTO_TYPES .. py:function:: sync_unit(payload: api.domain.intake.UnitSyncRequest, sync: api.services.catalog_sync.CatalogSync = Depends(get_catalog_sync)) Crée l'unité (avec sa reprise, et le prix de rachat et les photos client de son équipement) ou complète celle qui existe. - 200 ``in_sync`` : écrit ; ``written`` est la nouvelle référence. - 200 ``conflict`` : modifiée dans Airtable depuis le dernier envoi, non écrasée. - 502 : relancer avec le même ``idempotency_key`` (jamais de doublon). .. py:class:: PhotoUpload Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: image_b64 :type: str .. py:attribute:: content_type :type: str :value: 'image/jpeg' .. py:attribute:: filename :type: str .. py:function:: upload_photo(unit_id: str, payload: PhotoUpload, at: api.services.unit_photos.PhotoGateway = Depends(get_attachment_gateway)) Idempotent par nom de fichier (``rw-…``) : renvoie l'attachement déjà présent au lieu d'en ajouter un second. .. py:class:: PhotoRemoval Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: attachment_ids :type: list[str] .. py:function:: remove_photos(unit_id: str, payload: PhotoRemoval, at: api.services.unit_photos.PhotoGateway = Depends(get_attachment_gateway)) Retire seulement ces pièces jointes ; les autres restent. .. py:function:: remove_unit(unit_id: str, sync: api.services.catalog_sync.CatalogSync = Depends(get_catalog_sync)) 409 ``unit_locked`` si l'unité est vendue, réservée, commandée, aux enchères ou liée à une vente / un devis. Déjà supprimée : 200. .. py:class:: UnitRestoreRequest Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: fields :type: dict[str, Any] .. py:function:: restore_unit(unit_id: str, payload: UnitRestoreRequest, sync: api.services.catalog_sync.CatalogSync = Depends(get_catalog_sync)) ``restored: false`` si l'unité n'existe plus.