Giter VIP home page Giter VIP logo

eco-mmerce-project's Introduction

Eco-mmerce

Models:

User

- email : string, required, unique, email format
- firstName : string, required
- lastName : string, required
- phoneNumber : integer, required
- password : string, required
- picture: url, required
- role : string
- username: string, required

Products

- name : string, required
- price : integer, required
- stock : string, required
- weight : double,required
- status : string,required
- ingridient : string,required
- picture : string,required, url format
- UserId : string,required
- CategoryId : string,required

Chats

- BuyerId : string, required
- SellerId : text, required
- Message : integer, required

list of available endpoints:

  • POST /buyers/register
  • POST /buyers/login
  • POST /buyers/login/google
  • POST /sellers/register
  • POST /sellers/login
  • GET /buyers/products
  • GET /buyers/products/:id
  • GET /brands
  • GET /categories
  • GET /ingridients

routes below need authentication & authorization

  • GET /buyers/carts
  • GET /buyers/history
  • POST /buyers/carts
  • POST /buyers/checkout
  • DELETE /buyers/carts
  • DELETE /buyers/carts/:id
  • GET /chats/:id
  • GET /sellers/chats
  • GET /sellers/products
  • GET /sellers/products/:id
  • POST /sellers/products
  • PUT /sellers/products/:id
  • DELETE /sellers/products/:id



GET /brands

description: get all brands from database

Response:

  • status: 200
  • body:
[
    {
        "id": "integer",
        "name": "string",
    },
  ...,
  ...,
]

GET /categories

description: get all categories from database

Response:

  • status: 200
  • body:
[
    {
        "id": "integer",
        "name": "string",
    },
  ...,
  ...,
]

GET /ingridients

description: get all ingredients from database

Response:

  • status: 200
  • body:
[
    {
        "id": "integer",
        "name": "string",
    },
  ...,
  ...,
]

POST /buyers/register || /sellers/register

Request:

  • data:
{
  "email": "string",
  "firstName": "string",
  "lastName": "string",
  "password": "string",
  "phoneNumber": "integer",
  "picture": "file",
  "username": "string",
}

Response:

  • status: 201
  • body: โ€‹
{
  "id": "integer",
  "email": "string",
}

Response (400 - Bad Request)

{
  "message": "<field> cannot be empty"
}

Response (400 - Bad Request)

{
  "message": "Invalid email format"
}

Response (400 - Bad Request)

{
  "message": "Email already exists"
}

POST /buyers/login || /sellers/logins

Request:

  • data:
{
  "email": "string",
  "password": "string"
}

Response:

  • status: 200
  • body: โ€‹
{
  "access_token": "jwt string",
  "id": "integer",
  "role": "string",
  "picture": "string",
  "firstName": "string",
  "lastName": "string",
}

Response (401 - Unauthenticated)

{ "message": "Invalid Email or Password" }

GET /buyers/products

description: get all products from database

Response:

  • status: 200
  • body:
[
    {
        "id": "integer",
        "name": "string",
        "price": "integer",
        "stock": "Integer",
        "picture": "url String",
        "harmfulIngridient": ["string"],
        "Category": {
            "id": "integer",
            "name": "string"
        },
        "Brands": [
            {
                "id": integer,
                "name": "string"
            }
        ]
    },
  ...,
  ...,
]

GET /products/:id

description: get the details of a product

Response:

  • status: 201
  • body:
{
    "id": 3,
    "name": "string",
    "price": "integer",
    "stock": "integer",
    "weight": "integer",
    "status": "string",
    "description": "string",
    "ingridient": ["string"],
    "picture": "url string",
    "harmfulIngridient": ["string"],
    "UsersProducts": [
        {
            "ProductId": "integer",
            "User": {
                "id": "integer",
                "firstName": "string",
                "lastName": "string",
                "role": "string"
            }
        }
    ],
    "Category": {
        "id": "integer",
        "name": "string"
    },
    "Brands": [
        {
            "id": "integer",
            "name": "string"
        }
    ]
}

Response (404 - Not Found)

{ "message": "ID not found !" }

GET /buyers/carts

description: show cart

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
[
    {
        "Product": {
            "id": "integer",
            "name": "string",
            "stock": "integer",
            "price": "string",
            "weight": "integer",
            "status": "string",
            "picture": "url string",
            "UsersProducts": {
                "User": {
                    "id": "integer",
                    "firstName": "string",
                    "lastName": "string"
                }
            },
            "qty": "integer"
        }
    },
	...,
	...
]

Response (401 - Unauthorized)

{
    "message": "You are not authorized!"
}

POST /buyers/carts

description: add product to cart

Request:

  • headers: access_token (string)
  • body:
{
	ProductId: "integer"
}

Response:

  • status: 200
  • body:
{
    "message": "Product is added to cart"
}

Response (401 - Unauthorized)

{
    "message": "You are not authorized!"
}

DELETE /buyers/carts/:id

description: delete items in a cart

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
{
    "message": "Product has been reduced by one"
}

POST /buyers/carts/checkout

description: checkout cart

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
{
    "token": "b8e4cd43-717b-49b4-b9c7-82ff1c054ff3",
    "redirect_url": "https://app.sandbox.midtrans.com/snap/v2/vtweb/b8e4cd43-717b-49b4-b9c7-82ff1c054ff3"
}

GET /buyers/history

description: get order history

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
[
    {
        "Product": {
            "id": "integer",
            "name": "string",
            "stock": "integer",
            "price": "string",
            "weight": "integer",
            "status": "string",
            "picture": "url string",
            "UsersProducts": {
                "User": {
                    "id": "integer",
                    "firstName": "string",
                    "lastName": "string"
                }
            },
            "qty": "integer"
        }
    },
	...,
	...
]

GET /chats/:id

description: get chat with another user

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
[
    {
        "BuyerId": 'integer',
        "SellerId": 'integer',
        "message": "string",
        "fullName": "string"
    },
	...,
	...
]

GET /sellers/chats/:id

description: get chat to another user

Request:

  • headers: access_token (string)

Response:

  • status: 200
  • body:
[
    {
        "BuyerId": 'integer',
        "SellerId": 'integer',
        "message": "string",
        "User": {
			"id": 'integer',
			"firstName": 'string',
			"lastName": 'string'
		}
    },
	...,
	...
]

Global Error

Response (401 - Unauthorized)

{ "message": "you are not authorized!" }

eco-mmerce-project's People

Contributors

ditaisyiyah avatar marcotiger avatar jayfortune03 avatar baskoropandu avatar

Stargazers

 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.