Created
July 23, 2018 23:38
-
-
Save sungkim23/88aeb8a5b9e1feb9d11511fae828e803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Every API should have the following format, more info at https://labs.omniti.com/labs/jsend */ | |
/* Every POST should receive FORM DATA, not httpBody, or anything or sorts*/ | |
{ | |
"status" : "success", | |
"data": { | |
/* data goes here */ | |
}, | |
"message": null /* if status is false, error message goes here */ | |
} | |
/* /GET Services for /restaurant.json, /postres.json, /organica.json, /flores.json */ | |
{ | |
"status" : "success", | |
" data": { | |
[ | |
{ | |
"id": "1", | |
"restaurantName": "Juicy Lucy", | |
"affiliated": "0", | |
"restaurantPriority": "1" | |
}, | |
{ | |
"id": "2", | |
"restaurantName": "King Kroughnuts", | |
"affiliated": "0", | |
"restaurantPriority": "15" | |
} | |
] | |
}, | |
"message": "" | |
} | |
/* /GET to "json(id).json" , should return following, would be best if it was an array of [categoria] and each item returned the items that correspond, but that could be for a | |
future update, doing it now would force apps to do a huge change: */ | |
{ | |
"status" : "success", | |
"data": { | |
[ | |
{ | |
"categoria" : "Desayunos" | |
"items" : | |
[ | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Desayunos", | |
"platos": "American Breakfast" | |
}, | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Desayunos", | |
"platos": "Continental Breakfast" | |
} | |
] | |
}, | |
{ | |
"categoria" : "Desayunos" | |
"items" : | |
[ | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Sandwiches", | |
"platos": "Club Sandwich 2" | |
}, | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Sandwiches", | |
"platos": "Club Sandwich" | |
} | |
] | |
} | |
] | |
}, | |
"message": "" | |
} | |
/* /GET to "json(id).json */ | |
{ | |
"status" : "success", | |
"data": { | |
[ | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Desayunos", | |
"categoriaDescription": "El jugo puede ser de papaya, piña, naranja o surtido. El café puede ser descafeinado añadiendo S/. 2.00", | |
"platos": "Desyuno alemán", | |
"platosDescription": "Jamón de pierna, queso brie, quedo edam, huevo pasado, canasta de panes, mermelada, mantequilla, jugo y café o infusión", | |
"precioIndividual": 30 | |
}, | |
{ | |
"restaurant": "La Mora", | |
"categoria": "Desayunos", | |
"categoriaDescription": "", | |
"platos": "Desyuno español", | |
"platosDescription": "Pan, taomte, omelette, jamón serrano, jugo y café o infusión", | |
"precioIndividual": 27 | |
} | |
] | |
}, | |
"message" : "" | |
} | |
/* /POST to "api/api.php/orders" should probably be a /GET, should return following: */ | |
{ | |
"status": "success", | |
"data": { | |
"lastOrderID": "1230" | |
}, | |
"message" : "" | |
} | |
/* /POST to "order/", haven’t tested new API you provided but should receive a JSON array example: */ | |
//Test order | |
var orderDict = { | |
"orderID" = "1234", | |
"items" = [ | |
{"restaurantName": "Juicy Lucy", "platos": "Smash Burger" "price": "S/. 20.00"}, | |
{"restaurantName": "Juicy Lucy", "platos": "Regular Burger" "price": "S/. 18.00"}, | |
{"restaurantName": "Juicy Lucy", "platos": "Spicy Mexico Burger", "price": "S/. 16.00"} | |
] | |
} | |
// What we would send. | |
{ | |
"orders": orderDict | |
} | |
/* /POST to "api/api.php/users/" ... name could probably be changed to something like /users/register or signup */ | |
//What we send | |
{ | |
"name" : name, | |
"tel" : cellphone, | |
"email": email | |
} | |
//What we should receive | |
{ | |
"status":"", | |
"data" : { | |
"userid" : "1234", | |
"tel": "123123123", | |
"email": "[email protected]" | |
}, | |
"message": "" | |
} | |
//In case register fails | |
{ | |
"status": "failure", | |
"data": { | |
}, | |
"message" : "No se pudo crear usuario por X problema" | |
} | |
/* /GET to api/api.php/users/?filter=tel,eq,51\(cellphone!) ... name could probably be changed to something like /users/login and also should be a /POST request or security reasons */ | |
//What we send | |
{ | |
"tel" : cellphone | |
} | |
//What we should receive | |
{ | |
"status":"", | |
"data" : { | |
"userid" : "1234", | |
"tel": "123123123", | |
"email": "[email protected]" | |
}, | |
"message": "" | |
} | |
//In case register fails | |
{ | |
"status": "failure", | |
"data": { | |
}, | |
"message" : "Usuario no pudo iniciar sesion por X problema" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment