Easy Order - louis-xu-ustc/EasyOrder_Backend GitHub Wiki
- create new user / delete user (not used)
http POST <BaseURL>/user/ twitterID=<string> name=<string>
http DELETE <BaseURL>/user/ twitterID=<string>
- post new dish to menu
http POST <BaseURL>/dish/ name=<string> price=<int> photo=<base64 encoded picture>
- get all dish information / delete all dish (not used)
http GET <BaseURL>/dish/
[
{
"name":"pizza",
"price":20,
"rate":3.5,
"rateNum":3,
"photo":"/media/dishes/33a797d3-913.jpg",
"id":1
},
{
...
}
]
get rate of dish (provide dish ID) (Duplicated Function)
- get/delete certain dish
http GET <BaseURL>/dish/<dishid>
http DELETE <BaseURL>/dish/<dishid>
- post rate of dish (one user can only vote once towards a dish)
http PUT <BaseURL>/rate/<dishid> user=<twitterID> rate=<num>
http DELETE <BaseURL>/rate/<dishid> user=<twitterID>
- post order in one shot / specifying dish type and dish amount as a user
http POST <BaseURL>/order/ twitterID=<twitterID> amount=<num> dish=<dishid>
http POST <BaseURL>/order/bunch
request data:
{
"twitterID": "21345467",
"order": [
{
"dish": 2,
"amount": 1,
},
...
]
}
- get order amount of dish
http GET <BaseURL>/order/
[
{
"id": 1,
"name": "pizza",
"price": 2,
"rate": 3.5,
"photo": "media/dish/a4db.jpg",
"num": 3
},
{
...
}
}
Get effective orders for a user (within this meal interval)
http GET <BaseURL>/order/user/<twitterID>
[
{
"dish": "pizza",
"price": 10,
"amount": 2
},
{
...
}
]
Get history orders (recent 5 order)
http GET <BaseURL>/order/history/<twitterID>
[
{
"dish": "pizza",
"price": 10,
"amount": 2
},
{
...
}
]
- update retailer's location
http PUT <BaseURL>/current_location/ latitude=<num> longitude=<num>
- get retailer's location
http GET <BaseURL>/current_location/
{
"latitude":"10.23",
"longitude":"102.18"
}
- get all pickup location
http GET <BaseURL>/pickup_locations/
[
{
"latitude":"10",
"longitude":"102",
"name": "CMU"
},
{
...
}
]
- add a pickup location
http POST <BaseURL>/pickup_locations/ latitude=<num> longitude=<num>
- delete all pickup location
http DELETE <BaseURL>/pickup_locations/
- post arrival notification (triggered by geofencing / pressed by retailer)
http PUT <BaseURL>/notification/ content=<string>
-
get arrival notification (long poll)
First time GET the notification without timestamp, you would get a notification with its modified time (represented in timestamp). From second REST call (long polling), append timestamp in URI to check whether there is a new notification.
http GET <BaseURL>/notification/
http GET <BaseURL>/notification/<last-timestamp>/
// there is a new notification
{
"content": "hello",
"modified_at": "1499745017",
"notification": true
}
// no new notification
{
"notification": false
}
- get the client token that is used for braintree payment
http GET <BaseURL>/payment/client_token/
- place the order
http POST <BaseURL>/payment/checkout/ (iOS version, use HTTP POST input)
http POST <BaseURL>/payment/checkout/android/ (android version, use Json input)
// HTTP.body
payment_method_nonce=%<nonce-generated-locally>&user_id=%<twitter-access=token>
- get list of users (with whether user has paid) (long poll)
http GET <BaseURL>/user/
[
{
"twitterID": "1234567890",
"name": "Jiajie",
"paid": True,
}
{
...
}
]