patch-private-units-UNIT.rst (2074B)
1 .. http:patch:: [/instances/$INSTANCE]/private/units/$UNIT 2 3 Update attributes of a measurement unit. 4 5 **Required permission:** ``units-write`` 6 7 **Request:** 8 9 The request must be a `UnitPatchRequest`. 10 11 **Response:** 12 13 :http:statuscode:`204 No content`: 14 The backend updated 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 unit or instance is unknown to the backend. 20 Returned with ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` or 21 ``TALER_EC_MERCHANT_GENERIC_UNIT_UNKNOWN``. 22 :http:statuscode:`409 Conflict`: 23 The unit is a builtin unit and cannot be modified. 24 Returned with ``TALER_EC_MERCHANT_GENERIC_UNIT_BUILTIN``. 25 :http:statuscode:`500 Internal Server Error`: 26 The server experienced an internal failure. 27 Returned with ``TALER_EC_GENERIC_DB_STORE_FAILED`` or 28 ``TALER_EC_GENERIC_DB_SOFT_FAILURE``. 29 30 Built-in units allow changing ``unit_allow_fraction``, ``unit_precision_level``, and 31 ``unit_active``; other fields are immutable for built-ins. 32 33 .. ts:def:: UnitPatchRequest 34 35 interface UnitPatchRequest { 36 // Updated human-readable long label. 37 unit_name_long?: string; 38 39 // Updated human-readable short label. 40 unit_name_short?: string; 41 42 // Updated translations for the long label keyed by BCP 47 language tags. 43 unit_name_long_i18n?: { [lang_tag: string]: string }; 44 45 // Updated translations for the short label keyed by BCP 47 language tags. 46 unit_name_short_i18n?: { [lang_tag: string]: string }; 47 48 // Override to allow or forbid fractional quantities. 49 unit_allow_fraction?: boolean; 50 51 // Override for the fractional precision (0-6). Ignored if fractions are disabled. 52 unit_precision_level?: Integer; 53 54 // Toggle whether the unit is active. 55 unit_active?: boolean; 56 } 57 58 Fractional precision is capped at six decimal places. Disabling 59 ``unit_allow_fraction`` forces ``unit_precision_level`` to zero.