Backend service for a coffee shop that manages the employees and allows them to take customer orders.
- Authentication and Authorization via a role-based control design pattern
- Ability to perform CRUD shop on orders, employees, customers, items, and bills.
POST /manager/employee
Request Body
:
{
"name": "Ahmad Ahmad",
"phone_number": 0596581120,
"role": "cashier",
"username": "ahmad99",
"password": "123"
}
Response
:
{
"message": "Created new Employee."
"Employee":
{
"name": "Ahmad Ahmad",
"phone_number": 0596581120,
"join_date":'2022-09-01',
"role": "cashier",
"username": "ahmad99",
"status": "Active"
}
}
POST /auth/login
Request Body
:
{
"username": "ahmad99",
"password": "123"
}
Response
:
{
"access_token": "secret"
}
GET /manager/employees
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
[
{
"phone_number": 555,
"id": 1,
"role": "cashier"
"name": "Ahmad Ahmad"
},
{
"phone_number": 444,
"id": 2,
"role": "manager"
"name": "David"
}
]
GET /manager/employees/${employee_id}
Parameter | Type | Description |
---|---|---|
employee_id |
integer |
Required. Id of employee to fetch |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"phone_number": 555,
"id": 1,
"role": "cashier"
"name": "Ahmad Ahmad",
"status": "Active"
}
PUT /manager/employees/${employee_id}
Parameter | Type | Description |
---|---|---|
employee_id |
integer |
Required. Id of employee to update |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"phone_number": 111,
"name": "Ahmad Ahmad",
"status": "Deactivated"
}
Response
:
{
"phone_number": 111,
"id": 1,
"name": "Ahmad Ahmad"
}
GET /shop/items
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
[
{
"id": 1,
"name": "Curry Chicken with Onion",
"price": "$7.00"
},
{
"id": 2,
"name": "Chicken with Black Beans",
"price": "$7.00"
}
]
POST /shop/items
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"name": "Curry Chicken with Onion",
"price": "$7.00"
}
Response
:
{
"id": 1,
"name": "Curry Chicken with Onion",
"price": "$7.00"
}
DELETE /shop/items/${item_id}
Parameter | Type | Description |
---|---|---|
item_id |
integer |
Required. Id of item to delete |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"id": 1,
"name": "Curry Chicken with Onion",
"price": "$7.00"
}
GET /shop/items/${item_id}
Parameter | Type | Description |
---|---|---|
item_id |
integer |
Required. Id of item to fetch |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"id": 1,
"name": "Curry Chicken with Onion",
"price": "$7.00"
}
PUT /shop/employees/${item_id}
Parameter | Type | Description |
---|---|---|
item_id |
integer |
Required. Id of item to update |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"name": "Curry Chicken with Onion",
"price": "$10.00"
}
Response
:
{
"id": 1,
"name": "Curry Chicken with Onion",
"price": "$10.00"
}
GET /shop/customers
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
[
{
"phone_number": 1,
"id": 1,
"name": "one"
},
{
"phone_number": 2,
"id": 2,
"name": "two"
}
]
POST /shop/customers
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"phone_number": 3,
"name": "Osama"
}
Response
:
{
"id": 3,
"phone_number": 3,
"name": "Osama"
}
DELETE /shop/customers/${customer_id}
Parameter | Type | Description |
---|---|---|
customer_id |
integer |
Required. Id of customer to delete |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"id": 3,
"phone_number": 3,
"name": "Osama"
}
GET /shop/customers/${employee_id}
Parameter | Type | Description |
---|---|---|
customer_id |
integer |
Required. Id of customer to fetch |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"id": 3,
"phone_number": 3,
"name": "Osama"
}
PUT /shop/customers/${customer_id}
Parameter | Type | Description |
---|---|---|
customer_id |
integer |
Required. Id of customer to update |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"phone_number": 4,
"name": "David"
}
Response
:
{
"id": 4,
"phone_number": 4,
"name": "David"
}
GET /shop/orders
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
[
{
"customer_id": 2,
"employee_id": 5,
"id": 7,
"items_ordered": [
{
"description": "no salt",
"item_id": 1,
"quantity": 1
}
],
"order_time": "2022-07-25T07:20:08.023003",
"status": "in Progress"
},
{
"customer_id": 1,
"employee_id": 2,
"id": 12,
"items_ordered": [
{
"description": "A LOT OF SALT",
"item_id": 5,
"quantity": 2
},
{
"description": "NO SUGAR",
"item_id": 4,
"quantity": 2
}
],
"order_time": "2022-07-25T07:20:08.023003",
"status": "in Progress"
]
POST /shop/orders
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"customer_id": 2,
"employee_id": 3,
"items_ordered": [
{
"description": "extra salt",
"item_id": 3,
"quantity": 2
}
],
"status": "in Progress"
}
Response
:
{
"customer_id": 2,
"employee_id": 1,
"id": 19,
"items_ordered": [
{
"description": "extra salt",
"item_id": 3,
"quantity": 2
}
],
"order_time": "2022-07-25T10:12:40.397597",
"status": "in Progress"
}
DELETE /shop/orders/${order_id}
Parameter | Type | Description |
---|---|---|
order_id |
integer |
Required. Id of order to delete |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"customer_id": 2,
"employee_id": 1,
"id": 19,
"items_ordered": [
{
"description": "extra salt",
"item_id": 3,
"quantity": 2
}
],
"order_time": "2022-07-25T10:12:40.397597",
"status": "Canceled"
}
GET /shop/orders/${order_id}
Parameter | Type | Description |
---|---|---|
order_id |
integer |
Required. Id of order to fetch |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"customer_id": 1,
"employee_id": 2,
"id": 12,
"items_ordered": [
{
"description": "A LOT OF SALT",
"item_id": 5,
"quantity": 2
},
{
"description": "NO SUGAR",
"item_id": 4,
"quantity": 2
}
],
"order_time": "2022-07-25T07:44:11.668169",
"status": "in Progress"
}
PUT /shop/orders/${order_id}
Parameter | Type | Description |
---|---|---|
order_id |
integer |
Required. Id of order to update |
Token |
Bearer Token |
Required. JWT of an authorized employee |
Request Body
:
{
"customer_id": 1,
"employee_id": 2,
"items_ordered": [
{
"description": "chicken tika masala",
"item_id": 1,
"quantity": 2
}
],
"status": "Done"
}
Response
:
{
"customer_id": 1,
"employee_id": 2,
"id": 12,
"items_ordered": [
{
"description": "chicken tika masala",
"item_id": 1,
"quantity": 2
}
],
"order_time": "2022-07-25T07:44:11.668169",
"status": "Done"
}
GET /shop/bill
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
[
{
"customer_id": 1,
"employee_id": 1,
"order_id": 1,
"price": "12"
},
{
"customer_id": 1,
"employee_id": 2,
"order_id": 2,
"price": "13"
},
]
GET /operation/bill/${order_id}
Parameter | Type | Description |
---|---|---|
Token |
Bearer Token |
Required. JWT of an authorized employee |
Response
:
{
"customer_id": 1,
"employee_id": 1,
"order_id": 1,
"price": "12"
}
POST /shop/bill/${order_id}
Parameter | Type | Description |
---|---|---|
order_id |
integer |
Required. Id of order to find the receipt of |
Token |
Bearer Token |
Required. JWT of an authorized employee |
{
"customer_id": 1,
"employee_id": 1,
"order_id": 1,
"price": "$67.50"
}