expenses

The following resources are applicable:

/expenses

Mount Point: /rest/v2/expenses

The following operations are supported on this resource:

GET

RESTful service to list all the expenses of the authorised client (i.e. the Resource Owner in OAuth terms). Accepts a http GET request to /expenses.

Parameters

name description type default
firstResult Optional, defaults to 0

Used for pagination, the firstResult query parameter specifies the first record to be returned by the 'List All Sales Invoices' end point. The parameter is 0 index-based, and so if requesting the first sales invoice in the list of sales invoices, firstResult should be set to 0.

The firstResult parameter is optional, and the default value for firstResult is 0. If specified, firstResult should be set to any non-negative integer.

query 0
resultsPerPage Optional, defaults to 0

Used for pagination, the resultsPerPage query parameter specifies the maximum number of results returned by the 'List All Sales Invoices' service.

The resultsPerPage parameter is relative to the firstResult parameter - therefore if firstResult is set to 0 and resultsPerPage is set to 10, then only the first 10 sales invoices from the overall list of sales invoices will be returned.

If firstResult is set to 10 and resultsPerPage is set to 10, then the service will return the next 10 records (i.e the sales invoices at positions 10 to 19 in the complete list of sales invoices).

query
supplierId The id of the supplier. query
date Optional, defaults to empty string query
dateFrom Optional, defaults to empty string query
dateTo Optional, defaults to empty string query

Response Body

element: expenses
media types: application/xml
application/json

Expenses or Errors

Status Codes

HTTP Status Code Description
200 OK Expenses found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

POST

RESTful service to add a new expense to the Crunch account of the authorised client (i.e. the Resource Owner in OAuth terms). Accepts both a http PUT or a http POST to the /expense path

Request Body

element: expense
media types: application/xml
application/json

The expense to add

Response Body

element: expense
media types: application/xml
application/json

Expense (with only the newly created Expense ID set) or Errors

Status Codes

HTTP Status Code Description
201 Created Expense added
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

OPTIONS

Options call to handle CORS requests (typically coming from javascript frameworks like jQuery) See here for further information.

Response Body

element: (custom)
media types: */*
application/xml

(no documentation provided)

/expenses/{expenseId}

Mount Point: /rest/v2/expenses/{expenseId}

GET

RESTful service to retrieve all of the available expense details for the expense who's ID is specified as the last element to the resource URL. e.g. performing a HTTP GET request to: http:///rest/v2/expense/1 will return the expense who's id is 1. The id of the expense can be found within the listing of expenses retrieved from the /expenses service. This service will always return all of the expense details.

Parameters

name description type default
expenseId The id of the expense. path

Response Body

element: expense
media types: application/xml
application/json

Expense or Errors

Status Codes

HTTP Status Code Description
200 OK Expense found
404 Not Found Expense not found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

DELETE

RESTful service to delete the expense who's ID is specified as the last element to the resource URL. e.g. performing a HTTP DELETE request to: http:///rest/v2/expense/1

The id of the expense can be found within the listing of expenses retrieved from the /expenses service.

Parameters

name description type default
expenseId The id of the expense to be deleted. path

Response Body

element: expense
media types: application/xml
application/json

empty body or Errors

Status Codes

HTTP Status Code Description
204 No Content Expense deleted
404 Not Found Expense (id) not found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred