Stock Locations
Index
To get a list of stock locations, make this request:
GET /api/v1/stock_locations
Stock locations are paginated and can be iterated through by passing along a page
parameter:
GET /api/v1/stock_locations?page=2
Parameters
- page:
The page number of stock location to display.
- per_page:
The number of stock locations to return per page
Response
{"stock_locations": [{"id": 1,"name": "default","address1": "7735 Old Georgetown Road","address2": "Suite 510","city": "Bethesda","state_id": 1,"state_name": null,"country_id": 1,"zipcode": "20814","phone": "","active": true,"country": {"id": 1,"iso_name": "UNITED STATES","iso": "US","iso3": "USA","name": "United States","numcode": 1},"state": {"id": 1,"name": "New York","abbr": "NY","country_id": 1}}],"count": 5,"current_page": 1,"pages": 1}
Search
To search for a particular stock location, make a request like this:
GET /api/v1/stock_locations?q[name_cont]=default
The searching API is provided through the Ransack gem which Boxid depends on. The name_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.
Response
{"stock_locations": [{"id": 1,"name": "default","address1": "7735 Old Georgetown Road","address2": "Suite 510","city": "Bethesda","state_id": 1,"state_name": null,"country_id": 1,"zipcode": "20814","phone": "","active": true,"country": {"id": 1,"iso_name": "UNITED STATES","iso": "US","iso3": "USA","name": "United States","numcode": 1},"state": {"id": 1,"name": "New York","abbr": "NY","country_id": 1}}],"count": 5,"current_page": 1,"pages": 1}
Show
To get information for a single stock location, make this request:
GET /api/v1/stock_locations/1
Response
{"id": 1,"name": "default","address1": "7735 Old Georgetown Road","address2": "Suite 510","city": "Bethesda","state_id": 1,"state_name": null,"country_id": 1,"zipcode": "20814","phone": "","active": true,"country": {"id": 1,"iso_name": "UNITED STATES","iso": "US","iso3": "USA","name": "United States","numcode": 1},"state": {"id": 1,"name": "New York","abbr": "NY","country_id": 1}}
Create
To create a stock location, make a request like this:
POST /api/v1/stock_locations
Assuming in this instance that you want to create a stock location with a name of East Coast
, send through the parameters like this:
{
"stock_location": {
"name": "East Coast"
}
}
Response
{"id": 1,"name": "East Coast","address1": "7735 Old Georgetown Road","address2": "Suite 510","city": "Bethesda","state_id": 1,"state_name": null,"country_id": 1,"zipcode": "20814","phone": "","active": true,"country": {"id": 1,"iso_name": "UNITED STATES","iso": "US","iso3": "USA","name": "United States","numcode": 1},"state": {"id": 1,"name": "New York","abbr": "NY","country_id": 1}}
Update
To update a stock location, make a request like this:
PUT /api/v1/stock_locations/1
To update stock location information, use parameters like this:
{
"stock_location": {
"name": "North Pole"
}
}
Response
{"id": 1,"name": "North Pole","address1": "7735 Old Georgetown Road","address2": "Suite 510","city": "Bethesda","state_id": 1,"state_name": null,"country_id": 1,"zipcode": "20814","phone": "","active": true,"country": {"id": 1,"iso_name": "UNITED STATES","iso": "US","iso3": "USA","name": "United States","numcode": 1},"state": {"id": 1,"name": "New York","abbr": "NY","country_id": 1}}
Delete
To delete a stock location, make a request like this:
DELETE /api/v1/stock_locations/1
This request will also delete any related stock item
records.