Skip to content

API Documentation

v0.0.3

Created by Ildiko Makra

Last update: 09-03-2022

BaseUrl-Azure: https://mammit.azurewebsites.net/

baseUrl-local: http://localhost:5000

Models in use:

  1. ProductModel
  2. CardModel
  3. UserModel

Routes for the ProductModel

Route 1

POST /api/v1/products/browse

Use for add a new product - Request Example

{
    "name": "tuote f",
    "strength": "5 mg",
    "package": "30 tabl",
    "quantity": 1,
    "vnr": 42345,
    "logged": "Ildiko"
}
  • Response Example
{
    "msg": "Logged product added",
    "post": {
        "name": "tuote g",
        "strength": "5 mg",
        "package": "30 tabl",
        "quantity": 1,
        "vnr": 52345,
        "logged": "Ildi",
        "_id": "620cdf167a00c3f1e6f32f36",
        "__v": 0
    }
}

Route 2

POST /api/v1/products/queue

Use for add new product into the queue (logged: false) - Request Example

{
    "name": "tuote f",
    "strength": "5 mg",
    "package": "30 tabl",
    "quantity": 1,
    "vnr": 42345
}
  • Response Example
{
    "msg": "Product added to queue",
    "post": {
        "name": "tuote f",
        "strength": "5 mg",
        "package": "30 tabl",
        "quantity": 1,
        "vnr": 42345,
        "_id": "620cdcbfc589236941ba2cca",
        "__v": 0
    }
}

Route 3

GET /api/v1/products/browse-all

Use for fetch the total number of products

Route 4

GET /api/v1/products/browse

Get products paginated by 5 item and sorted by names in ascending or descending order

Route 5

GET /api/v1/products/vnr/:vnr

Get products filtered by VNR and paginated by 5

Route 6

GET /api/v1/products/name/:name

Get products filtered by VNR and paginated by 5

Route 7

GET /api/v1/products/queue

Use to fetch products from the queue

Route 8

PUT /api/v1/products/queue/:id

Import (Accept) products into bookkeeping

Routes for the CardModel

Route 9

POST /api/v1/cards/received

Use for post in a card when new stock amount arrived from a supplier

!Required an array

  • Request Example
[
    {
        "date": "2022-02-16",
        "from": "Tukku4",
        "in": 10,
        "storage": 2,
        "vnr": "22345",
        "logged": "MI"
    },
    {
        "date": "2022-02-16",
        "from": "Tukku5",
        "in": 30,
        "storage": 2,
        "vnr": "33345",
        "logged": "Makra"
    }
]
  • Response Example
{
    "msg": "Product logged in successfully",
    "total": 2,
    "cardArray": [
        {
            "date": "2022-02-16",
            "from": "Tukku4",
            "in": 10,
            "storage": 2,
            "vnr": "22345",
            "logged": "MI"
        },
        {
            "date": "2022-02-16",
            "from": "Tukku5",
            "in": 30,
            "storage": 2,
            "vnr": "33345",
            "logged": "Makra"
        }
    ]
}

Route 10

POST /api/v1/cards/sale

!Protected route with JWT token in header: 'auth-token'

  • Request Example
{
    "date": "2022-02-16",
    "out": 1,
    "storage": 1,
    "patient": "IM",
    "doctor": "MT",
    "vnr": "22345",
    "logged": "MA"
}
  • Response Example
{
    "msg": "Product on customer sales logged successfully",
    "post": {
        "date": "2022-02-16T00:00:00.000Z",
        "out": 1,
        "storage": 1,
        "patient": "IM",
        "doctor": "MT",
        "vnr": 22345,
        "logged": "MA",
        "_id": "620ce9f0c031cf3638fb492d",
        "__v": 0
    }
}

Route 11

GET /api/v1/cards/browse-all

!Protected route with JWT token in header: 'auth-token'

Use for get the total number of all cards.

Route 12

GET /api/v1/cards/browse

!Protected route with JWT token in header: 'auth-token'

Use for fetch product cards paginated by 5 item

Route 13

GET /api/v1/cards/browse/:cardId

Use for select a card based on ID

Route 14

GET /api/v1/cards/vnr/:vnr

Use for select cards on a sepcific VNR-number - paginated

Route 15

GET /api/v1/cards/vnr-all/:vnr

Use for select cards on a sepcific VNR-number - without pagination

Route 16

GET /api/v1/cards/date

Use for select a date period for cards to be shown.

Routes for the UserModel

Route 17

POST /api/v1/users/register

  • Request Example
{
    "username": "user222",
    "email": "user.222@mail.com",
    "password" : "xxxabcd"
}
  • Response Example: shows the id of the created new user
{
    "createdUser": "620ccc705b1950510542c0ab"
}

Route 18

POST /api/v1/users/login

  • Request Example
{
    "username": "user222",
    "email": "user.222@mail.com",
    "password" : "xxxabcd"
}
  • Response Example : A JWT-token to provide when a route is protected for logged-in users
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MjBjY2M3MDViMTk1MDUxMDU0MmMwYWIiLCJpYXQiOjE2NDUwMDYxNzl9.aRFZaQX9dMN6r_h6MyvFDPFx-z6WX3IyRFtVY8jFEh4

Route 19

GET /api/v1/users/browse

Use for fetch all user details.

Route 20

POST /api/v1/users/logout -- Coming soon...