Return Authorizations API
Index
To list all return authorizations for an order, make a request like this:
GET /api/orders/R1234567/return_authorizations
Return authorizations are paginated and can be iterated through by passing along a page
parameter:
GET /api/orders/R1234567/return_authorizations?page=2
Parameters
- page
- The page number of return authorization to display.
- per_page
- The number of return authorizations to return per page
Response
Status: 200 OK
{
"return_authorizations": [
{
"id": 1,
"number": "12345",
"state": "authorized",
"amount": 14.22,
"order_id": 14,
"reason": "Didn't fit",
"created_at": "2012-10-24T23:26:23Z",
"updated_at": "2012-10-24T23:26:23Z"
}
],
"count": 2,
"pages": 1,
"current_page": 1
}
Search
To search for a particular return authorization, make a request like this:
GET /api/orders/R1234567/return_authorizations?q[reason_cont]=damage
The searching API is provided through the Ransack gem which Spree depends on. The reason_cont
here is called a predicate, and you can learn more about them by reading about Predicates on the Ransack wiki.
The search results are paginated.
Sorting results
Results can be returned in a specific order by specifying which field to sort by when making a request.
GET /api/orders/R1234567/return_authorizations?q[s]=amount%20asc
Response
Status: 200 OK
{
"return_authorizations": [
{
"id": 1,
"number": "12345",
"state": "authorized",
"amount": 14.22,
"order_id": 14,
"reason": "Didn't fit",
"created_at": "2012-10-24T23:26:23Z",
"updated_at": "2012-10-24T23:26:23Z"
}
],
"count": 1,
"pages": 1,
"current_page": 1
}
Show
To get information for a single return authorization, make a request like this:
GET /api/orders/R1234567/return_authorizations/1
Response
Status: 200 OK
{
"id": 1,
"number": "12345",
"state": "authorized",
"amount": 14.22,
"order_id": 14,
"reason": "Didn't fit",
"created_at": "2012-10-24T23:26:23Z",
"updated_at": "2012-10-24T23:26:23Z"
}
Create
To create a return authorization, make a request like this:
POST /api/orders/R1234567/return_authorizations
For instance, if you want to create a return authorization with a number, make this request:
POST /api/orders/R1234567/return_authorizations?return_authorization[number]=123456
Response
Status: 201 Created
{
"id": 1,
"number": "12345",
"state": "authorized",
"amount": 14.22,
"order_id": 14,
"reason": "Didn't fit",
"created_at": "2012-10-24T23:26:23Z",
"updated_at": "2012-10-24T23:26:23Z"
}
Update
To update a return authorization, make a request like this:
PUT /api/orders/R1234567/return_authorizations/1
For instance, to update a return authorization’s number, make this request:
PUT /api/orders/R1234567/return_authorizations/1?return_authorization[number]=123456
Response
Status: 200 OK
{
"id": 1,
"number": "12345",
"state": "authorized",
"amount": 14.22,
"order_id": 14,
"reason": "Didn't fit",
"created_at": "2012-10-24T23:26:23Z",
"updated_at": "2012-10-24T23:26:23Z"
}
Delete
To delete a return authorization, make a request like this:
DELETE /api/orders/R1234567/return_authorizations/1
Response
Status: 204 No Content