Skip to content

Ox03bb/DigitalMarket_API

Repository files navigation

DRF

Python Version Django Version DRF Version SQLite3 Version

API Endpointes


Endpoint

Role

Method

Purpose

/api/users

No role required

POST

Creates a new user with name, email , password,...etc

/api/users

 

manager

GET

List all users with ther info

/api/users/{id}

 

manager

GET

Show the users number {id} info

/api/users/me/

 

Anyone with a valid user token

GET

Displays only the current user

 

 

 

 

/api/login

Anyone with a valid username and password

POST

Generates access tokens that can be used in other API calls in this project

/api/logout

Anyone has already logged in

POST

Deleting the token from the database for security reasons

Menu-items endpoints

Endpoint

Role

Method

Purpose

/api/menu-items

Customer, delivery crew

GET

Lists all menu items. Return a 200 – Ok HTTP status code

/api/menu-items

Customer, delivery crew

 

POST, PUT, PATCH, DELETE

Denies access and returns 403 – Unauthorized HTTP status code

/api/menu-items/{menuItem}

Customer, delivery crew

 

GET

Lists single menu item

/api/menu-items/{menuItem}

Customer, delivery crew

POST, PUT, PATCH, DELETE

Returns 403 - Unauthorized

 

 

 

 

/api/menu-items

Manager

GET

Lists all menu items

/api/menu-items

Manager

POST

Creates a new menu item and returns 201 - Created

/api/menu-items/{menuItem}

Manager

GET

Lists single menu item

/api/menu-items/{menuItem}

Manager

PUT

Updates single menu item

/api/menu-items/{menuItem}

Manager

DELETE

Deletes menu item

User group management endpoints

Endpoint

Role

Method

Purpose

/api/groups/manager/users

Manager

GET

Returns all managers

/api/groups/manager/users/{userId}

 

Manager

POST

Assigns the user in the payload to the manager group and returns 201-Created

/api/groups/manager/users/{userId}

Manager

DELETE

Removes this particular user from the manager group and returns 200 – Success if everything is okay.

If the user is not found, returns 404 – Not found

/api/groups/delivery-crew/users

Manager

GET

Returns all delivery crew

/api/groups/delivery-crew/users/{userId}

 

Manager

POST

Assigns the user in the payload to delivery crew group and returns 201-Created HTTP

/api/groups/delivery-crew/users/{userId}

Manager

DELETE

Removes this user from the manager group and returns 200 – Success if everything is okay.

If the user is not found, returns  404 – Not found

Cart management endpoints

Endpoint

Role

Method

Purpose

/api/cart

Customer

GET

Returns current items in the cart for the current user token

/api/cart

 

Customer

 

POST

Adds the menu item to the cart. Sets the authenticated user as the user id for these cart items

/api/cart

 

Customer

 

PUT

Update the quantity of product {id,cnt} OR delete one item from the cart {id} only

/api/cart

 

Customer

 

DELETE

Deletes all menu items created by the current user token

Order management endpoints

Endpoint

Role

Method

Purpose

/api/orders

Customer

GET

Returns all orders with order items created by this user

/api/orders

 

Customer

 

POST

Creates a new order item for the current user. Gets current cart items from the cart endpoints and adds those items to the order items table. Then deletes all items from the cart for this user.

/api/orders/{orderId}

 

Customer

GET

Returns all items for this order id. If the order ID doesn’t belong to the current user, it displays an appropriate HTTP error status code.

/api/orders

Manager

GET

Returns all orders with order items by all users

/api/orders/{orderId}

 

Customer

 

PUT, PATCH

Updates the order. A manager can use this endpoint to set a delivery crew to this order, and also update the order status to 0 or 1.

If a delivery crew is assigned to this order and the status = 0, it means the order is out for delivery.

If a delivery crew is assigned to this order and the status = 1, it means the order has been delivered.

/api/orders/{orderId}

Manager

DELETE

Deletes this order

/api/orders

Delivery crew

GET

Returns all orders with order items assigned to the delivery crew

/api/orders/{orderId}

Delivery crew

 

PATCH

A delivery crew can use this endpoint to update the order status to 0 or 1. The delivery crew will not be able to update anything else in this order.

DataBase Diagrame :

DB-Diagrame

This project is under Devlopment

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/DigitalMarket_API.git
  2. Navigate to the project directory:

    cd DigitalMarket_API
  3. Install dependencies:

    pip install -r requirements.txt
  4. Apply database migrations:

    python manage.py migrate
  5. Run the development server:

    python manage.py runserver
  6. Access the API at http://localhost:8000/.

Using Docker

  1. Ensure you have Docker Engine installed on your system.

  2. open terminal/cmd .

  3. Run the following command to build and start the Docker services:

docker-compose up -d
  1. Access the API at http://localhost:8000/.

  2. Access the phpMyAdmin at http://localhost:80/.

NOTE : if you faced any problem with django server, just Restart it.

Feel free to reach out with any questions, feedback, or suggestions!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published