User - YoussefMRefaat/timezone GitHub Wiki

Only users can access these points

Add a watch to the cart

  • URL

/api/cart

  • Method

POST

  • URL Params

None

  • Data Params

Required:

watchID=[integer] quantity=[integer,max:9,min:1]

  • Success response

Code: 201 Content: {"Message":"Watch has been added successfully"}

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" } OR Code: 409 Content: { "Message" => "Watch is already in the cart" } OR Code: 422 Content: { "Message" => "The given data was invalid", "errors": { :field : [:messages ], :field : [:messages ] ...} }



Show cart details

  • URL

/api/cart

  • Method

GET

  • URL Params

None

  • Data Params

None

  • Success response

Code: 200 Content: {"Message":"Watches have been retrieved successfully", "Data":{"Watches":[{"id": :id,"name": :name, "image": :image,"quantity": :quantity ,"price": :price},{"id": :id,"name": :name,"image": :image,"quantity": :quantity,"price": :price} ...], "Total": :total_price} }

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" }



Update the quantity of a watch in the cart

  • URL

/api/cart/:id

  • Method

PATCH

  • URL Params

Required:

id=[integer]

  • Data Params

Required:

quantity=[integer,max:9,min:1]

  • Success response

Code: 200 Content: {"Message":"Cart has been updated successfully"}

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" } OR Code: 409 Content: { "Message" => "Watch is not in the cart" } OR Code: 422 Content: { "Message" => "The given data was invalid", "errors": { "quantity" : [:messages ]} }



Delete a watch from the cart

  • URL

/api/cart/:id

  • Method

DELETE

  • URL Params

Required:

id=[integer]

  • Data Params

None

  • Success response

Code: 200 Content: {"Message":"Cart has been updated successfully"}

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" } OR Code: 409 Content: { "Message" => "Watch is not in the cart" }



Make an order

  • URL

/api/orders

  • Method

POST

  • URL Params

None

  • Data Params

None

  • Success response

Code: 201 Content: {"Message":"Order has been made successfully"}

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" } OR Code: 409 Content: { "Message" => "Cart is empty" }



Show user's orders

  • URL

/api/orders

  • Method

GET

  • URL Params

None

  • Data Params

None

  • Success response

Code: 200 Content: {"Message":"Orders have been retrieved successfully", "Data":[ {"id": :id,"ordered_at": :date,"total_price": :price,"status": :status,"shipped_at": :date,"delivered_at" :date,"Watches":[{"id": :id,"name": :name, "image": :image,"quantity": :quantity ,"price": :price},{"id": :id,"name": :name,"image": :image,"quantity": :quantity,"price": :price} ...] },{"id": :id,"ordered_at": :date,"total_price": :price,"status": :status,"shipped_at": :date,"delivered_at" :date,"Watches":[{"id": :id,"name": :name, "image": :image,"quantity": :quantity ,"price": :price},{"id": :id,"name": :name,"image": :image,"quantity": :quantity,"price": :price} ...] } ...] }

  • Error response

Code: 401 Content: { "Message" => "Unauthenticated" } OR Code: 403 Content: { "Message" => "Unauthorized" } OR Code: 403 Content: { "Message" => "Email is not verified" }