Open dartandrevinsky opened 3 years ago
POST /address
Exchanges address and delivery time for a list of restaurants
Body:
{
address,
time
}
Response:
{
address,
time
restaurants: Array<{
id,
name,
cuisine,
street1,
street2,
locality,
region,
postcode,
country,
'delivery-fee',
avgDeliveryTime
}>
}
GET /restaurants/:restaurantId
Obtain detail info for a given restaurant including the menu
Response:
{
id,
name,
cuisine,
street1,
street2,
locality,
region,
postcode,
country,
'delivery-fee',
avgDeliveryTime,
menu: Array<{
id,
name,
price,
category_name
}>
}
GET /cart
Retrieves a blank cart object for the user.
Body:
none required
Response:
{
orderId,
total,
subTotal,
tax,
taxAmount,
delivery,
items: []
}
PUT /cart
Updates the cart items
Body:
{
restaurantId,
itemId,
quantity
}
Response:
{
orderId,
total,
subTotal,
tax,
taxAmount,
delivery,
items: Array<{
id,
count,
restaurantId
}>
}
POST /payment/intent
Creates a (like-Stripe) Payment Intent object based on the submitted cart items and responds with the clientSecret
value for this transaction.
Body:
{
items: Array<{
id,
count,
restaurantId
}>
}
Response:
{
{
clientSecret // paymentIntent.client_secret
}
}
POST /payment/confirm
Accepts a credit card data, validates it, responds with confirmed payment or declined (with a given reason).
Body:
{
clientSecret,
paymentMethod: {
card: {
card_number,
exp_year,
exp_month,
cvv,
zip
}
}
}
Response: OK: Status 200,
{
sucess: true
}
Failure: Status: 400
{
error: {
message
},
errors: {
card_field: String
}
}
The delivery address and time is part of the shopping cart. POST /address
-> POST /cart/address
cuisine_name
-> cuisine
and is an attribute of the restaurant, not the menu item
What is the structure of the restaurant's address
?
Regarding POST /cart
cartId
should not be part of the API. There is simply a cart that in the real application would be associated with the logged in user.GET /cart
to retrieve the current state of the cartmeta: { restaurantId }
makes no sense - the should just be a restaurantId
attributeRegarding PUT /cart/:cartId
qty
meta: { restaurantId }
makes no sense - the should just be a restaurantId attributeGET /cart
described aboveWhat is the structure of the restaurant's address?
It's a simple string. As per our correspondence.
cuisine_name
->cuisine
and is an attribute of the restaurant, not the menu item
I actually used this source to collect several sample items: https://codebeautify.org/jsonviewer/cb51497a I understand what needs to be changed, thank you!
What is the structure of the restaurant's address?
It's a simple string. As per our correspondence.
The address entered by the user is a string. The address of a restaurant must be structured data. e.g.:
Document API endpoints for ease of implementation