API Route
I. Introduction
This document provides an overview of the API routes used in the Qranty Transportation Server, detailing the endpoints, request methods, and functionalities provided by the server. By understanding the API routes, developers can effectively interact with the server to manage transportation resources, process data, and perform various operations within the Qranty system.
II. Auth Route
1. Login Route
- Endpoint:
/api/login - Method:
POST - Description: Authenticates the user and generates an access token for subsequent requests.
- Authentication: None
- Request Parameters:
username: The username of the user.password: The password of the user.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the login attempt.token: An access token for authenticating subsequent requests.
2. Change password Route
- Endpoint:
/api/change-password - Method:
POST - Description: Allows the user to change their password.
- Authentication: Bearer token
- Request Parameters:
oldPassword: The user's current password.newPassword: The new password to set.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the password change attempt.
III. Admin Routes
1. Add Model
- Endpoint:
/api/admin/model - Method:
POST - Description: Adds a new model to the system.
- Authentication: Bearer token
- Request Parameters:
name: The name of the model.videoType: A description of the model.playlist: The list videos of the modeltitle: The title of the videolink: The link of the videothumbnail: The thumbnail of the video
- Response:
status: The status of the request (success or error).message: A message indicating the result of the model addition attempt.
2. Delete Model
- Endpoint:
/api/admin/model - Method:
DELETE - Description: Deletes an existing model from the system.
- Authentication: Bearer token
- Request Parameters:
_id: The ID of the model to delete.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the model deletion attempt.
3. Get Models
- Endpoint:
/api/admin/models - Method:
GET - Description: Retrieves a list of models from the system.
- Authentication: Bearer token
- Response:
status: The status of the request (success or error).models: An array of models with their details.
4. Get single Model
- Endpoint:
/api/admin/model/:modelName - Method:
GET - Description: Retrieves a single model from the system.
- Authentication: None
- Response:
status: The status of the request (success or error).model: The details of the requested model.
5. Get Company settings
- Endpoint:
/api/admin/settings - Method:
GET - Description: Retrieves the company settings from the system.
- Authentication: Bearer token
- Response:
status: The status of the request (success or error).settings: The company settings.
6. Add print sample
- Endpoint:
/api/admin/settings/print-sample - Method:
POST - Description: Adds a print sample to the company settings.
- Authentication: Bearer token
- Request Parameters:
file: The name of the print sample.position: The position of area to insertqrcode: The position of QR code[any]: The position of the field is configed auto fill at the Manage Registration Fields
- Response:
status: The status of the request (success or error).message: A message indicating the result of the print sample addition attempt.
7. Add Registration Field
- Endpoint:
/api/admin/settings/activation-fields - Method:
POST - Description: Adds a registration field to the company settings.
- Authentication: Bearer token
- Request Parameters:
fieldName: The name of the field.label: The label of the field.type: The type of the field.autoFill: Whether the field is auto-filled by scanning a QR code.required: Whether the field is required.regex: The regular expression to validate the field (optional).models: The models that the field belongs to.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the field addition attempt.
8. Get User role
- Endpoint:
/api/admin/role - Method:
GET - Description: Retrieves the list of roles of user from the system.
- Authentication: Bearer token
- Response:
status: The status of the request (success or error).roles: An array of roles.
9. Add User
- Endpoint:
/api/admin/add-user - Method:
POST - Description: Adds a new user to the system.
- Authentication: Bearer token and the role must be manage or admin
- Request Parameters:
username: The username of the user.password: The password of the user.role: The role of the user.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the user addition attempt.
11. Edit User
- Endpoint:
/api/admin/edit-user - Method:
PATCH - Description: Edits an existing user in the system.
- Authentication: Bearer token and the role must be manage or admin
- Request Parameters:
username: The username of the user.role: The new role of the user.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the user edit attempt.
12. Get Users
- Endpoint:
/api/admin/users - Method:
GET - Description: Retrieves a list of users from the system.
- Authentication: Bearer token
- Response:
status: The status of the request (success or error).users: An array of users with their details.
13. Reset user password
- Endpoint:
/api/admin/user/reset-password - Method:
POST - Description: Resets the password of a user in the system.
- Authentication: Bearer token
- Request Parameters:
username: The username of the user.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the password reset attempt.
14. Delete User
- Endpoint:
/api/admin/user/account - Method:
DELETE - Description: Deletes an existing user from the system.
- Authentication: Bearer token
- Request Parameters:
username: The username of the user to delete.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the user deletion attempt.
IV: Client Routes
1. Check Serial Registered
- Endpoint:
/api/client/check-registered/:serial - Method:
GET - Description: Checks if a serial number is already registered in the system.
- Authentication: None
- Response:
status: The status of the request (success or error).message: A message indicating the result of the check.
2. Register Serial
- Endpoint:
/api/client/register - Method:
POST - Description: Registers a serial number in the system.
- Authentication: None
- Request Parameters: The fields is configed at the Manage Registration Fields
- Response:
status: The status of the request (success or error).message: A message indicating the result of the registration attempt.
V. Config Routes
1. Get Company Config
- Endpoint:
/api/configs - Method:
GET - Description: Retrieves the company configuration from the system.
- Authentication: None
- Response:
status: The status of the request (success or error).configs: The company configuration.
2. Add Company
- Endpoint:
/api/configs/add - Method:
POST - Description: Adds a new company configuration to the system.
- Authentication: API Token (get from the secret key in environment variables file)
- Request Parameters:
name: The name of the company.clientsiteDomain: The domain of the client site.adminsiteDomain: The domain of the admin site.logo: The logo of the company.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the company addition attempt.
3. Delete Company
- Endpoint:
/api/configs/delete - Method:
DELETE - Description: Deletes an existing company configuration from the system.
- Authentication: API Token (get from the secret key in environment variables file)
- Request Parameters:
name: The name of the company to delete.adminSiteDomain: The domain of the admin site.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the company deletion attempt.
4. Update Company Config
- Endpoint:
/api/configs/update/:type/:name - Method:
PUT - Description: Updates an existing company configuration in the system.
- Authentication: API Token (get from the secret key in environment variables file)
- Request Parameters:
type: The type of configuration to update. Type list [LOGO, ADMIN-DOMAIN, CLIENT-DOMAIN, NAME, ADD-USER, REMOVE-USER, ADD-ASSETS, SET_ACTIVATION_REQUIRED_FIELD]name: The name of the company to update.value: The new value of the configuration.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the company update attempt.
5. Get Config Update Type
- Endpoint:
/api/configs/update - Method:
GET - Description: Retrieves the list of configuration update types from the system.
- Authentication: API Token (get from the secret key in environment variables file)
- Response:
status: The status of the request (success or error).types: An array of configuration update types.
6. Config on registration failed
- Endpoint:
/api/configs/on-registration-failed-config - Method:
GET - Description: Retrieves the configuration for handling failed registrations from the system.
- Authentication: Bearer token
- Request Parameters:
notify: Whether to notify the user on failed registration.email: The email address to notify as boolean.phone: The phone number to notify as boolean.
receiver: The email address or phone number to notify.email: The email address to notify as string.phone: The phone number to notify as string.
- Response:
status: The status of the request (success or error).config: The configuration for handling failed registrations.
7. Update account (SMS, Email, CRM)
- Endpoint:
/api/configs/account-config - Method:
PUT - Description: Updates the account configuration for SMS, Email, and CRM integration.
- Authentication: Bearer token
- Request Parameters:
sms: The configuration for SMS.provider: The SMS provider.authType: The authentication type.basicAuth: The basic authentication for the CRM integration.username: The username for basic authentication.password: The password for basic authentication.
bearerAuth: The bearer token for the CRM integration.token: The bearer token for the CRM integration.
apiKeyAuth: The API key for the CRM integration.key: The API key for the CRM integration.value: The value for the API key.addTo: Whether to add the API key to the body or header.
from: The sender of the SMS.useDefault: Whether the default SMS provider is used.
email: The configuration for Email.host: The email server hostname.user: The email address for sending emails.pass: The password for the email server.port: The port number for the email server.secure: Whether to use SSL/TLS for the email server.useDefault: Whether the default email is used.
crm: The configuration for CRM integration.host: The CRM integration server hostname.authType: The authentication type.host: The host server for the CRM integration.basicAuth: The basic authentication for the CRM integration.username: The username for basic authentication.password: The password for basic authentication.
bearerAuth: The bearer token for the CRM integration.token: The bearer token for the CRM integration.
apiKeyAuth: The API key for the CRM integration.key: The API key for the CRM integration.value: The value for the API key.addTo: Whether to add the API key to the body or header.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the account configuration update attempt.
8. Update notification template
- Endpoint:
/api/configs/templates-config - Method:
PUT - Description: Updates the notification template configuration for SMS and Email.
- Authentication: Bearer token
- Request Parameters:
sms: The SMS notification template.template: The template content for SMS.
email: The Email notification template.template: The template content for Email.
- Response:
status: The status of the request (success or error).message: A message indicating the result of the notification template update attempt.