taler-docs

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

post-private-units.rst (1320B)


      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:`409 Conflict`:
     16     A built-in unit with the same short name already exists.
     17 
     18   .. ts:def:: UnitAddRequest
     19 
     20     interface UnitAddRequest {
     21       // Short identifier to reference the unit from products and orders.
     22       unit: string;
     23 
     24       // Human-readable long label (e.g. "kilogram").
     25       unit_name_long: string;
     26 
     27       // Human-readable short label (e.g. "kg").
     28       unit_name_short: string;
     29 
     30       // Optional translations for the long label keyed by BCP 47 language tags.
     31       unit_name_long_i18n?: { [lang_tag: string]: string };
     32 
     33       // Optional translations for the short label keyed by BCP 47 language tags.
     34       unit_name_short_i18n?: { [lang_tag: string]: string };
     35 
     36       // Defaults to false; set to true to enable fractional quantities.
     37       unit_allow_fraction?: boolean;
     38 
     39       // Fractional precision (0-6). Ignored when ``unit_allow_fraction`` is false.
     40       unit_precision_level?: Integer;
     41 
     42       // Defaults to true.
     43       unit_active?: boolean;
     44     }