Update a Carpool Booking Rule
PATCH/carpool/rules/:booking_rule_id
Changes one booking rule of the account, the same setting the Carpool settings screen changes. The account's own setting is created when it does not exist yet, and the answer is the rule as it is now.
Which rules. Only the rules returned by GET /carpool/rules can be
changed. Any other booking_rule_id answers 404, exactly like an id that
does not exist.
Two kinds of rule. The value_type of the rule in GET /carpool/rules
tells which request body applies. The body is one of two shapes, never a
mix of them.
value_type | Rules | Send | In the answer |
|---|---|---|---|
BOOL | The switches: booking permissions, vehicle management, start and stop methods, active booking extension and the notifications | is_enabled only | value is null |
| A duration unit | 101 advance booking and 102 maximum duration | value, unit or both | is_enabled is true while value is at least 1 |
Switch a rule. Send {"is_enabled": true} or {"is_enabled": false}.
Sending value or unit for a switch answers 422.
Set a duration rule. Send value, unit or both. Booking checks read
only the value and the unit of these rules, so there is nothing to switch.
The limit is on while the value is at least 1, and sending is_enabled
answers 422. As on the Carpool settings screen, these limits cannot be
switched off, so a value of 0 answers 422.
| Unit | Largest value |
|---|---|
MINUTES | 50000 |
HOURS | 2000 |
DAYS | 365 |
WEEKS | 52 |
MONTHS | 60 |
The value that results from the request, the one sent or else the stored
one, must be at least 1 and at most the largest value of the resulting unit.
Changing only unit therefore checks the stored value against the new unit,
so send value together with unit when moving to a smaller unit. Sending
unit for any rule other than 101 and 102 answers 422.
Errors.
| Status | When |
|---|---|
401 | The credentials are missing or invalid |
403 | The credentials belong to a subuser |
404 | The booking_rule_id is not one of the rules GET /carpool/rules returns |
422 | Field validation: the body is empty, carries an unknown field, a null or a blank text, is_enabled is not the JSON true or false, value is not a JSON whole number of at least 1 with at most nine digits, or unit is not one of the five units above in upper case |
422 with reason code CARPOOL_RULE_VALUE_NOT_ALLOWED | The body mixes the two shapes (is_enabled for a duration rule, or value for a switch), unit is sent for a rule other than 101 and 102, the value is outside the range of its unit, or the stored value does not fit the new unit |
Existing bookings are not re-validated. Relaxing a rule does not approve anything that was refused, and tightening one does not invalidate a booking that was already accepted. A change applies to bookings made after it.
This operation is available to the main account only.
Request
Responses
- 200
- 401
- 403
- 404
- 422
- 500
The rule as it is now.
Unauthorized access. Authentication is required.
The operation requires main account credentials. Valid subusers receive this response.
The requested resource was not found.
Request field validation or Carpool business validation failed.
Internal server error.