Corporative cards
This section describes the API of the corporative card resource.
Parameters
id: | integer |
name: | string |
flag: | JSON object |
number: | string |
expiration_date: | string |
expiration_month: | integer |
expiration_year: | integer |
active: | boolean |
user: | JSON object |
organization: | JSON object |
_links: |
array of object array of links of the corporative card |
Example of Corporative card
List all corporative cards of the user
Retrieve all corporative cards that the authenticated user have. 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 corporative cards can be
found in the Corporative card section.
Parameters
page: | integer |
per_page: | integer limit to 100 |
Definition
GET https://app.rexpense.com/api/v1/corporative_cards
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/corporative_cards \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
Filtering corporative cards
You can filter the list of retrieved corporative cards.
Parameters
All parameters must be nested a q
parameter.
id_in: | array of integer |
name_cont: | string |
flag_cont: | string |
organization_id_in: | array of integer |
active_eq: | boolean |
created_at_lteq: | string |
updated_at_gteq: | string |
Definition
GET https://app.rexpense.com/api/v1/corporative_cards
Request example
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/corporative_cards \
-H 'Accept: application/json' \
-H 'Content-type: application/json' \
-d '{"q": {"id": [1]}}'
Response Example
Show a corporative card
This request shows the corporative card complete information.
Parameters
id: | integer required |
Definition
GET https://app.rexpense.com/api/v1/corporative_cards/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/corporative_cards/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 a corporative card
This request creates a new corporative card.
Important:
- The authenticated user must belong to an organization to create a new corporative card.
- A corporative card must be attached to an organization.
Parameters
name: | string |
number: | string |
expiration_date: | string MM/YY format |
organization_id: | integer |
user_id: | integer |
active: | boolean |
Definition
POST https://app.rexpense.com/api/v1/corporative_cards
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/corporative_cards \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"name": "Credit card", "number": "1234567890123456", "organization_id": 1, ... }'
Response Example Success
HTTP 201 CREATED
Response Example Failure
HTTP 422 Unprocessable Entity
Update a corporative card
There are two ways to update a corporative card: 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 corporative card. This behaviour is the same for all resources in the Rexpense API.
Parameters
name: | string required |
expiration_date: | string MM/YY format |
active: | boolean |
organization_id: | integer required |
Definition
PUT/PATCH https://app.rexpense.com/api/v1/corporative_cards/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/corporative_cards/:id \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"name": "John John"}'
Response Example Success
HTTP 200 OK
Response Example Failure
HTTP 422 Unprocessable Entity
Destroy a corporative card
To destroy a corporative card it has to have no expense attached to it.
Definition
DELETE https://app.rexpense.com/api/v1/corporative_cards/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/corporative_cards/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 204 NO CONTENT
Example Response Failure when corporative card has expenses attached to it
HTTP 422 Unprocessable entity