- Create an
postgresqldatabase nameprojectand import data fromfds.sql - Run file
main.pyto start server
psycopg2to run sql commandflaskandflask-corsto run backend server
- Note: Replace param in <> with the specific value
/login- body:
{ "username": <username>, "password": <password> }- return code: 200 for OK and 400 for fail
/register- body:
{ "username": <username>, "password": <password>, "phone": <8-digit integer>, "userType": "customer"/"rider"/"staff"/"manager" }- return code: 200 for OK and 400 for fail
/<username>/update- body: Pass at least 1 of 2 fields in the body below
{ "password": <password>, "phone": <8-digit integer> }- return code: 200 for OK and 400 for fail
/<username>/update/customer- body: Pass at least 1 of 2 fields in the body below
{ "creditCardNumber": <credit card number>, "cvv": <cvv> }- return code: 200 for OK and 400 for fail
-
/<username>/profile- return user data which is stored as a dictionary which includes of
username,phone,userType,rewardPointsThis is what should be returned to user:
'data' { 'username': <username> 'phone': <phone number contains exactly 8 digits> 'userType': <customer, rider, staff, manager> 'rewardPoints': <a positive integer> } - return user data which is stored as a dictionary which includes of
/customer/<username>/order{ "rName": <list of selected restaurants>, "rCategory": <list of restaurant categories>, "location": <list of location>, "fName": <list of food item names>, "fCategory": <list of food categories>, }- return: information of restaurants, food, and menu
{ "data": { list of json object with keys "rid", "fid", "rName", "rCategory", "location", "minSpent", "availability", "noOfOrders", "price", "fName", "fCategory" } }
/customer/<username>/order/checkout/<rid>/<fid>- body:
{ "creditCardNumber": <credit card number>, "cvv": <cvv> }- return:
- code 400 if credit card or cvv does not match
- else: price information of the order
{ "total price", "fool price", "deliver cost" }
/customer/<username>/past-order/past-order/date?startdate=<startdate>&enddate=<enddate>startdateandenddateare optional paramter with formatyyyy-mm-dd- return: all orders of user between
startdateandenddate
{ "data": { list of json object with keys "order time", "restaurant", "foodItem", "price", "review" } }
-
/customer/<username>/search-food/<item>- return:
{ "data": list of food item with substring <item> } -
/customer/<username>/search-restaurant/<restaurant>- return:
{ "data": list of restaurants with name containing substring <restaurant> { "rName", "location" } }
/staff/<username>/summary/promotion/<startdate>/<enddate>/staff/<username>/summary/promotion/<startdate>enddateis an optional parameter- return:
- code 400 if promotion is found
- else
Format of flat promotion{ "data": list of flat promotion and percentage promotion between startdate and endate }Format of percentage promotion{ 'type': 'flat promotion', 'pid', 'startDate', 'endDate', 'flatAmount', 'minAmount', 'rid', 'no. of orders', 'orders per day', 'total price' }{ 'type': 'percentage promotion', 'pid', 'startDate', 'endDate', 'percentage', 'maxAmount', 'rid', 'no. of orders', 'orders per day', 'total price' }
/staff/<username>/summary/order/<month>/<year>- return:
{ 'total orders', 'total cost', 'rName': restaurant managed by staff, 'location': location of restaurant, 'favorite food': list of top 5 most-ordered food in month }
/manager/<username>/month-summary/<month>/<year>- return:
{ 'new user': number of new user, 'no. of orders': number of orders in month, 'total price': total transaction in month, 'user': [ { 'cid': customer id, 'no. of orders': number of orders by the customer, 'total price': money purchased by customer } ] }
/manager/<username>/order/<area>/<day>/<starttime>/<endtime>- return: orders in area in a specific day within a period of time
'no. of order': number of orders, 'order': list of all orders
/manager/<username>/rider/<month>/<year>- return:
{ "data": "part time": list of part time riders in month { "type": "part time", "uid", "no. rating", "average rating", "no. order", "salary", "total time", "average deliver time" }, "full time": list of full time riders in month { "type": "full time", "uid", "no. rating", "average rating", "no. order", "salary", "total time", "average deliver time" }, }
-
manager/<username>/create/promotion- Data should be parsed:
new_promotion { `restaurant`: <name of restaurant> `foodItem`: <name of the food> `endDate`: <end date of the promotion> `startDate`: <start date of the promotion> `promotion_type`: <flat or percentage> `percent`: <percent of discount for percentage promotion's type> `maxAmount` `flatAmount`: <amount dicount for flat promotion's type> `minAmount` }Return 200 if OK, 400 if there is error
-
manager/<username>/delete/promotion/<pid>Pass the
pidof the promotion needs to be deletedReturn 200 if OK, 400 if there is an error
/rider/<username>/summary/<month>/<year>- return:
{ "type": "part time" / "full time", "uid", "no. rating", "average rating", "no. order", "salary", "total time", "average deliver time" },