manuals:api
Differences
This shows you the differences between two versions of the page.
manuals:api [2018/03/02 10:12] – created - external edit 127.0.0.1 | manuals:api [2024/11/18 18:54] (current) – dmarti | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | ====== Introduction ====== |
- | < | + | This document may describe the ways in which particular tasks are performed to place an order to the PizzaGest platform, using various technologies as JavaScript (xmlhttprequest) or JQuery (AJAX), HTML5 or server side platforms like PHP making the request in POST HTTP, and using UTF-8 charset. |
- | < | + | Full documentation of each service is contained within |
- | < | + | These web services use HTTP requests to specific URLs, passing parameters as request arguments to the services. |
- | < | + | ====== Get Started ====== |
- | < | + | A typical Web Service request is generally of the following form on POST method, replacing {Function Name} by the name of the function and parsing JSON string as parameters. The following URL must be used for all the requests: |
- | <p>A typical Web Service request is generally of the following form on POST method, replacing {Function Name} by the name of the function and parsing JSON string as parameters. The following URL must be used for all the requests:</ | + | <code> |
- | + | ||
- | <pre> | + | |
http:// | http:// | ||
POST[data]-> | POST[data]-> | ||
POST[hash]-> | POST[hash]-> | ||
- | </pre> | + | </code> |
- | <p>Get request:</p> | + | Get request: |
- | <pre> | + | <code> |
http:// | http:// | ||
- | </pre> | + | </code> |
- | <p>The REST architectural style was developed by W3C Technical Architecture Group (TAG) in parallel with HTTP 1.1, based on the existing design of HTTP 1.0. The World Wide Web represents the largest implementation of a system conforming to the REST architectural style.</p> | + | The REST architectural style was developed by W3C Technical Architecture Group (TAG) in parallel with HTTP 1.1, based on the existing design of HTTP 1.0. The World Wide Web represents the largest implementation of a system conforming to the REST architectural style. |
+ | To access to the PizzaGest API we will provide you a “Client code” and “Hash” to sign all the REQUESTS. Your client code and timestamp must be specified in all the placed requests, and also all requests should be signed with the hash. | ||
- | <p>To access to the PizzaGest API we will provide you a “Client code” and “Hash” to sign all the REQUESTS. Your client code and timestamp must be specified | + | Keep your client code and hash in a safe place and don’t publish it in your source code, because this may turn vulnerable |
- | < | + | **[POST][data] :** Contains all the information necessary for the request parsed in a JSON string. ClientCode, Timestamp, Function Params. |
- | + | ||
- | < | + | |
- | ClientCode, Timestamp, Function Params.</p> | + | |
- | < | + | **[POST][hash] :** Contains the sign in SHA256 generated for each request as a Json string merged with Json string length, and signed with the hash. The line below is a PHP example to generate the hash. |
- | <pre> | + | <code> |
+ | hash_hmac (' | ||
+ | </code> | ||
- | < | + | **SANDBOX_DATA: |
- | <pre>Client code: ‘HungerStation’ | + | <code> |
+ | Client code: ‘HungerStation’ | ||
Hash: 285c148c9374923c3024d6ec76b7f85d6519293949f7340afe1470079de9adzz | Hash: 285c148c9374923c3024d6ec76b7f85d6519293949f7340afe1470079de9adzz | ||
- | </pre> | + | </code> |
+ | **JSON EXAMPLE POST DATA:** | ||
- | <b>JSON EXAMPLE POST DATA:</ | + | <code> |
- | + | ||
- | <pre> | + | |
http:// | http:// | ||
Line 55: | Line 53: | ||
[hash]=" | [hash]=" | ||
- | </pre> | + | </code> |
- | <h1>Get Example</h1> | + | ====== |
- | <pre> | + | <code> |
http:// | http:// | ||
- | </pre> | + | </code> |
- | + | ||
- | < | + | |
- | Both parameters must be converted to string.</ | + | |
- | < | + | IMPORTANT NOTE: All requests may have “Client Code” and “Timestamp” included in the JSON String. Both parameters must be converted to string. |
- | [data]={" | + | |
- | <p>PHP sample | + | <code> |
+ | [data]={" | ||
+ | </code> | ||
- | < | + | PHP sample code: |
- | $client= " | + | < |
- | $pass = " | + | $client, |
- | $date = new DateTime(); | + | |
- | + | ||
- | $data = array( | + | |
- | " | + | |
" | " | ||
); | ); | ||
Line 110: | Line 102: | ||
?> | ?> | ||
- | </pre> | + | </code> |
- | <h1>Managing Responses</h1> | + | ====== |
- | <p>Once the request is completed, the API will return a POST data as JSON string parsed with all the data you requested, then the data only needs to be parsed to an object or array to be comfortably managed.</p> | + | Once the request is completed, the API will return a POST data as JSON string parsed with all the data you requested, then the data only needs to be parsed to an object or array to be comfortably managed. |
- | <p>The API returns a JSON String [response], if the request is correctly filled with all the information, | + | The API returns a JSON String [response], if the request is correctly filled with all the information, |
- | < | + | **SAMPLE RESPONSE** |
- | <pre> | + | <code> |
- | </pre> | + | {" |
+ | </code> | ||
- | < | + | **SAMPLE ERROR** |
- | <pre> | + | <code> |
+ | {" | ||
+ | </code> | ||
- | <h1>About pizzagest software</h1> | + | ====== |
- | <p>Our software is a complete tool for managing food related business with lots of possible options depending on the customer, and may be necessary to acquire some knowledge about how our software works to understand correctly how to deal with the requests to our servers.</ | + | Our software is a complete tool for managing food related business with lots of possible options depending on the customer, and may be necessary to acquire some knowledge about how our software works to understand correctly how to deal with the requests to our servers. |
- | + | ||
- | <h1>Available Functions</h1> | + | ====== |
+ | IMPORTANT NOTE:In the list below we describe the parameters that must be included in [data] field parsed JSON to its corresponding function. | ||
- | < | + | ===== getBranchesInfo: ===== |
+ | This function retrieves the information for all available branches. If data[BranchCode] is specified, retrieves only the information for the requested branch. | ||
- | < | + | **REQUIRED PARAMS:** |
- | <p>This function retrieves the information for all available branches. If data[BranchCode] is specified, retrieves only the information for the requested branch. </ | + | <code> |
- | + | ||
- | < | + | |
- | <pre> | + | |
[data][ClientCode] | [data][ClientCode] | ||
[data][Timestamp] | [data][Timestamp] | ||
- | </pre> | + | </code> |
+ | |||
+ | **OPTIONAL PARAMS:** | ||
+ | |||
+ | < | ||
+ | [data][BranchCode] | ||
+ | </code> | ||
- | < | + | The object returned by the function is as follows: |
- | < | + | |
- | + | ||
- | <p>The object returned by the function is as follows:</p> | + | |
- | <pre>[Array] | + | <code> |
+ | [Array] | ||
[AreaCode]: indicating branch area code. | [AreaCode]: indicating branch area code. | ||
[AreaName]: indicating branch area name. | [AreaName]: indicating branch area name. | ||
Line 193: | Line 190: | ||
PickUp: Array object list with all available payment methods for pickup orders. | PickUp: Array object list with all available payment methods for pickup orders. | ||
[PrayTimes]: | [PrayTimes]: | ||
- | </pre> | + | </code> |
+ | ===== getMenuInfo: | ||
- | < | + | Retrieves the full menu product list grouped by its family and including topping customization options and prices. |
- | < | + | **REQUIRED PARAMS:** |
- | <p>< | + | <code> |
- | <pre>[data][ClientCode] | + | [data][ClientCode] |
[data][Timestamp] | [data][Timestamp] | ||
[data][BranchCode] => Branch code (num). | [data][BranchCode] => Branch code (num). | ||
- | </pre> | + | </code> |
- | < | + | **EXTRA PARAMS:** |
- | < | + | |
- | <p>Note that is required | + | <code> |
+ | [data][Language]=> | ||
+ | </code> | ||
- | <p>The object returned by the function is as follows:</p> | + | Note that is required to provide the branch ID for getting the product list as the prices may be different from one branch to another. As the branch with ID “1” is a test branch do not use it in production. |
- | <pre>[Array] | + | |
+ | The object returned by the function is as follows: | ||
+ | |||
+ | <code> | ||
+ | [Array] | ||
[Products]: Array object which specifies the available products (sale items) for the family group. Each element of the array has the following attributes: | [Products]: Array object which specifies the available products (sale items) for the family group. Each element of the array has the following attributes: | ||
[Doughs]: Object containing the default dough for the item. | [Doughs]: Object containing the default dough for the item. | ||
Line 297: | Line 300: | ||
For example: Medium Pizza , prefix [PM]. BBQ medium code PMBB | For example: Medium Pizza , prefix [PM]. BBQ medium code PMBB | ||
Large Pizza, prefix [PL]. BBQ Large code PLBB | Large Pizza, prefix [PL]. BBQ Large code PLBB | ||
- | </pre> | + | </code> |
- | <h2>addNewTicket: | + | ===== addNewTicket: |
- | <p>Saves the order into the middleware database. The order will be automatically imported by its corresponding branch.</p> | + | Saves the order into the middleware database. The order will be automatically imported by its corresponding branch. |
- | < | + | **REQUIRED PARAMS:** |
- | <pre> | + | <code> |
[ClientCode] | [ClientCode] | ||
[Timestamp] | [Timestamp] | ||
Line 321: | Line 324: | ||
[Latitude] | [Latitude] | ||
[Longitude] | [Longitude] | ||
- | </pre> | + | </code> |
- | < | + | |
- | <pre> | + | **RETURNED PARAMS:** |
+ | |||
+ | <code> | ||
[BranchAlive]-> | [BranchAlive]-> | ||
connected to the middleware database. This time can be used for avoiding ordering to a branch with | connected to the middleware database. This time can be used for avoiding ordering to a branch with | ||
Line 351: | Line 356: | ||
[Topping]: | [Topping]: | ||
[ToppingName]: | [ToppingName]: | ||
+ | </ | ||
- | </ | + | ====== |
- | + | ||
- | <h1>Errors</h1> | + | |
- | <p>There are two error types:</ | + | There are two error types: |
- | < | + | |
- | </p> | + | |
- | < | + | **Server: |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | < | + | |Error Number|Error Description |
- | < | + | |100 |
- | < | + | |101 |
- | < | + | |200 |
- | < | + | |201 |
- | < | + | |202 |
- | < | + | |203 |
- | < | + | |204 |No Content |
- | < | + | |205 |
- | < | + | |206 |
- | < | + | |300 |
- | < | + | |301 |
- | < | + | |302 |
- | < | + | |303 |See Other | |
- | < | + | |304 |Not Modified |
- | < | + | |305 |Use Proxy | |
- | < | + | |306 |
- | < | + | |307 |
- | < | + | |400 |Bad Request |
- | </ | + | |401 |
+ | |402 | ||
+ | |403 | ||
+ | |404 |Not Found | | ||
+ | |405 | ||
+ | |406 |Not Acceptable | ||
+ | |407 | ||
+ | |408 | ||
+ | |409 | ||
+ | |410 | ||
+ | |411 | ||
+ | |412 | ||
+ | |413 | ||
+ | |414 | ||
+ | |415 | ||
+ | |416 | ||
+ | |417 | ||
+ | |500 | ||
+ | |501 |Not Implemented | ||
+ | |502 |Bad Gateway | ||
+ | |503 | ||
+ | |504 | ||
+ | |505 |HTTP Version Not Supported | ||
+ | **Request: | ||
- | </ | + | |Error Number|Error Description |
+ | |1000 |Unknown client code | | ||
+ | |1001 |Bad request (token) | ||
+ | |1002 |No results found | | ||
+ | |1003 |The user is already registered | ||
+ | |1004 |Required parameter missing ( Param Name)| | ||
+ | |1005 |Required parameter empty (Param Name) | | ||
+ | |1007 |Required parameter type incorrect | ||
+ | |1008 |Internal Web Server Error | | ||
+ | |1009 |User registered not validated | ||
+ | |1010 |Wrong password | ||
+ | |1011 |Wrong validate code | | ||
+ | |1012 |User validated | ||
+ | |1013 |Order empty | | ||
+ | |1014 |User Not Registered | ||
+ | |1016 |Email missing | ||
+ | |1017 |Branch code missing | ||
+ | |1018 |Order save fail | |
manuals/api.1519981931.txt.gz · Last modified: 2018/03/02 10:12 by 127.0.0.1