Skip to content

Latest commit

 

History

History
218 lines (160 loc) · 3.4 KB

README.md

File metadata and controls

218 lines (160 loc) · 3.4 KB

edp-backend

Project description link

Links

API Endpoints

Search and filter

For searching and filter all GET all endpoints access the following query params:

  • search: which is a text you are trying to search

  • Page: page number form 1 to ...

  • Limit: which is the size of results to be returned per page

    example: /sales?page=2&limit=15&search=FAB

Authentication

Login

POST /authentication/sign-in

{
    "Content-type": "application/json"
    "body":{
        "phoneNumber":"0789374675",
        "password":"string345"
    }
}

Current user

GET /authentication/current

{
    "Content-type": "application/json"
    "Authorization":{{TOKEN}}
}

Users

Create a new user

POST /users (for admin)

POST /companies/:companyId/users (for supervisor)

{
    "Content-type": "application/json"
    "Authorization":{{TOKEN}}
    "body":{
        "username":"abayo",
        "password":"password",
        "phoneNumber":"0789277287",
        "companyId":"6faa1986-d9c9-42ab-a40e-477c1124581f"
    }
}

Get all users

GET /users (for admin)

GET /companies/:companyId/users (for supervisor)

{
    "Content-type": "application/json"
    "Authorization":{{TOKEN}}
}

Get one users

GET /users/:id (for admin and owner)

GET /companies/:companyId/users/:id (for supervisor)

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
}

Update user

PUT /users/:id

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
    "body":{
        "name":"Luc Abayo",
        "username":"abayo_luc",
        "email":"me@gexample"
    }
}

Update password

PUT /users/:id/passwords

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
    "body":{
       "password":"new-password"
    }
}

Company

Create a new company

POST /companies

{
    "Content-type": "application/json"
    "Authorization":{{ADMIN_TOKEN}}
    "body":{
        "name":"123 Inc.",
        "email":"[email protected]",
        "address":"KG 11 Av",
        "phoneNumber":"0789277275"
    }
}

Get all companies

GET /companies

{
    "Content-type": "application/json"
    "Authorization":{{TOKEN}}
}

Get one company

GET /company/:id

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
}

Update company

PUT /companies/:id/passwords

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
    "body":{
        "name":"EDP Ltd",
        "email":"[email protected]",
        "address":"GG 11 St",
        "phoneNumber":"0789866365"
    }
}

Delete company

DELETE /companies/:id

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
}

Sales

Get all sales

GET /sales (for only admins)

{
    "Content-type": "application/json",
    "Authorization":{{TOKEN}}
}

Get all company sales

GET /companies/:companyId/sales

Get all agent sales

GET /companies/:companyId/