Rest API List of receipt markers - datawizio/pythonAPI GitHub Wiki
List of receipt markers - is a list of markers used for a certain types of sales. With the help of /receipt-markers/
resource one can get access to the list of receipt-markers and add new markers.
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
url |
URL | no | yes | url of this object | |
brand_id |
line | yes | no | marker identifier | |
name |
line | no | no | marker name |
The following commands are used with the /Receipt-markers/
resource:
-
GET
- to receive one page from collection -
POST
- to add new marker or list of markers -
OPTIONS
- meta information about the object structure -
HEAD
- similar toGET
, but shows only heading of the response
Command type: GET http://api.datawiz.io/api/v1/receipt-markers/
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 by server:
GET http://api.datawiz.io/api/v1/brands/?max_date=0000-00-00
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
Example of a 2-element collection:
GET http://api.datawiz.io/api/v1/receipt-markers/?format=json&page_size=2:
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"url": "http://api.datawiz.io/api/v1/receipt-markers/RECEIP-MARKER-ID-6V1J-J7WO-GJEJ/",
"marker_id": "RECEIP-MARKER-ID-6V1J-J7WO-GJEJ",
"name": "wholesale"
},
{
"url": "http://api.datawiz.io/api/v1/receipt-markers/RECEIP-MARKER-ID-IMBJ-YNPT-ZR0S/",
"marker_id": "RECEIP-MARKER-ID-IMBJ-YNPT-ZR0S",
"name": "on offer"
}
}
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/receipt-markers/?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 marker. Two fields are important: marker_id
and name
.
Example of correct requests to add new marker:
POST http://api.datawiz.io/api/v1/receipt-markers/.json
{
"marker_id": "0fa9d963-62b9-11e5-81c6-001b21a1ef75",
"name": "Kalynivka"
}
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/receipt-markers/
Allow: GET, POST, HEAD, OPTIONS
{
"created": 1,
"updated": 0
}
Constraints:
One can not add to server a marker if there is already a marker with an indicated marker_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 (marker_id
field is empty):
HTTP 400 BAD REQUEST
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
{
"marker_id": [
"This field is required."
]
}
The following JSON structure returns at this command:
OPTIONS /api/v1/receipt-markers/
HTTP 200 OK
Allow: GET, POST, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"name": "Receipt Marker List",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"POST": {
"url": {
"type": "string",
"required": false,
"read_only": true,
"label": "Url"
},
"marker_id": {
"type": "string",
"required": true,
"read_only": false,
"label": "Marker id",
"max_length": 150
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"max_length": 150
}
}
}
}