Rest API List of pay order document - datawizio/pythonAPI GitHub Wiki

28. Resource /order-pay-documents/ (List of pay order document, Collection)

With the help of /order-pay-documents/ resource one can get access to the list of payments for received goods and add new pay orders.

28.1. Pay order structure:

28.1.1. order-pay-document object structure

Field name Field type Size Required Read only Remark
url URL no yes link to an object
document_id line yes no Pay order identifier
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 time and date of the document
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
responsible line no no person responsible for return
description line no no additional notes
total_price number yes no total price

28.2. Available commands

The following commands are used with the /order-pay-documents/ resource:

  • GET - to receive one page from collection
  • POST - to add new pay order document or list of documents
  • OPTIONS - meta information about the object structure
  • HEAD - similar to GET, but shows only heading of the response

28.2.1. GET /order-pay-documents/ - to receive one page of a collection.

Command type: GET http://api.datawiz.io/api/v1/order-pay-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}
  • 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/supplier-refunds/

{
     "count": 0, 
     "next": null, 
     "previous": null, 
     "results": [] 
} 

Example of a 1-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": 1,
"next": null,
"previous": null,
"results": [
{
"url": "http://api.datawiz.io/api/v1/order-pay-documents/test-1_9856d0f5-0929-11e5-80d8-7054d2c57800/",
"document_id": "test-1",
"receive_document_url": "http://api.datawiz.io/api/v1/receive-documents/9856d0f5-0929-11e5-80d8-7054d2c57800_1111/",
"shop_id": "9856d0f5-0929-11e5-80d8-7054d2c57800",
"shop_url": "http://api.datawiz.io/api/v1/shops/9856d0f5-0929-11e5-80d8-7054d2c57800/",
"supplier_id": "supplier-1",
"supplier_ulr": "http://api.datawiz.io/api/v1/suppliers/supplier-1/",
"date": "2017-01-01T00:00:00",
"doc_number": "000",
"responsible": "AAA",
"description": "",
"total_price": "100.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"
}

27.2.2. POST /order-pay-documents/ - to add new refund document

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/order-pay-documents/.json

{
    "document_id": "test-1",
    "receive_document_id": "9856d0f5-0929-11e5-80d8-7054d2c57800_1111",
    "shop_id": "9856d0f5-0929-11e5-80d8-7054d2c57800",
    "supplier_id": "supplier-1",
    "date": "1/1/2017",
    "doc_number": "000",
    "responsible": "Petro",
    "description": "",
    "total_price": 100
}

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." 
     ] 
} 

27.2.3. OPTIONS /supplier-refunds/ - meta information about an object structure

The following JSON structure returns at this command:

OPTIONS /api/v1/order-pay-documents/

HTTP 200 OK
Allow: GET, POST, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "name": "Order Pay 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": 150
            },
            "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"
            },
            "shop_id": {
                "type": "integer",
                "required": true,
                "read_only": false,
                "label": "Shop id"
            },
            "shop_url": {
                "type": "integer",
                "required": false,
                "read_only": true,
                "label": "Shop 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"
            },
            "date": {
                "type": "datetime",
                "required": true,
                "read_only": false,
                "label": "Date"
            },
            "doc_number": {
                "type": "string",
                "required": false,
                "read_only": false,
                "label": "Doc number",
                "max_length": 200
            },
            "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
            },
            "total_price": {
                "type": "decimal",
                "required": true,
                "read_only": false,
                "label": "Total price"
            }
        }
    }
}
⚠️ **GitHub.com Fallback** ⚠️