nperez0111 / Pizza

Pizza Web App Point of Sale and API
1 stars 0 forks source link

Juan & Nalin Manual #29

Open nperez0111 opened 8 years ago

nperez0111 commented 8 years ago

The Juan & Nalin Manual

Written in C++ Please

string baseUrl = "http://api.nickthesick.com/";
string tableName = "order";
  1. Figure out how cURL works
  2. Figure out parsing JSON response in C++

    JSON Response

{
    "status":"OK",
    "message":{
        "ID":"Some Integer",
        "Order":"Some String",
        "Date":"Some String",
        "Price":"Some Decimal"
        }

}

JSON Error Response

{
    "status":"ERROR",
    "message":"Mal-Formed request, check url params",
    "Solution":"Check http request type, Check Credentials, Check URL parameters"
}

What needs to happen

  1. While true loop, constantly asking database every x seconds
  2. Print receipt based on response (formatted)
  3. Save that the response has already been logged to a file or something
  4. on close of program delete the file
  5. In order to request successfully you must send data in a data header that is formatted as JSON

    JSON Request Format

{
   "login":{
     "user":"username",
     "password":"pass"
   }
}
NSuri1 commented 8 years ago

I found a JSON parser on github: https://github.com/miloyip/rapidjson

nperez0111 commented 8 years ago

This is kind of sort of how the receipt will be formatted.

I also figured out that I can call c++ programs within php so if you guys are having trouble getting networking in the program this would help a lot. Basicallly what can go down is that the program is called with an argument to it that will be the JSON so all that you guys would have to do is print the receipt. If you can figure out the networking thing fine, if not I'll set you guys up with this.

NSuri1 commented 8 years ago
  1. cURL to get the server message.
  2. RapidJSON to parse message into C++ with the structures.
  3. Read whole table, if new data, print.

creates array of objects

function prototype brainstorming:

string getMessage(); structure returning function parseMessage(); bool ifNew(); void print();

nperez0111 commented 8 years ago

http://api.nickthesick.com/orders?login%5BEmail%5D=nick%40nickthesick.com&login%5Bpassword%5D=0046788285 This is a proper response from the database