Advancements
This section describes the API of the advancement resource.
Parameters
id: | integer |
description: | string |
amount: | float |
date: | string |
tags: | array |
payer: | JSON object |
receiver: | JSON object |
responsible_user: | JSON object |
currency: | string based on currencies code |
_links: |
array of object array of links of the advancement |
Example of Advancement
List all advancements
Retrieve all advancements that the authenticated user can view or manage. It will return a JSON
containing the name of the resource
with an array of the objects requested and informations like the total of objects, current page and total pages. The fields of the advancements can be
found in the Advancement section.
Parameters
page: | integer |
per_page: | integer limit to 100 |
Definition
GET https://app.rexpense.com/api/v1/advancements
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
Filtering a list of advancements
You can filter the list of retrieved advancements.
Parameters
All parameters must be nested in the q
parameter.
amount_gteq: | float |
amount_lteq: | float |
receiver_id_eq: | integer |
payer_id_eq: | integer |
created_at_gteq: | string |
created_at_lteq: | string |
updated_at_gteq: | string |
updated_at_lteq: | string |
search_tags: | string |
has_tag: | string Available values: '1', '0', '' |
Definition
GET https://app.rexpense.com/api/v1/advancements
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"amount_gteq":123.63}}'
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"amount_gteq":3000.00, "amount_lteq": 4000.00}}'
Response Example
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"receiver_id_eq": 1}}'
Response Example
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"payer_id_eq": 1}}'
Response Example
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"created_at_gteq": "12-24-2013", "created_at_lteq": "12-25-2013"}}'
Response Example
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"updated_at_gteq": "12-24-2013", "updated_at_lteq": "12-25-2013"}}'
Response Example
Show an advancement
This request shows the advancement complete information.
Parameters
id: | integer required |
Definition
GET https://app.rexpense.com/api/v1/advancements/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/advancements/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
Response Example Failure
HTTP 404 Record Not Found
Create an advancements
This request creates a new advancement.
Important:
- The payer must have a relation with the receiver to create a new advancement.
Parameters
description: | string |
payer: |
payer object attributes required
id: integer
type: string |
receiver: |
receiver object attributes required
id: integer
type: string |
amount: | float required |
tags: | array |
date: | string required iso8601 format |
currency: | string based on currencies code |
Expired organization
If the organization is expired, it will return an 402 error.
Definition
POST https://app.rexpense.com/api/v1/advancements
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/advancements \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"amount": 1000.00, "date": "2013-12-24", "payer": {"id": 1, "type": "Organization"}}'
Response Example Success
HTTP 201 CREATED
Response Example Failure
HTTP 422 Unprocessable Entity
Example Response Failure when organization is expired
HTTP 402 Payment Required
Update an advancement
There are two ways to update an advancement: partially or fully. If you'd like to change just one or
a few attributes, you have to use the HTTP method PATCH
. If you use the HTTP method PUT
, you'll have to
pass all attributes of the advancement. This behaviour is the same for all resources in the Rexpense API.
Parameters
description: | string |
amount: | float required |
date: | string required |
currency: | string |
tags: | array |
payer: |
payer object attributes required
id: integer
type: string |
receiver: |
receiver object attributes required
id: integer
type: string |
Expired organization
If the organization is expired, it will return an 402 error.
Definition
PUT/PATCH https://app.rexpense.com/api/v1/advancements/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/advancements/:id \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"amount": 1200.00, "date": "2014-12-28"}'
Response Example Success
HTTP 200 OK
Response Example Failure
HTTP 422 Unprocessable Entity
Example Response Failure when organization is expired
HTTP 402 Payment Required
Destroy an advancement
To destroy an advancement you have to own the advancement (be the receiver) or be an Organization's Administrator or Manager (have any relation with the payer).
Expired organization
If the organization is expired, it will return an 402 error.
Definition
DELETE https://app.rexpense.com/api/v1/advancements/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/advancements/:id \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 204 NO CONTENT
Example Response Failure when organization is expired
HTTP 402 Payment Required
Advancement's activities
Activities are simple logs from an Advancement's changes or comments activities.
If the activity is an Advancement change, the response will hide the source
element from the response.
If the activity is a Comment and the content
have emojis, they will be rendered as text code by default (for example, :smile:
). However, if you'd like to get the unicode of the emojis instead, you should supply a emoji_in_unicode
boolean param.
Parameter
emoji_in_unicode: | boolean |
Definition
GET https://app.rexpense.com/api/v1/advancements/:advancement_id/activities
Example request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements/1/activities \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK