Organization distance rules
This section describes the API of the organization distance rule resource.
Parameters
id: | integer |
organization_id: | integer |
amount: | float |
distance_kind: |
string options: km or mi
|
currency: | string based on currencies code |
Example of Distance Rule
[
{
"id": 1,
"amount": 12.0,
"organization_id": 1,
"distance_kind": "km",
"currency": "BRL"
}
]
List distance rules
Retrieve organization distance rules list. When the administrator of the organization did not set the distance rule, a default distance rule with id: null
is returned.
Parameters
organization_id: | integer |
Definition
GET https://app.rexpense.com/api/v1/organizations/:organization_id/distances_rules
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/organizations/:organization_id/distances_rules \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
[
{
"id": 1,
...
}
]
Response Example when organization does not have a distance rule (return default values)
[
{
"id": null,
"amount": 4.68,
"organization_id": 1,
"currency": "BRL",
"distance_kind": "km"
}
]
Update a distance rule
Parameters
organization_id: | integer |
amount: | float |
currency: | integer |
distance_kind: | string options: km , mi |
Definition
POST https://app.rexpense.com/api/v1/organizations/:organization_id/distances_rules
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/organizations/:organization_id/distances_rules \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"amount": 10.00, "currency": "BRL", "distance_kind": "mi"}'
Response Example Success
HTTP 200 OK
[
{
"id": 1,
"amount": 10.0,
...
}
]
HTTP 422 Unprocessable Entity
{
"errors": {
"currency": [
"não está incluído na lista"
],
"amount": [
"não pode ficar em branco"
]
}
}
HTTP 403 Forbidden
{
"errors": {
"message": "Você não tem permissão para realizar esta ação."
}
}