Coder Social home page Coder Social logo

m4hf0d / homelift-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9.44 MB

Modern Furniture E-commerce Website as a group project for 3rd year. Led backend development using Django Rest Framework

Python 22.88% Procfile 0.04% CSS 37.33% JavaScript 36.61% HTML 3.14%
api-rest django-rest-framework postgresql

homelift-api's Introduction

HomeLift Api :

Table of Contents

Swagger More in depth Api Documentation :

Visit:

GET http://127.0.0.1:8000/swagger/
GET http://127.0.0.1:8000/redoc/

How to use:

Clone the Repo then :

python3 -m venv env
source env/bin/activate  
# On Windows use `env\Scripts\activate`

# Install the requirements
pip install -r requirements.txt

#Run the server 
python manage.py makemigrations
python manage.py migrate

python manage.py createsuperuser #optional

python manage.py runserver

Usage :

Authentification : Latest Version Old endpoints + New for staff

Authentification ( Old without verification) for customers

a) Registration
POST http://127.0.0.1:8000/account/register/

in the Request Body :

Key Type Description
email string Required Unique The Users Email
phone_number string Required Unique
password string Required
fullname string Required
username string
shipping_address string
payment_info string

Responses

{
  "response": "Registration Successful!",
    "phone_number": Phone_Number,
    "email": email,
    "token": {
        "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....",
        "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
    }
}

b) Login

POST http://127.0.0.1:8000/account/api/token/

in the Request Body :

Key Type
email string
password string

Responses

{
  "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Product :

a) Products List

 

GET http://127.0.0.1:8000/homeLift/products/ #Products list 

GET /api/products/          # get all products

GET /api/products/<pk>/     # get a specific product by primary key

GET /api/products/?min_price=<min_price>&max_price=<max_price>&price_exact=<price_exact> # filter products by price range 

GET /api/products/?archived=True #Filter By archived products

GET /api/products/?search=<search_term> # search for products by name, description, category, or subcategory

GET /api/products/?ordering=<ordering_field> # order products by name, price, or quantity

Responses

HTTP 200 OK
{
        "id": 6,
        "productComments": [],
        "productImages": [],
        "productRatings": [],
        "category_name": "Dining Room",
        "subcategory_name": "Dining table",
        "in_stock": true,
        "name": "Coffe Table",
        "image": "http://127.0.0.1:8000/images/images/coffetable_MABDhkG.jpg",
        "price": 21111.0,
        "description": "descr",
        "quantity": 2000,
        "rating_rv": 0.0,
        "rating_nb": 0,
        "created_at": "2023-04-20T13:09:31.814193Z",
        "updated_at": "2023-04-20T13:09:31.814193Z",
        "archived": false,
        "subcategory": 5,
        "category": 4
    },
b) Products Pictures

 

POST http://127.0.0.1:8000/homeLift/products/<int:pk>/images-create/ #Add images for specific Prodcut 
Key Type Description
image image <int:pk>==product id

Response

HTTP 201 Created
{
    "id": 2,
    "image": "http://127.0.0.1:8000/images/images/image.jpg"
}
GET|PUT|DELETE http://127.0.0.1:8000/homeLift/products/images/<int:pk>/ #Get Image by id
Key Type Description
image image <int:pk>==image id

Response

HTTP 201 Created
{
    "id": 2,
    "image": "http://127.0.0.1:8000/images/images/image.jpg"
}
c) Create A Product:

 

POST  http://127.0.0.1:8000/homeLift/products/

in the Request Body :

Key Type Description
name string Required Unique
image picture
price integer Required
description string
quantity integer
category string category.name
subcategory string subcategory.name
archived bool default = False

Responses

HTTP 201 Created
{
    "id": 9,
    "productComments": [],
    "productImages": [],
    "productRatings": [],
    "category_name": "Bedroom",
    "subcategory_name": "Nightstand",
    "in_stock": true,
    "name": "Test Product 1",
    "image": "http://127.0.0.1:8000/images/images/fc_GQ9Uy1Q.jpg",
    "price": 188888.0,
    "description": "Description",
    "quantity": 5000,
    "rating_rv": 0.0,
    "rating_nb": 0,
    "created_at": "2023-04-28T21:44:56.529072Z",
    "updated_at": "2023-04-28T21:44:56.529072Z",
    "archived": false,
    "subcategory": 7,
    "category": 2

}
c) Retrieve/Updat/Delete a Product : (& Archive a Product)

 

GET|PUT|Patch|DELETE http://127.0.0.1:8000/homeLift/products/<id:int>/

in the Request Body :

Key Type Description
name string Required Unique
image picture
price integer Required
description string
quantity integer
category string category.name
subcategory string subcategory.name
archived bool default = False

Responses

HTTP 201 Created
{
    "id": 9,
    "productComments": [],
    "productImages": [],
    "productRatings": [],
    "category_name": "Bedroom",
    "subcategory_name": "Nightstand",
    "in_stock": true,
    "name": "Test Product 1",
    "image": "http://127.0.0.1:8000/images/images/fc_GQ9Uy1Q.jpg",
    "price": 188888.0,
    "description": "Description",
    "quantity": 5000,
    "rating_rv": 0.0,
    "rating_nb": 0,
    "created_at": "2023-04-28T21:44:56.529072Z",
    "updated_at": "2023-04-28T21:44:56.529072Z",
    "archived": false,
    "subcategory": 7,
    "category": 2

}

 To archive a Product Patch Request with archived = True

{
    "id": 9,
    "archived": true,
}

Categories :

GET|POST http://127.0.0.1:8000/homeLift/categories/ #List All categories/ Add a category

in the Request Body :

Key Type Description
name string Required Unique
Responses
HTTP 201 Created
{
    "id": 6,
    "subCategories": [],
    "name": Category name
}

 

Sub-Categories

GET http://127.0.0.1:8000/homeLift/categories/<int:pk>/subcategory/ #List All sub categories in a category

in the Request Body :

Key Type Description
name string Required Unique
Responses
HTTP 201 Created
{
    "id": 6,
    "subCategories": [],
    "name": Category name
}

 

POST http://127.0.0.1:8000/homeLift/categories/<int:pk>/subcategory/ #Create sub-category

in the Request Body :

Key Type Description
name string Required Unique , <int:pk> == Category ID
Responses
HTTP 201 Created
{
    "id": 9,
    "products": [],
    "name": "Sub-Category Name
}

 

GET|Put|Patch|Delete http://127.0.0.1:8000/homeLift/categories/subcategory/<int:pk>/ #Edit subcategory

in the Request Body :

Key Type Description
name string Required Unique , <int:pk> == Sub-Category ID
Responses
HTTP 201 Created
{
    "id": 5,
    "products": [],
    "name": New-Name
}

View Customer List

  GET http://127.0.0.1:8000/account/customer-list/

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": role_id,
    "blocked": True or False,
    "profile_picture": profile picture
}

RetrieveUpdateDelete Customer (you can Block here)

http://127.0.0.1:8000/account/customer-list/<int:pk>/
Key Type Description
username string
fullname string Required(not necessarily modified)
email string Required (not necessarily modified)
phone_number string Required (not necessarily modified)
shipping_address string
payment_info string
profile_picture picture

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": 2,
    "blocked": True or False,
    "profile_picture": profile picture
}

View And Edit Profile

1)view profile:
  GET http://127.0.0.1:8000/account/${id}/view-profile/

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": role_id,
    "blocked": True or False,
    "profile_picture": profile picture
}
2)edit profile:
  PUT http://127.0.0.1:8000/account/${id}/view-profile/
Key Type Description
username string
fullname string Required(not necessarily modified)
email string Required (not necessarily modified)
phone_number string Required (not necessarily modified)
shipping_address string
payment_info string
profile_picture picture

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": role_id,
    "blocked": True or False,
    "profile_picture": profile picture
}

View Staff List

  GET http://127.0.0.1:8000/account/staff-list/

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": role_id,
    "blocked": True or False,
    "profile_picture": profile picture
}

Add Staff

  POST http://127.0.0.1:8000/account/staff-list/add/
Key Type Description
username string
fullname string Required
email string Required Unique
phone_number string Required Unique
shipping_address string
payment_info string
profile_picture picture

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": 2,
    "blocked": True or False,
    "profile_picture": profile picture
}

RetrieveUpdateDelete Staff (you can Block here)

1)Retrieve:
  GET http://127.0.0.1:8000/account/staff-list/${id}/

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": 2,
    "blocked": True or False,
    "profile_picture": profile picture
}
2)Update:
  PUT  http://127.0.0.1:8000/account/staff-list/${id}/
Key Type Description
username string
fullname string Required(not necessarily modified)
email string Required (not necessarily modified)
phone_number string Required (not necessarily modified)
shipping_address string
payment_info string
profile_picture picture

Responses

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": 2,
    "blocked": True or False,
    "profile_picture": profile picture
}
3)Delete:
Delete http://127.0.0.1:8000/account/staff-list/${id}/
View blocked Users :
GET http://127.0.0.1:8000/account/blocked/

Response :

{
    "id": id,
    "username": username,
    "fullname": fullname,
    "email": email,
    "phone_number": phone_number,
    "shipping_address": shipping_address,
    "payment_info":payment_info ,
    "role": 2,
    "blocked": True or False,
    "profile_picture": profile picture
}

Notes:

Roles:

id Role
Admin 1
Staff 2
Client 3

homelift-api's People

Contributors

m4hf0d avatar chaimaslimane avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.