RESTful JSON API for Pizza Delivering Company
/api/users?phone=********789
phone* (Required)
token* (Required)
{ name,
email,
phone,
address,
cart, // may or may not be present
orders // may or may not be present
}
400: Required fields missing or they were invalid
403: Unauthorized access
404: User not Found
/api/users
email* (Required)
password* (Required)
name* (Required)
phone* (Required)
address* (Required)
none
{ }
400: User with that phone no already exists
400: Required fields missing or they were invalid
500: Couldn't create the new user, Couldn't hash the password
/api/users
phone*(Required)
(Atleast one of the below fields)
email
password
name
address
token* (Required)
{ }
404: User not found
400: Required fields missing or they were invalid
403: Unauthorized Access
500: Couldn't update users' data
/api/users?phone=********789
phone* (Required)
token* (Required)
{ }
400: Required fields missing or they were invalid
403: Unauthorized access
404: User not found
500: Could not delete the users' data
/tokens?id=string
id* (Required)
none
{
phone,
id,
expires
}
400: Invalid phone no
404: Token not Found
/api/tokens
phone* (Required)
password* (Required)
none
{
phone,
id,
expires
}
400: Required fields missing or they were invalid
400: Invalid password
500: Could not create the token for the user
404: User not found
/api/tokens?id=string
expires* (required)
none
{ }
400: Required fields missing or they were invalid
400: Token has already expired, and can't be extended
404: Token not found
500: Couldn't extend tokens' expiration
/api/tokens?id=string
id* (required)
none
{ }
400: Required fields missing or they were invalid
404: Token not found
500: Couldn't delete the specified token
GET
/menu
/api/menu?phone=********789
none
token
400: Required fields missing or they were invalid
403: Unauthorized access
405: Mehod not allowed
// No Authorization is needed
/items?id=string
id (optional) // if id is not present, will return the list of items in storage
none
{
// will either give the information about an item
id,
name,
price:{
small,
regular,
large
}
// or will represent all the itemId's in a list
}
404: Item not found for the given id
404: No items in the list
/api/items
{
name* (Required)
price* (Required) // price is an array for the amount of each size (small, regular, medium)...
Example -> price = [10,20,30]
}
none
{
id,
name,
price:{
small,
regular,
large
}
}
400: Required fields missing or they were invalid
400: Couldn't create the item
/api/items?id=string
id* (Required)
(Atleast one of the below fields)
name*
price*
none
{ }
400: Required fields missing or they were invalid
404: Item not found
500: Couldn't update the items' data
/items?id=string
id* (Required)
none
{ }
400: Invalid item Id
500: Could not delete the item
/api/cart?phone=********789
phone* (Required)
token* (Required)
{
Email,
Phone,
items // will contain an array of object(s) containing details of each item
}
400: Required fields missing or they were invalid
403: Unauthorized access
404: Cart is empty
404: User not found
Will add the cart id in the users' cart field
/api/cart?phone=********789
phone* (Required)
itemId* (Required)
size* (Required) // small, regular or large
crust (Optional) // new hand tossed(default), wheat thin crust or cheese burst
token* Required
{
email,
phone,
name,
cartId,
itemId,
size,
crust,
amount
}
400: Required fields missing or they were invalid
403: Unauthorized access
404: User not found
404: Item not found
500: Couldn't update the specified users' data for new cart item
500: Couldn't add the item to the specified users' cart
/api/cart?id=string // cartId
id* (Required)
(Atleast one of the below fields)
size // small, regular or large
crust // new hand tossed(default), wheat thin crust or cheese burst
token* Required
{ }
400: Required fields missing or they were invalid
403: Unauthorized access
500: Couldn't update users' data
500: Couln't update the cart data
Will delete the cartId from the users' cart field
/api/cart?id=string
id* (Required) // cartId
token* (Required)
{ }
400: Required fields missing or they were invalid
403: Unauthorized access
404: Cart not found
404: Cart not present with the specified user
500: Couldn't delete the cart for the given user
500: Could not find the user for the given cart
500: Couldn't update the users' data
/api/orders?phone=********789
phone* (Required)
token* (Required)
{
name,
phone,
email,
orderId,
items, // an array of objects containing detail of each item
totalAmount,
paymentProcessed
}
400: Required fields missing or they were invalid
403: Unauthorized access
404: Order not found
500: Insufficient Permissions
Will create the order with all the items on the cart
/api/orders?phone=********789
phone* (Required)
token* (Required)
{
Your Order : {
name,
phone,
email,
orderId,
items, // an array of objects containing detail of each item
totalAmount,
paymentProcessed
}
}
400: Required fields missing or they were invalid
403: Unauthorized Access
404: No items in the cart to place order
404: User not found
500: Transaction failure
500: Could not create the order for the user
500: Could not email the order receipt
500: Couldn't update the users' data for new order