Admin - YoussefMRefaat/timezone GitHub Wiki
Moderators and admins can access these points
Create a watch
-
URL
/api/admin/watches
-
Method
POST
-
URL Params
None
-
Data Params
Required:
name=[string,max:20]
description=[string,max:255]
image=[image]
price=[unsigned decimal,max:99999.99]
quantity=[unsigned integer]
-
Success response
Code: 201
Content: { "Message" => "Watch has been created successfully", }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 422
Content: { "Message" => "The given data was invalid", "errors": { :field : [:messages ], :field : [:messages ] ...} }
Show all watches
-
URL
/api/admin/watches
-
Method
GET
-
URL Params
None
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Watches have been retrieved successfully","Data":[{"id": :id,"name": :name,"description": :description,"image": :image,"price": :price} , {"id": :id,"name": :name,"description": :description,"image": :image,"price": :price} ...]}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
Show a watch
-
URL
/api/admin/watches/:id
-
Method
GET
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Watch has been retrieved successfully", "Data":{ "id": :id,"name": :name,"description": :description,"image": :image,"price": :price, "quantity": :quantity, "created_at": :date, "updated_at": :date }}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Watch not found" }
Update a watch
-
URL
/api/admin/watches/:id
-
Method
PATCH
-
URL Params
Required:
id=[integer]
-
Data Params
Required:
name=[string,max:20]
description=[string,max:255]
price=[unsigned decimal,max:99999.99]
quantity=[unsigned integer]
-
Success response
Code: 201
Content: { "Message" => "Watch has been updated successfully", }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Watch not found" }
ORCode: 422
Content: { "Message" => "The given data was invalid", "errors": { :field : [:messages ], :field : [:messages ] ...} }
Update the image of a watch
-
URL
/api/admin/watches/:id/image
-
Method
PATCH
-
URL Params
Required:
id=[integer]
-
Data Params
Required:
image=[image]
-
Success response
Code: 201
Content: { "Message" => "Watch has been updated successfully", }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Watch not found" }
ORCode: 422
Content: { "Message" => "The given data was invalid", "errors": { "image": [:messages] }}
Delete a watch
-
URL
/api/admin/watches/:id
-
Method
DELETE
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Watch has been deleted successfully"}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Watch not found" }
Show all users
-
URL
/api/admin/users
-
Method
GET
-
URL Params
None
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Users have been retrieved successfully","Data":[{"id": :id,"first_name": :name,"last_name": :name,"email": :email,"gender": :gender } , {"id": :id,"first_name": :name,"last_name": :name,"email": :email,"gender": :gender} ...]}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
Show users based on their gender
-
URL
/api/admin/users/:gender
-
Method
GET
-
URL Params
Required:
gender=[string , ['male' , 'female'] ]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Users have been retrieved successfully","Data":[{"id": :id,"first_name": :name,"last_name": :name,"email": :email} , {"id": :id,"first_name": :name,"last_name": :name,"email": :email} ...]}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
typo in gender
Show a user
-
URL
/api/admin/users/:id
-
Method
GET
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"User has been retrieved successfully", "Data":{ "id": :id,"first_name": :name,"last_name": :name,"email": :email,"email_verified_at": :date,"gender": :gender,"primary_phone": :phone, "sec_phone": :phone,"primary_address": :address,"sec_address": :address, "created_at": :date, "updated_at": :date } }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "User not found" }
Show user's orders
-
URL
/api/admin/users/:id/orders
-
Method
GET
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message": "Orders have been retrieved successfully","Data":[{"id": :id,"status": :status,"total": :price,"created_at": :date,},{"id": :id,"status": :status,"total": :price,"created_at": :date,} ...] }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "User not found" }
Show all orders
-
URL
/api/admin/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,"user_id": :id,"user_name": :name},{"id": :id,"ordered_at": :date,"total_price": :price,"status": :status,"shipped_at": :date,"delivered_at": :date,"user_id": :id,"user_name": :name} ...] }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
Show orders based on status
-
URL
/api/admin/orders/:status
-
Method
GET
-
URL Params
Required:
status=[string]
-
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,"user_id": :id,"user_name": :name},{"id": :id,"ordered_at": :date,"total_price": :price,"status": :status,"shipped_at": :date,"delivered_at": :date,"user_id": :id,"user_name": :name} ...] }
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
Show an order
-
URL
/api/admin/orders/:id
-
Method
GET
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Order has been retrieved successfully","Data":{"id": :id,"total_price": :price,"status": :status,"shipped_at": :date,"delivered_at": :date,"ordered_at": :date,"user_id": :id,"user_name": :name,"watches":[{"id": :id,"name": :name,"quantity": :quantity,"price": :price},{"id": :id,"name": :name,"quantity": :quantity,"price": :price} ...] }}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Order not found" }
Ship a pending order
-
URL
/api/admin/orders/:id
-
Method
PATCH
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Order has been shipped successfully"}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Order not found" }
ORCode: 409
Content: { "Message" => "Order has already been shipped or cancelled" }
Deliver a shipped order
-
URL
/api/admin/orders/:id
-
Method
PATCH
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Order has been delivered successfully"}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Order not found" }
ORCode: 409
Content: { "Message" => "Order cannot be delivered" }
Cancel an order
-
URL
/api/admin/orders/:id
-
Method
PATCH
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success response
Code: 200
Content: {"Message":"Order has been cancelled successfully"}
-
Error response
Code: 401
Content: { "Message" => "Unauthenticated" }
ORCode: 403
Content: { "Message" => "Unauthorized" }
ORCode: 403
Content: { "Message" => "Email is not verified" }
ORCode: 404
Content: { "Message" => "Order not found" }
ORCode: 409
Content: { "Message" => "Order has already been delivered or cancelled" }