Pre-Expenses
This section describes the API of the Pre-Expense object. A Pre-Expense is an object that demands some intervention (approval or not) of the user to be converted into an Expense object. Usually, a Pre-Expense is a result of an integration (i.e. integration with Uber)
Parameters
id: | integer |
description: | string |
amount: | float |
* status: | string |
occurred_at: | string |
receiver: | JSON object |
tags: | array |
currency: | string based on currencies code |
extra_information: | JSON object |
_links: |
array of object array of links of the pre-expense |
* Pre-expense status is not equivalent to Expense status. It only tells if the Pre-Expense is completed to be converted to an Expense (current available Pre-Expense statuses: completed
, in_progress
)
Example Pre-Expense
List all Pre-Expenses
Retrieve all pre-expenses that the authenticated user has. 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.
Parameters
page: | integer |
per_page: | integer limit to 100 |
status: | string ignored or waiting_approval |
When requesting without specifying which is the status, the default is waiting approval
Definition
GET https://app.rexpense.com/api/v1/pre_expenses
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/pre_expenses \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
Show pre-expense
Returns the detailed information of a pre-expense.
Definition
GET https://app.rexpense.com/api/v1/pre_expenses/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/pre_expenses/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 200 OK
Ignore a Pre-Expense
When ignoring a Pre-Expense, it won't appear in the default list of Pre-Expenses (Pre-Expenses waiting approval of the user).
Definition
PUT https://app.rexpense.com/api/v1/pre_expenses/:id/ignore
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PUT https://app.rexpense.com/api/v1/pre_expenses/1/ignore \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
Restore a Pre-Expense
When restoring a Pre-Expense, it will appear in the default list of Pre-Expenses (Pre-Expenses waiting approval of the user).
Definition
PUT https://app.rexpense.com/api/v1/pre_expenses/:id/restore
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PUT https://app.rexpense.com/api/v1/pre_expenses/1/restore \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
Convert a Pre-Expense
When a Pre-Expense is converted, it creates a new Expense. To convert a Pre-Expense, you have to provide some parameters so the Expense can be created.
After created, the Expense is in its initial status Awaiting analysis
and it follows its natural process.
When request is succeed, the response will contain the created Expense information with the pre_expense_id
.
Parameters
description: | string |
payer: |
payer object attributes required
id: integer
type: string |
amount: | float required |
occurred_at: | string iso8601 format required |
tags: | string |
latitude: | float |
longitude: | float |
location: | string |
Definition
POST https://app.rexpense.com/api/v1/pre_expenses/:id/convert
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/pre_expenses/1/convert \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"description": "Some description", "amount": 125.99, "payer": {"id": 1, "type": "Organization"}, "tags": [], "liquidate_through_advancement": false}'
Response Example Success
HTTP 200 OK
Destroy a Pre-Expense
Definition
DELETE https://app.rexpense.com/api/v1/pre_expenses/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/pre_expenses/:id \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 204 NO CONTENT