taler-docs

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

post-private-units.rst (2083B)


      1 .. http:post:: [/instances/$INSTANCE]/private/units
      2 
      3   Create a custom measurement unit or reactivate a previously disabled one.
      4 
      5   **Required permission:** ``units-write``
      6 
      7   **Request:**
      8 
      9   The request must be a `UnitAddRequest`.
     10 
     11   **Response:**
     12 
     13   :http:statuscode:`204 No content`:
     14     The backend added the unit.
     15   :http:statuscode:`400 Bad Request`:
     16     The request body is malformed.
     17     Returned with ``TALER_EC_GENERIC_PARAMETER_MALFORMED``.
     18   :http:statuscode:`404 Not found`:
     19     The instance is unknown.
     20     Returned with ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN``.
     21   :http:statuscode:`409 Conflict`:
     22     A built-in unit with the same short name already exists.
     23     Returned with ``TALER_EC_MERCHANT_GENERIC_UNIT_BUILTIN``.
     24   :http:statuscode:`413 Request entity too large`:
     25     The uploaded body is to long, it exceeds the size limit.
     26     Returned with an error code of
     27     ``TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT``.
     28   :http:statuscode:`500 Internal Server Error`:
     29     The server experienced an internal failure.
     30     Returned with ``TALER_EC_GENERIC_DB_STORE_FAILED``,
     31     ``TALER_EC_GENERIC_DB_SOFT_FAILURE`` or
     32     ``TALER_EC_GENERIC_DB_INVARIANT_FAILURE``.
     33 
     34   .. ts:def:: UnitAddRequest
     35 
     36     interface UnitAddRequest {
     37       // Short identifier to reference the unit from products and orders.
     38       unit: string;
     39 
     40       // Human-readable long label (e.g. "kilogram").
     41       unit_name_long: string;
     42 
     43       // Human-readable short label (e.g. "kg").
     44       unit_name_short: string;
     45 
     46       // Optional translations for the long label keyed by BCP 47 language tags.
     47       unit_name_long_i18n?: { [lang_tag: string]: string };
     48 
     49       // Optional translations for the short label keyed by BCP 47 language tags.
     50       unit_name_short_i18n?: { [lang_tag: string]: string };
     51 
     52       // Defaults to false; set to true to enable fractional quantities.
     53       unit_allow_fraction?: boolean;
     54 
     55       // Fractional precision (0-6). Ignored when ``unit_allow_fraction`` is false.
     56       unit_precision_level?: Integer;
     57 
     58       // Defaults to true.
     59       unit_active?: boolean;
     60     }