taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

patch-private-products-PRODUCT_ID.rst (5402B)


      1 .. http:patch:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID
      2 
      3   This is used to update product details in the inventory. Note that the
      4   ``total_stock`` and ``total_lost`` numbers MUST be greater or equal than
      5   previous values (this design ensures idempotency).  In case stocks were lost
      6   but not sold, increment the ``total_lost`` number.  All fields in the
      7   request are optional, those that are not given are simply preserved (not
      8   modified).  Note that the ``description_i18n`` and ``taxes`` can only be
      9   modified in bulk: if it is given, all translations must be provided, not
     10   only those that changed.  ``never`` should be used for the ``next_restock``
     11   timestamp to indicate no intention/possibility of restocking, while a time
     12   of zero is used to indicate "unknown".
     13 
     14   **Required permission:** ``products-write``
     15 
     16   **Request:**
     17 
     18   The request must be a `ProductPatchDetailRequest`.
     19 
     20   **Response:**
     21 
     22   :http:statuscode:`204 No content`:
     23     The backend has successfully expanded the inventory.
     24   :http:statuscode:`400 Bad Request`:
     25     The request body is malformed or a validation check failed.
     26   :http:statuscode:`404 Not found`:
     27     The instance, product, category, product group or money pot specified are
     28     unknown. Possible error ``code`` values are thus:
     29     ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` (instance unknown),
     30     ``TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN`` (product unknown),
     31     ``TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN`` (product group unknown)
     32     ``TALER_EC_MERCHANT_GENERIC_MONEY_POT_UNKNOWN`` (money pot unknown),
     33     ``TALER_EC_MERCHANT_GENERIC_CATEGORY_UNKNOWN``
     34     (category unknown, specific category is given in the details).
     35   :http:statuscode:`409 Conflict`:
     36     The provided information is inconsistent with the current state of
     37     the inventory.
     38     Returned with ``TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_REDUCED``,
     39     ``TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_SOLD_REDUCED``, or
     40     ``TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_STOCKED_REDUCED``.
     41   :http:statuscode:`500 Internal Server Error`:
     42     The server experienced an internal failure.
     43     Returned with ``TALER_EC_GENERIC_DB_STORE_FAILED``.
     44 
     45   .. ts:def:: ProductPatchDetailRequest
     46 
     47     interface ProductPatchDetailRequest {
     48 
     49       // Human-readable product name.
     50       // Since API version **v20**.  Optional only for
     51       // backwards-compatibility, should be considered mandatory
     52       // moving forward!
     53       product_name?: string;
     54 
     55       // Human-readable product description.
     56       description: string;
     57 
     58       // Map from IETF BCP 47 language tags to localized descriptions.
     59       description_i18n?: { [lang_tag: string]: string };
     60 
     61       // Unit in which the product is measured (liters, kilograms, packages, etc.).
     62       unit: string;
     63 
     64       // Optional override to control whether fractional quantities are permitted.
     65       unit_allow_fraction?: boolean;
     66 
     67       // Override for the fractional precision level (0-6). Only relevant if
     68       // ``unit_allow_fraction`` is true.
     69       unit_precision_level?: Integer;
     70 
     71       // Categories into which the product belongs.
     72       // Used in the POS-endpoint.
     73       // Since API version **v16**.
     74       categories?: Integer[];
     75 
     76       // Preferred way to express the per-unit price. Supply at least one entry;
     77       // the first entry represents the base price and MUST include applicable taxes.
     78       // Zero implies that the product is not sold separately or that the price must be supplied
     79       // by the frontend.
     80       // Each entry must use a distinct currency.
     81       // Since API version **v25**.
     82       // Currency uniqueness enforced since protocol **v25**.
     83       unit_price?: Amount[];
     84 
     85       // Legacy price field.
     86       // Deprecated since **v25**;
     87       // when present it must match the first element of ``unit_price``.
     88       price?: Amount;
     89 
     90       // True if the price(s) given are a net prices, false if they are
     91       // gross prices.
     92       // Since protocol **vTAXES**.
     93       price_is_net?: boolean;
     94 
     95       // An optional base64-encoded product image.
     96       image?: ImageDataUrl;
     97 
     98       // A list of taxes paid by the merchant for one unit of this product.
     99       taxes?: Tax[];
    100 
    101       // Preferred way to express inventory counts using "<integer>[.<fraction>]" syntax.
    102       // Use "-1" for unlimited stock.
    103       unit_total_stock?: DecimalQuantity;
    104 
    105       // Legacy stock counter. Deprecated, use ``unit_total_stock`` instead.
    106       total_stock?: Integer;
    107 
    108       // Number of units of the product that were lost (spoiled, stolen, etc.).
    109       total_lost?: Integer;
    110 
    111       // Identifies where the product is in stock.
    112       address?: Location;
    113 
    114       // Identifies when we expect the next restocking to happen.
    115       next_restock?: Timestamp;
    116 
    117       // Minimum age buyer must have (in years). Default is 0.
    118       minimum_age?: Integer;
    119 
    120       // Product group the product belongs to. 0 and missing both
    121       // means default.
    122       // Since **v25**.
    123       product_group_id?: Integer;
    124 
    125       // Money pot revenue on the product should be accounted in.
    126       // 0 and missing both mean no money pot (revenue accounted
    127       // in money pot of the overall order or not at all).
    128       // Since **v25**.
    129       money_pot_id?: Integer;
    130 
    131     }
    132 
    133   The same compatibility rules for the ``unit_*`` fields and their deprecated counterparts apply
    134   when patching an existing product.