This repo contains a Remix.run project with a Postgresql database queried with Prisma.io.
The backend also exposes API routes in the /api/v1 folder.
All requests to the API routes, except for the /api/v1/.../login
API route , must have the authorization
header set with the token in the form:
const headers = {
authorization: `Bearer <jwt>`,
};
All API routes accept only application/json
as Content-Type
in body request and return application/json
as Content-Type
in response body.
⚠️ please note that thenull
value could possibly be returned as body response of a 200 or 204 response
A docker-compose.yaml
file can be found in the project that starts a postgresql
server.
Setup your .env
file like the .env.example
.
In order to start the dev database server, run:
⚠️ please note that we use the latest version of Docker that already has compose, notdocker-compose
$ npm run dev:docker
To stop the database server run npm run dev:docker:stop
.
The prisma model for the database can be found here.
Once a change is made, run:
$ npm run db:push
This will overwrite all existings data in your database, and setup a new library.
The connection to the database is handled by this helper, for example:
import { database } from "~/helpers/db-helper.server";
database.user.create({
data: {
firstName: "Saul",
lastName: "Goodman",
},
});
ℹ️ Migrations are work in progress
A great utility is the prisma studio
package that should be already installed.
In order to run the prisma studio
utility, run:
-
Linux/MacOS
$ npm run dev:prisma
-
Windows
$ DATABASE_URL="postresql://<user>:<password>@<host>:<port>/<db>" npx prisma studio
- Ecommerce
- Warehouse
- Active Product
- Customers
- Employees
- Orders
- GET
/api/v1/warehouse/orders
- GET
/api/v1/warehouse/orders/{id}
- PATCH
/api/v1/warehouse/orders/{id}
- DELETE
/api/v1/warehouse/orders/{id}
- GET
/api/v1/warehouse/orders//by-status/{status}
- POST
/api/v1/warehouse/orders/dates/within-delivered
- POST
/api/v1/warehouse/orders/dates/within-ordered
- POST
/api/v1/warehouse/orders/dates/within-shipped
- GET
- Product Instances
- GET
/api/v1/warehouse/productInstances
- POST
/api/v1/warehouse/productInstances
- PATCH
/api/v1/warehouse/productInstances/{productInstanceId}
- DELETE
/api/v1/warehouse/productInstanceso/{productInstanceId}
- GET
/api/v1/warehouse/productInstances/{productInstanceId}
- POST
/api/v1/warehouse/productInstances/productInstanceActivation
- GET
/api/v1/warehouse/productInstances/count/by-status/{productInstanceStatus}
- GET
/api/v1/warehouse/productInstances/count/by-type/{productId}
- GET
- Product
Create a new customer
Content-Type: application/json
{
"email": "example@example.com",
"password": "password",
"firstName": "John",
"lastName": "Doe",
"billingAddressId": "cl52gilrq0059g4jjj50ffvdg",
"shippingAddressId": "cl4zoemig0036l2jjv0efdted"
}
Constraints:
password
must have at least 8 characters
{
"id": "",
"email": "example@example.com",
"password": "password",
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z",
"firstName": "John",
"lastName": "Doe",
"billingAddressId": "cl52gilrq0059g4jjj50ffvdg",
"shippingAddressId": "cl4zoemig0036l2jjv0efdted"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
405 Method Not Allowed |
The request method is not POST |
Update customer info
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid customer id
{
"customer": {
"email": "example@example.com",
"password": "password",
"firstName": "John",
"lastName": "Doe"
}
}
Constraints:
password
must have at least 8 characters
{
"id": "",
"email": "example@example.com",
"password": "password",
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z",
"firstName": "John",
"lastName": "Doe",
"billingAddressId": "cl52gilrq0059g4jjj50ffvdg",
"shippingAddressId": "cl4zoemig0036l2jjv0efdted"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
404 Not Found |
Customer not found |
405 Method Not Allowed |
The request method is not PATCH |
Delete a customer
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid customer id
{
"id": "",
"email": "example@example.com",
"password": "password",
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z",
"firstName": "John",
"lastName": "Doe",
"billingAddressId": "cl52gilrq0059g4jjj50ffvdg",
"shippingAddressId": "cl4zoemig0036l2jjv0efdted"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Customer not found |
405 Method Not Allowed |
The request method is not PATCH |
Create a customer credit card
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid customer id
{
"creditCard": {
"number": 1234567887654321,
"expMonthDate": 1,
"expoYearDate": 1970,
"secretCode": 123
}
}
Constraints:
number
must be positiveexpMonthDate
must be between1
and12
expYearDate
must be greater than1970
secretCode
must be positive
{
"id": "cl5atk1nr002506jjot8atd5p",
"number": 1234567887654321,
"expMonthDate": 1,
"expoYearDate": 1970,
"secretCode": 123
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Customer not found |
405 Method Not Allowed |
The request method is not POST |
Get a valid jwt for a customer
Content-Type: application/json
{
"email": "example@example.com",
"password": "password"
}
Constraints:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
404 Not found |
User not found |
405 Method Not Allowed |
The request method is not POST |
Creates an order given the id of the customer and a list of product id with relative quantity
Content-Type: application/json
Authorization: Bearer <jwt>
{
"customerId": "cl5apl7c00037xhjjm5hela3m",
"products": [
{
"productId": "cl4zoemig0036l2jjv0efdted",
"quantity": 2
},
{
"productId": "cl5ar5z3y0051cujjz0cq3jo7",
"quantity": 1
}
]
}
Constraints:
customerId
must be a valid cuidproductId
must be a valid cuidquantity
must be a positive number
{
"id": "cl4vfbh0u00009xjjvk2btxym",
"status": "ORDERED",
"orderedAt": "2022-06-26T14:45:56.334Z",
"shippedAt": null,
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid or the customerId do not exist |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
The productId (s) provided do not exist |
405 Method Not Allowed |
The request method is not POST |
Get all the active products
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"products": [
{
"id": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Create a new Active Product
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"customerId": "c00p6qup20000ckkzslahp5pn"
}
Constraints:
customerId
must be a valid cuid
{
"id": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not POST |
Update an Active Product status
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"activeProductInstanceId": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE"
}
Constraints:
activeProductInsanceId
must be a valid cuidstatus
must be a validActiveProductInstanceStatus
{
"id": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
Delete an Active Product
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"activeProductInstanceId": "cl4zoemig0036l2jjv0efdted"
}
Constraints:
activeProductInsanceId
must be a valid cuid
{
"id": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not PATCH |
Get the active product with the specific activeProductInstanceId
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
{
"id": "cl4zoemig0036l2jjv0efdted",
"status": "ACTIVE",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not GET |
Get all the customers
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"customers": [
{
"id": "c00p6qup20000ckkzslahp5pn",
"email": "john@doe.com",
"password": "hashedpassword",
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z",
"firstName": "John",
"lastName": "Doe",
"billingAddressId": "ch72gsb320000udocl363eofy",
"shippingAddressId": "c00p6qup20000ckkzslahp5pn"
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Get a specific customer
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
{
"id": "c00p6qup20000ckkzslahp5pn",
"email":"john@doe.com",
"password":"hashedpassword",
"createdAt":"1970-01-01T00:00:00.000Z",
"updatedAt":"1970-01-01T00:00:00.000Z",
"firstName":"John",
"lastName":"Doe",
"billingAddressId":"ch72gsb320000udocl363eofy",
"shippingAddressId":"c00p6qup20000ckkzslahp5pn"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Delete a specific customer
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
{
"id": "c00p6qup20000ckkzslahp5pn",
"email":"john@doe.com",
"password":"hashedpassword",
"createdAt":"1970-01-01T00:00:00.000Z",
"updatedAt":"1970-01-01T00:00:00.000Z",
"firstName":"John",
"lastName":"Doe",
"billingAddressId":"ch72gsb320000udocl363eofy",
"shippingAddressId":"c00p6qup20000ckkzslahp5pn"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Customer not found |
405 Method Not Allowed |
The request method is not GET |
Get a specific customer's Active Products
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"activeProducts": [
{
"status": "",
"id": "c00p6qup20000ckkzslahp5pn",
"model": ""
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Customer has no Active Products |
405 Method Not Allowed |
The request method is not GET |
Get a specific customer's Orders
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"orders": [
{
"id": "c00p6qup20000ckkzslahp5pn",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": "1970-01-01T00:00:00.000Z",
"deliveredAt": "1970-01-01T00:00:00.000Z",
"customerId": "c00p6qup20000ckkzslahp5pn"
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Customer has no Orders |
405 Method Not Allowed |
The request method is not GET |
List all the employees
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"employees": [
{
"id": "",
"email": "",
"createdAt": "",
"updatedAt": "",
"firstName": "",
"lastName": "",
"role": "ADMIN"
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not METHOD |
Create a new employee
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"email": "",
"password": "",
"firstName": "",
"lastName": "",
"role": ""
}
Constraints:
role
must be a valid Role
{
"id": "",
"email": "",
"createdAt": "",
"updatedAt": "",
"firstName": "",
"lastName": "",
"role": "ADMIN"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not POST |
Get a valid jwt for an employee
Content-Type: application/json
{
"email": "example@example.com",
"password": "password"
}
Constraints:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
405 Method Not Allowed |
The request method is not POST |
Get information about the current employee
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "",
"email": "",
"password": "",
"createdAt": "",
"updatedAt": "",
"firstName": "",
"lastName": "",
"role": "ADMIN"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Get information about a specific employee
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"employee": {
"id": "ch72gsb320000udocl363eofy",
"email": "example@example.com",
"password": "988119d6cca702beb1748f4eb497e316467f69580ffa125aa8bcb6fb63dce237",
"createdAt": "01-01-1970-00:00:00",
"updatedAt": "01-01-1970-00:00:00",
"firstName": "John",
"lastName": "Doe",
"role": "ADMIN"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Get information about a specific employee
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "",
"email": "",
"password": "",
"createdAt": "",
"updatedAt": "",
"firstName": "",
"lastName": "",
"role": "ADMIN"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not PATCH |
Delete a specific employee
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"id": "",
"email": "",
"password": "",
"createdAt": "",
"updatedAt": "",
"firstName": "",
"lastName": "",
"role": "ADMIN"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Employee not found |
405 Method Not Allowed |
The request method is not DELETE |
Retrieves the complete list of orders.
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"orders": [
"id": "cl4qrncms0334tcjj75gn06tv",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": null,
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
]
]
}
Error code | Description |
---|---|
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not DELETE |
Retrieves a single order
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "1970-01-01T00:00:00.000Z",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": null,
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Order not found |
405 Method Not Allowed |
The request method is not GET |
Update an order
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"status": "DELIVERED",
"shippedAt": "1970-01-01T00:00:00.000Z",
"deliveredAt": "1970-01-01T00:00:00.000Z"
}
Constraints:
id
must be a valid cuidstatus
must be a valid status
{
"id": "cl4vfbh0u00009xjjvk2btxym",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": "1970-01-01T00:00:00.000Z",
"deliveredAt": "1970-01-01T00:00:00.000Z",
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
The order do not exist |
405 Method Not Allowed |
The request method is not PATCH |
Set an order status to CANCELLED
.
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee
{
"id": "cl4vfbh0u00009xjjvk2btxym",
"status": "CANCELLED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": "1970-01-01T00:00:00.000Z",
"deliveredAt": "1970-01-01T00:00:00.000Z",
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
The order do not exist |
405 Method Not Allowed |
The request method is not DELETE |
Get a list of orders that match the given status
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"orders": [
"id": "cl4qrncms0334tcjj75gn06tv",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": null,
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
]
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Order not found |
405 Method Not Allowed |
The request method is not GET |
Get a list of orders delivered within the given dates
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"startDate": "1970-01-01T00:00:00.000Z",
"endDate": "1970-01-01T00:00:00.000Z"
}
{
"orders": [
"id": "cl4qrncms0334tcjj75gn06tv",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": null,
"deliveredAt": "1970-01-01T00:00:00.000Z",
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
]
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Order not found |
405 Method Not Allowed |
The request method is not GET |
Get a list of orders ordered within the given dates
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"startDate": "1970-01-01T00:00:00.000Z",
"endDate": "1970-01-01T00:00:00.000Z"
}
{
"orders": [
"id": "cl4qrncms0334tcjj75gn06tv",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": null,
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
]
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Order not found |
405 Method Not Allowed |
The request method is not GET |
Get a list of orders ordered within the given dates
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"startDate": "1970-01-01T00:00:00.000Z",
"endDate": "1970-01-01T00:00:00.000Z"
}
{
"orders": [
"id": "cl4qrncms0334tcjj75gn06tv",
"status": "ORDERED",
"orderedAt": "1970-01-01T00:00:00.000Z",
"shippedAt": "1970-01-01T00:00:00.000Z",
"deliveredAt": null,
"customerId": "cl4qrmvvf0278tcjjl1zu8g6a",
"productInstances": [
{
"id": "cl52gilrq0059g4jjj50ffvdg",
"status": "SOLD",
"orderId": "cl5atk1nr002506jjot8atd5p",
"productId": "cl4zoemig0036l2jjv0efdted",
"product": {
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Test Product",
"imageUrl": "/path/to/image",
"description": "Test Description",
"color": "Blue",
"size": "M",
"price": 19.99,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z"
}
},
]
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Order not found |
405 Method Not Allowed |
The request method is not GET |
Retrieve the complete list of product instances.
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"productInstances": [
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3",
"activeProductInstance": {
"id": "cl4rb2pdh00012a6640drwif0",
"status": "ACTIVE",
"customerId": "cl4rb3wvv00032a66audt0pbp"
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not GET |
Create a number of new product instances given the quantity and the type of product
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"productId": "cl4rb193000002a66jmw17ri3",
"quantity": 3
}
Constraints:
productId
must be a valid cuidquantity
must be greater than0
{
"numberOfCreatedProductInstances": 3
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not POST |
Update the fields of a specific product instance
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3"
}
Constraints:
- The
id
field is readonly, used only to query the product instance to update- All the id fields must be a valid cuid
status
accepts only "SOLD" and "IN_STOCK" as valid valuesorderId
can benull
{
"productInstance": {
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Product Instance not found |
405 Method Not Allowed |
The request method is not PATCH |
Delete a specific product instance record and its related active product instance record (if present)
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "ch72gsb320000udocl363eofy"
}
Constraints:
- The
id
field is readonly, used only to query the product instance to update, and must be a valid cuid
{
"productInstance": {
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3"
}
}
Constraints:
- The
id
field is readonly, used only to query the product instance to update- All the id fields must be a valid cuid
status
accepts only "SOLD" and "IN_STOCK" as valid valuesorderId
can benull
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Product Instance not found |
405 Method Not Allowed |
The request method is not DELETE |
Retrieve a specific product instance
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"productInstance": {
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not GET |
Activate a specific product instance
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"customerId": "ch72gsb320000udocl363eofy",
"productInstanceId": "cl4zoemig0036l2jjv0efdted"
}
Constraints:
- The
id
fields must be a valid cuid
{
"productInstanceActivated": {
"id": "ch72gsb320000udocl363eofy",
"status": "SOLD",
"orderId": "c00p6qup20000ckkzslahp5pn",
"productId": "cl4rb193000002a66jmw17ri3"
}
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Product Instance not found |
405 Method Not Allowed |
The request method is not POST |
Retrieve a count of product instances by their status
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"numberOfProductInstances": 3
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Product Instances not found |
405 Method Not Allowed |
The request method is not GET |
Retrieve a count of product instances by their product type
Content-Type: application/json
Authorization: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"numberOfProductInstances": 3
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Product Instances not found |
405 Method Not Allowed |
The request method is not GET |
List all products
Content-Type: application/json
Authentication: Bearer <jwt>
{
"products": [
{
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Blue",
"size": "L",
"price": 199.99
}
]
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
405 Method Not Allowed |
The request method is not GET |
Create a new product given the necessary parameters.
Content-Type: application/json
Authentication: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id with ADMIN role
{
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Blue",
"size": "L",
"price": 199.99
}
Constraints:
price
must be greater than0
{
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Blue",
"size": "L",
"price": 199.99,
"createdAt": "2022-06-29T14:10:44.094Z",
"updatedAt": "2022-06-29T14:11:24.664Z"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
405 Method Not Allowed |
The request method is not POST |
Get a specific product
Content-Type: application/json
Authentication: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Blue",
"size": "L",
"price": 199.99
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
404 Not Found |
Product not found |
405 Method Not Allowed |
The request method is not GET |
Update the fields of a specific product
Content-Type: application/json
Authentication: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Black",
"size": "L",
"price": 189.99
}
Constraints:
price
must be greater than0
{
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Black",
"size": "L",
"price": 199.99,
"createdAt": "2022-06-29T14:10:44.094Z",
"updatedAt": "2022-06-30T15:02:55.335Z"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Product not found |
405 Method Not Allowed |
The request method is not PATCH |
Delete a specific product record
Content-Type: application/json
Authentication: Bearer <jwt>
Constraints:
- The
jwt
must contain a valid employee id and role
{
"id": "cl4zoemig0036l2jjv0efdted",
"model": "Watch",
"imageUrl": ["/path/to/image"],
"description": "A cool watch",
"color": "Black",
"size": "L",
"price": 199.99,
"createdAt": "2022-06-29T14:10:44.094Z",
"updatedAt": "2022-06-30T15:02:55.335Z"
}
Error code | Description |
---|---|
400 Bad Request |
The request body content is invalid |
401 Unauthorized |
Authentication credentials not valid |
403 Forbidden |
User has not enough rights to access the resource |
404 Not Found |
Product not found |
405 Method Not Allowed |
The request method is not PATCH |