Rest API List of refunds to supplier - datawizio/pythonAPI GitHub Wiki
With the help of /supplier-refunds/
resource one can get access to the list of returns to supplier and add new returns.
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
url |
URL | no | yes | url of this object | |
document_id |
line | yes | no | identifier of refund | |
supplier_id |
line | yes | no | supplier identifier | |
supplier_url |
URL | no | yes | link to a supplier | |
shop_id |
line | yes | no | shop identifier | |
shop_url |
URL | no | yes | link to a shop | |
date |
line | yes | no | return date | |
responsible |
line | no | no | person responsible for return | |
description |
line | no | no | additional notes | |
products |
list | yes | no | list of returned products |
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
url |
URL | no | yes | link to a returned product | |
product_id |
line | yes | no | product identifier | |
product_url |
URL | no | yes | link to a product | |
receive_document_id |
line | yes | no | Complex identifier of refund document (<shop identifier>_<document identifier> ) |
|
receive_document_url |
URL | no | yes | link to a document for receiving products | |
qty |
number | yes | no | quantity of items | |
price |
number | yes | no | product price | |
total_price |
number | yes | no | total price of products |
The following commands are used with the /supplier-refunds/
resource:
-
GET
- to receive one page from collection -
POST
- to add new refund document or list of documents -
OPTIONS
- meta information about the object structure -
HEAD
- similar to GET, but shows only heading of the response
Command type: GET http://api.datawiz.io/api/v1/supplier-refunds/
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}
-
Ordering = url | date | order_id
- to sort fields in ascending order -
Ordering = -url | -date | order_id
- to sort fields in reverse order
Server's response:
The "collection" object consists of four fields (count
, next
, previous’,
results`).
An example of an empty collection returned b server:
GET http://api.datawiz.io/api/v1/supplier-refunds/
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
Example of a 2-element collection:
GET http://api.datawiz.io/api/v1/supplier-refunds/?format=json&page_size=2:
HTTP 200 OK
Allow: GET, POST, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"url": "http://api.datawiz.io/api/v1/supplier-refunds/test-document_1147/",
"supplier_id": "supplier-1",
"supplier_url": "http://api.datawiz.io/api/v1/suppliers/supplier-1/",
"shop_id": "37a9969a-1ce0-11e6-b15d-00505600b73b",
"shop_url": "http://api.datawiz.io/api/v1/shops/37a9969a-1ce0-11e6-b15d-00505600b73b/",
"date": "2017-01-01T15:39:00",
"identifier": "test-document",
"responsible": null,
"description": null,
"products": [
{
"url": "http://api.datawiz.io/api/v1/supplier-refunds/test-document_1147/products/4/",
"product_id": "43b9900b-78b0-11e5-ab16-000c29883704",
"product_url": "http://api.datawiz.io/api/v1/products/43b9900b-78b0-11e5-ab16-000c29883704/",
"receive_document_url": "http://api.datawiz.io/api/v1/receive-documents/9856d0f5-0929-11e5-80d8-7054d2c57800_1111/",
"qty": "1.0000",
"price": "5.0000",
"total_price": "5.0000"
}
]
},
{
"url": "http://api.datawiz.io/api/v1/supplier-refunds/test-document2_1147/",
"supplier_id": "supplier-1",
"supplier_url": "http://api.datawiz.io/api/v1/suppliers/supplier-1/",
"shop_id": "37a9969a-1ce0-11e6-b15d-00505600b73b",
"shop_url": "http://api.datawiz.io/api/v1/shops/37a9969a-1ce0-11e6-b15d-00505600b73b/",
"date": "2017-01-01T15:39:00",
"identifier": "test-document2",
"responsible": null,
"description": null,
"products": [
{
"url": "http://api.datawiz.io/api/v1/supplier-refunds/test-document2_1147/products/5/",
"product_id": "43b9900b-78b0-11e5-ab16-000c29883704",
"product_url": "http://api.datawiz.io/api/v1/products/43b9900b-78b0-11e5-ab16-000c29883704/",
"receive_document_url": "http://api.datawiz.io/api/v1/receive-documents/9856d0f5-0929-11e5-80d8-7054d2c57800_1111/",
"qty": "1.0000",
"price": "5.0000",
"total_price": "5.0000"
}
]
}
]
}
Error report:
In case of an error, server returns a response with a corresponding status and an error report in detail
key:
HTTP 404 NOT FOUND
Content-Type: application/json
Vary: Accept
Allow: GET, PUT, DELETE, HEAD, OPTIONS, PATCH
{
"detail": "Not found"
}
Command type: POST http://api.datawiz.io/api/v1/supplier-refunds/?format=json
Suffixes:
-
.json
- to interact with a server in JSON format -
.api
- to interact with a server in HTML format (test platform)
Parameters:
-
format=json
- to interact with a server in JSON format -
format=api
- to interact with a server in HTML format (test platform)
Request data:
The request contains JSON object describing a refund.
Example of correct requests to add new document:
POST http://api.datawiz.io/api/v1/supplier-refunds/.json
{
"supplier_id": "supplier-1",
"shop_id": "37a9969a-1ce0-11e6-b15d-00505600b73b",
"date": "2017-1-1 15:39:00",
"document_id": "test-document",
"products": [{"product_id": "43b9900b-78b0-11e5-ab16-000c29883704", "qty": 1, "price": 5, "total_price": 5, "receive_document_id": "9856d0f5-0929-11e5-80d8-7054d2c57800_1111"}]
}
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/supplier-refunds/
Allow: GET, POST, HEAD, OPTIONS
{
"created": 1,
"updated": 0
}
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 (brand_id
field is empty):
HTTP 400 BAD REQUEST
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
{
"document_id": [
"This field is required."
]
}
The following JSON structure returns at this command:
OPTIONS /api/v1/supplier-refunds/
HTTP 200 OK
Allow: GET, POST, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"name": "Supplier Refund 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"
},
"supplier_id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "Supplier id"
},
"supplier_url": {
"type": "integer",
"required": false,
"read_only": true,
"label": "Supplier 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"
},
"identifier": {
"type": "string",
"required": true,
"read_only": false,
"label": "Identifier",
"max_length": 150
},
"responsible": {
"type": "string",
"required": false,
"read_only": false,
"label": "Responsible",
"max_length": 150
},
"description": {
"type": "string",
"required": false,
"read_only": false,
"label": "Description",
"max_length": 200
},
"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"
},
"receive_document_id": {
"type": "string",
"required": true,
"read_only": false,
"label": "Receive document id",
"max_length": 300
},
"receive_document_url": {
"type": "field",
"required": false,
"read_only": true,
"label": "Receive document url"
},
"qty": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Qty"
},
"price": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Price"
},
"total_price": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Total price"
}
}
}
}
}
}
}