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