Rest API List of inventory documents
Inventory documents. With the help of /stock-taking-documents/
you can get access to the list of inventory documents and add new documents.
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
url |
URL | no | yes | url of this object | |
document_id |
string | yes | no | document identifier | |
date |
time and date | 50 | yes | no | time and date of stocktaking |
shop_id |
string | 50 | yes | no | shop identifier |
shop_url |
URL | no | yes | url of this object | |
stuff_id |
строка | 50 | нет | нет | cashier identifier |
stuff_url |
строка | no | yes | url of the cashier | |
products |
list | yes | no | array of products |
Each product has some characteristics that can be shown in the next structure:
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
product_id |
line | 200 | yes | no | product identifier from the Catalog of products (see .[/products/ ]) |
product_url |
URL | no | yes | product identifier url | |
stock_qty |
number | yes | yes | Stock qty | |
fact_qty |
number | yes | yes | actual stock qty |
To manage the /stock-taking-documents/
resource, the following commands are used:
-
GET
- to receive one page on a collection -
POST
- to load documents -
OPTIONS
- meta information about an object structure -
HEAD
- similar to GET, but you receive only a heading of a response
Command type: GET http://api.datawiz.io/api/v1/stock-taking-documents
Suffixes:
-
.json
- to receive a response from a server in JSON format -
.api
- to receive a response from a server in HTML format (test platform)
Parameters:
-
format = json | api
- similar to the stated above suffixes -
page_size = {nn}
- to establish a page size equal to{nn}
objects -
page = {n}
- to load a page{n}
-
search = text
- to show only the objects, whichname
contain "text" -
ordering = name | identifier
- to sort fields alphabetically (ascending) -
ordering = -name | -identifier
- to sort fields in the reverse order
Server's response:
The "collection" object consists of four fields (count
, next
, previous
, results
).
An example of an empty collection returned by server:
GET http://api.datawiz.io/api/v1/stock-taking-documents/.json/?search=unknown-string
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
Example of collection:
GET http://api.datawiz.io/api/v1/stock-taking-documents/?format=api&page_size=2:
HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS
[
{
"url": "http://api.datawiz.io/api/v1/stock-taking-documents/cb2084aa-4644-11e5-80d8-a01d4897e530/",
"document_id": "cb2084aa-4644-11e5-80d8-a01d4897e530",
"date": "2015-01-01T00:00:00",
"shop_id": "675",
"shop_url": "http://api.datawiz.io/api/v1/shops/46e08f10-cbe3-11e4-80b9-a01d4897e530/",
"stuff_id": null,
"stuff_url": null,
"products": [
{
"product_id": null,
"product_url": "http://api.datawiz.io/api/v1/products/a26f866b-1465-11e5-80cb-a01d4897e530/",
"stock_qty": "2.0000",
"fact_qty": "10.0000"
}
]
},
. . .
]
}
Error report:
In case of an error, server returns a response with a corresponding status and an error report in detail
key and/or in field http.response.content
:
HTTP 404 NOT FOUND
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS, PATCH
{
"detail": "Not found"
}
Command type: POST http://api.datawiz.io/api/v1/stock-taking-documents/?format=json
Suffixes:
-
.json
- to receive a response from a server in JSON format -
.api
- to receive a response from a server in HTML format (test platform)
Parameters:
-
format = json | api
- similar to the stated above suffixes
Request data:
A request contains a JSON-object of dictionary type describing documents.
Important fields: document_id
, document_date
, shop_id
, products
, product_id
, stock_qty
, fact_qty
. The sequence of fields is not important.
Example of request to load documents:
POST http://api.datawiz.io/api/v1/stock-taking-documents/.json
{
"url": "http://api.datawiz.io/api/v1/stock-taking-documents/cb2084aa-4644-11e5-80d8-a01d4897e530/",
"document_id": "cb2084aa-4644-11e5-80d8-a01d4897e530",
"date": "2015-01-01T00:00:00",
"shop_id": "675",
"shop_url": "http://api.datawiz.io/api/v1/shops/46e08f10-cbe3-11e4-80b9-a01d4897e530/",
"stuff_id": null,
"stuff_url": null,
"products": [
{
"product_id": null,
"product_url": "http://api.datawiz.io/api/v1/products/a26f866b-1465-11e5-80cb-a01d4897e530/",
"stock_qty": "2.0000",
"fact_qty": "10.0000"
}
]
}
Server's response:
At a particular request processing the server returns 201 status code and object creation details.
Example of a server's response:
HTTP 201 CREATED
Content-Type: application/json
Vary: Accept
Location: http://api.datawiz.io/api/v1/stock-taking-documents/124/
Allow: GET, POST, HEAD, OPTIONS
{
"updated": 0,
"inserted": 1
}
Conditions and constraints:
- If an object with
document_id
,shop_id
already exists on the server, the request will replace the object on server without notification. - One can not add to server an object if there is no product with an indicated
product_id
Error report:
In case of an error, server returns a response with a corresponding status and an error report next to the field, related to that error. If an error is not only about one field, but the whole object, the report will appear next to the key non_field_errors
.
Example of server's response with an error (product_id
field is empty):
HTTP 400 BAD REQUEST
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
{
"product_id": [
"This field is required."
]
}
The following JSON structure returns at this command:
OPTIONS /api/v1/stock-taking-documents/
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
"name": "Stock Taking Document List",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"POST": {
"url": {
"type": "field",
"required": false,
"read_only": true,
"label": "Url"
},
"document_id": {
"type": "string",
"required": true,
"read_only": false,
"label": "Document id",
"max_length": 200
},
"stuff_id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "Stuff id"
},
"stuff_url": {
"type": "integer",
"required": false,
"read_only": true,
"label": "Stuff url"
},
"shop_id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "Shop id"
},
"shop_url": {
"type": "integer",
"required": false,
"read_only": true,
"label": "Shop url"
},
"date": {
"type": "datetime",
"required": true,
"read_only": false,
"label": "Date"
},
"products": {
"type": "field",
"required": true,
"read_only": false,
"label": "Products",
"child": {
"type": "nested object",
"required": true,
"read_only": false,
"children": {
"url": {
"type": "field",
"required": false,
"read_only": true,
"label": "Url"
},
"product_id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "Product id"
},
"product_url": {
"type": "integer",
"required": false,
"read_only": true,
"label": "Product url"
},
"stock_qty": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Stock qty"
},
"fact_qty": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Fact qty"
}
}
}
}
}
}
}