DIRMEIER_logo

DIRMEIER
smartschank

REST API for Cash Interface

Version 1.0
10. Oktober 2023

1. Introduction

Dirmeier's REST API for Cash Interface provides a contemporary way to communicate between a cash register and Dirmeier's dispensing equipment. It lifts all known methods from the outdated serial communication to an HTTP/REST API, improving the process. No special equipment like serial cables and cash registers with COM-Ports are needed.

2. Schemas

2.1. Credit

{
  "type": "object",
  "properties": {
    "ID": { "type": "number" }, 
    "Waiter": { "type": "number" }, 
    "PLU": { "type": "number" }, 
    "Count": { "type": "number" }, 
    "Table": { "type": "number" },
    "Place": { "type": "number" },
    "ArticleName" : { "type": "string" },
    "StationID": { "type": "number" },
    "CustomerID": { "type": "number" }
  }
  "required": ["ID", "Waiter", "PLU", "Count"]
  // Note: For PUT requests, ID is passed separately as a URL parameter
}

Example:

{
  "Waiter": 1,
  "PLU": 101,
  "Count": 1
}
// Note: ID is passed separately as a URL parameter, (not shown here)

2.2. CreditList

{
  "type": "object",
  "properties": {
    "Credits": {
      "type": "array",
      "items": { "$ref": "#/components/schemas/Credit" }
    }
  }
}

Example:

{
  "Credits": [
    {
      "ID": 11696861732318,
      "Waiter": 2,
      "PLU": 103,
      "Table": 3,
      "Place": 4,
      "StationID": -1,
      "CustomerID": "5",
      "Count": 2
    },
    {
      "ID": 11696861732319,
      "Waiter": 1,
      "PLU": 103,
      "Table": 1,
      "Place": 1,
      "StationID": -1,
      "CustomerID": "3",
      "Count": 2
    }
  ]
}

2.3. Debit

{
  "type": "object",
  "properties": {
    "ID": { "type": "number" },
    "Waiter": { "type": "number" },
    "PLU": { "type": "number" },
    "Place": { "type": "number" },
    "Table": { "type": "number" },
    "Price": { "type": "number" },
    "Articlename": { "type": "string" },
    "Amount": { "type": "number" },
    "Count": { "type": "number" }
  }
}

Example:

{
  "ID": 10820,
  "Waiter": 1,
  "PLU": 201,
  "Place": 0,
  "Table": 5,
  "Price": 0,
  "Articlename": "Bt",
  "Amount": 0,
  "Count": 1
}

2.4. DebitList

{
  "type": "object",
  "properties": {
    "Debits": {
      "type": "array",
      "items": { "$ref": "#/components/schemas/Debit" }
    }
  }
}

Example:

{
  "Debits": [
    {
      "ID": 10820,
      "Waiter": 1,
      "PLU": 201,
      "Place": 0,
      "Table": 5,
      "Price": 0,
      "Articlename": "Cola",
      "Amount": 0,
      "Count": 1
    },
    {
      "ID": 10821,
      "Waiter": 1,
      "PLU": 201,
      "Place": 0,
      "Table": 5,
      "Price": 0,
      "Articlename": "Cola",
      "Amount": 0,
      "Count": 1
    }
  ]
}

3. Endpoints

3.1. Credits

3.1.1. GET /credits

3.1.2. POST /credits

3.1.3. GET /credits/

3.1.4. DELETE /credits/

3.1.5. PUT /credits/

3.2. Debits

3.2.1. GET /debits

3.2.2. DELETE /debits

3.2.3. GET /debits/

3.2.4. DELETE /debits/

4. Use-Cases

4.1. Send Credit

4.1.1. Workflow:

SSACashSSACashSSA creates an empty creditCash receives the location of the new creditCash sends the data to fill the creditSSA updates the credit with the provided dataPOST /credits (Create Credit)201 Created, Location Header with Credit IDPUT /credits/{credit_id} (Update specific credit)200 OK

4.1.2. Example:

  1. Creating an Empty Credit:

    POST /credits HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    Content-Type: application/json
    

    Response:

    HTTP/1.1 201 Created
    Location: /credits/11667928260823
    
  2. Updating the Created Credit:

    PUT /credits/11667928260823 HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    Content-Type: application/json
    
    {
      "Waiter": 3,
      "PLU": 103,
      "Count": 3
    }
    

    Response:

    HTTP/1.1 200 OK
    

4.2. Credit Cancellation

4.2.1. Workflow:

SSACashSSACashSSA creates new ressourceCash receives the location of the new ressourceCash sends Credit Data (desired PLU and count as negative count)SSA reduces existing credits (with the sent PLU) by the desired countPOST /credits (Create Credit)201 Created, Location Header IDPUT /credits/{credit_id} (Update ressource with PLU and negative count for cancellation)200 OK

Important Note for Users:
While it is possible to cancel an existing credit with the DELETE endpoint, it is recommendend to use this approach instead. The described cancellation process does not target a specific resource but rather cancels a product (identified by the PLU) from any available credits. For example, if there are two sets of POST & PUT requests, one with a count of 3 and another with a count of 2, these can be cancelled by a new POST followed by a PUT with a count of -5. The DELETE method, on the other hand, removes a specific resource. However, there might be cases where the resource is no longer available in the system, resulting in a 404 response. Therefore, for standard cancellation procedures, it is advisable to use the POST & PUT method. The DELETE method is primarily for handling exceptional cases and might not always be implemented.

4.2.2. Example:

  1. Creating an Empty Credit for Cancellation:

    POST /credits HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    Content-Type: application/json
    

    Response:

    HTTP/1.1 201 Created
    Location: /credits/11667928260824
    
  2. Cancelling the Credit with Negative Count:

    PUT /credits/11667928260824 HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    Content-Type: application/json
    
    {
      "Waiter": 4,
      "PLU": 104,
      "Count": -2
    }
    

    Response:

    HTTP/1.1 200 OK
    

4.3. Fetch Debits

4.3.1. Workflow:

SSACashSSACashCash receives a list of all available debitsSpecific debit is deletedMultiple debits are deletedGET /debits (Request Debit List)200 OK, DebitListDELETE /debits/{debit_id} (Delete specific debit)200 OKDELETE /debits (Send DebitList to delete multiple debits)200 OK

4.3.2. Example:

  1. Fetching List of Debits:

    GET /debits HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    

    Response:

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "Debits": [
          {
              "ID": 18652,
              "Waiter": 2,
              "PLU": 13,
              "Place": 0,
              "Table": 802,
              "Price": 310.00,
              "Articlename": "Cola 1/2",
              "Amount": 550,
              "Count": 1
          },
          {
              "ID": 18653,
              "Waiter": 2,
              "PLU": 19,
              "Place": 0,
              "Table": 802,
              "Price": 0.00,
              "Articlename": "Orangenlimo 1/4",
              "Amount": 25,
              "Count": 1
          },
          {
              "ID": 18654,
              "Waiter": 2,
              "PLU": 19,
              "Place": 0,
              "Table": 802,
              "Price": 0.00,
              "Articlename": "Orangenlimo 1/4",
              "Amount": 25,
              "Count": 1
          }
        ]
      }
    
  2. Deleting a Specific Debit:

    DELETE /debits/18652 HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    

    Response:

    HTTP/1.1 200 OK
    
  3. Deleting Multiple Debits:

    DELETE /debits HTTP/1.1
    Host: http://192.168.2.39/cash/1.0
    Content-Type: application/json
    
    {
      "Debits": [
          {
              "ID": 18653,
              "Waiter": 2,
              "PLU": 19,
              "Place": 0,
              "Table": 802,
              "Price": 0.00,
              "Articlename": "Orangenlimo 1/4",
              "Amount": 25,
              "Count": 1
          },
          {
              "ID": 18654,
              "Waiter": 2,
              "PLU": 19,
              "Place": 0,
              "Table": 802,
              "Price": 0.00,
              "Articlename": "Orangenlimo 1/4",
              "Amount": 25,
              "Count": 1
          }
        ]
      }
    

    Response:

    HTTP/1.1 200 OK