This documents lists the available routes served by this json-server mock API.
All the routes listed below are read-only mode.
You can only access the resources through the GET
HTTP method.
List of all available products. id
parameter is optional, if not specified, all the products will be retrieved.
GET /api/products/:id?
{
"id": "<number>",
"category": "<string>",
"name": "<string>",
"sale_price": "<number>",
"margin": "<number>"
}
List of all company customers. id
parameter is optional, if not specified, all the products will be retrieved.
GET /api/customers/:id?
{
"id": "<number>",
"firstName": "<string>",
"lastName": "<string>"
}
List of all company invoices + content (invoices lines).
GET /api/invoices/:id?
{
"id": "<number>",
"customer_id": "<number>",
"customer_name": "<string>",
"date": "<YYYY-MM-DD>",
"total_invoice": "<number>",
"total_margin": "<number>",
"region": "<string>",
"invoice_lines": [
{
"product_id": "<number>",
"product_name": "<string>",
"unit_price": "<number>",
"quantity": "<number>",
"total_line": "<number>",
"total_margin": "<number>"
}
]
}
Calculations of the revenues of the company on a time period.
:period
argument is mandatory : can be either monthly
or weekly
GET /api/revenues/:period
NB : week
attribute is only available for weekly revenues, and respectively, month
attribute only available for monthly results.
{
"week": "<YYYY W-ww>",
"month": "<YYYY-MM>",
"start_date": "<YYYY-MM-DD>",
"end_date": "<YYYY-MM-DD>",
"invoices_count": "<number>",
"total_margin": "<number>",
"total_revenue": "<number>"
}
Retrieve the customers list, with the total revenue, margin and invoices count they generated.
GET /api/customers/revenues
{
"customer_id": "<number>",
"customer_name": "<string>",
"total_revenue":"<number>",
"total_margin": "<number>",
"invoices_count": "<number>"
}
Retrieve the products categories, and the total amount of revenues and margin they generated.
GET /api/categories/revenues
{
"category_name": "<string>",
"total_revenue": "<number>",
"total_margin": "<number>"
}