API Calls Documentation
Table of Contents
Introduction
An overview of the API calls that we make in the app and its purpose. The API url is : https://demo-ecs.phpreaction.com/open-api/v3 The API Doc : https://phpreaction.com/utilisation-apiv4-phpreaction/
All external API calls go through the /api/callOut route which acts as a proxy to the external API.
External API Endpoints
Products
open-api/v3/products/{id}/
- Description: Get a product by ID.
- Method:
GET - Used in:
src/hooks/useProducts.tsx-getProductById() - Parameters:
- Query:
_locale(e.g.,fr_CA,en_CA)
- Query:
- Role:
ROLE_MOD_PRODUCT_SHOW
open-api/v3/products/by_sku/{sku}/inventory
- Description: Get a product by SKU.
- Method:
GET - Used in:
src/hooks/useProducts.tsx-getProductBySku() - Parameters:
- Query:
_locale(e.g.,fr_CA,en_CA) - Body:
userId
- Query:
- Role:
ROLE_MOD_PRODUCT_SHOW
open-api/v3/products/dropdown/get/
- Description: Get products for a dropdown/search functionality.
- Method:
GET - Used in:
src/hooks/useProducts.tsx-getProductBySearch() - Parameters:
- Query/Filter:
page: Page numberitemsPerPage: Items per page (e.g., 30)countedInInventory: Boolean filtersearch: Search term_locale: Locale (e.g.,fr_CA,en_CA)
- Body:
userId
- Query/Filter:
- Role:
ROLE_MOD_PRODUCT_DROPDOWN
Inventory Entries
open-api/v3/inventory_entries/
- Description: Create an inventory entry (adjustment or confirmation).
- Method:
POST - Used in:
src/hooks/useProducts.tsx-adjustQuantity() - Request Body:
{
"number": "quantity_adjustment",
"product": "/open-api/v3/products/{product_id}",
"description": "Transaction description (e.g., 'Adjustment' or 'Confirmation')",
"person": "/open-api/v3/people/1"
}- Role:
ROLE_MOD_INVENTORY_ENTRY_ADD
Key-Value Store
open-api/v3/keyvaluestore_keyvalues?user={user_id}
- Description: Get all key-value store entries for a specific user.
- Method:
GET - Used in:
src/contexts/KVSContext.tsx-getUserKVS() - Role:
ROLE_MOD_KEYVALUESTORE_KEYVALUE_LISTING
open-api/v3/keyvaluestore_keyvalues
- Description: Create a new key-value store entry.
- Method:
POST - Used in:
src/contexts/KVSContext.tsx-createKVS() - Request Body:
{
"key": "key_name",
"value": "value_string",
"user": "/open-api/v3/users/{user_id}",
"clearanceLevel": 7
}- Role:
ROLE_MOD_KEYVALUESTORE_KEYVALUE_ADD
open-api/v3/keyvaluestore_keyvalues?key={key}
- Description: Get a specific key-value store entry by key.
- Method:
GET - Used in:
src/contexts/KVSContext.tsx-getSpecificKVS() - Role:
ROLE_MOD_KEYVALUESTORE_KEYVALUE_LISTING
Generic Entity Endpoints
open-api/v3/{entity}/
- Description: Generic endpoint for fetching entities dynamically (used by combobox components).
- Method:
GET - Used in:
src/contexts/ComboBoxContext.tsx-fetchOptions() - Parameters:
- Filter: JSON string with pagination and filters
{ "page": 1, "range": 25, "enabled": true } - Body:
userId
- Filter: JSON string with pagination and filters
Internal API Routes
These are Next.js API routes that serve as endpoints within the application or proxy to external services.
/api/callOut
- Description: Proxy route for all external API calls. Handles GET, POST, and PUT requests.
- Methods:
GET,POST,PUT - Location:
src/app/api/callOut/route.ts - Usage: All
CallAPI()calls go through this route
Status Routes
/api/status
- Description: Get basic status information.
- Method:
GET - Location:
src/app/api/status/route.ts - Returns:
{status: 'ok'}
/api/status/all
- Description: Get comprehensive status information including app info, API status, configs, cache, and user token.
- Method:
GET - Location:
src/app/api/status/all/route.ts - Returns: Complete status information with app name, version, NextJS version, React version, etc.
/api/status/api
- Description: Get the status of the external API connection.
- Method:
GET - Location:
src/app/api/status/api/route.ts
/api/status/configs
- Description: Get the status of configuration services.
- Method:
GET - Location:
src/app/api/status/configs/route.ts - Returns: Configuration status including whether config API login is available
/api/status/cache
- Description: Get the status of cache tables (AppCache and ConfigCache).
- Method:
GET - Location:
src/app/api/status/cache/route.ts - Returns: Cache status including table status, item count, creation date/time
/api/status/user-token/check
- Description: Validate and check the user token.
- Method:
GET - Location:
src/app/api/status/user-token/check/route.ts - Authentication: Reads token from
currentUsercookie
/api/status/user-token/display
- Description: Get user token display information.
- Method:
GET - Location:
src/app/api/status/user-token/display/route.ts - Authentication: Reads token from
currentUsercookie
/api/status/user-token/expected
- Description: Get expected user token information.
- Method:
GET - Location:
src/app/api/status/user-token/expected/route.ts
Authentication Routes
/api/oauth/authorize
- Description: Initiate OAuth 2.0 authorization code flow.
- Method:
GET - Location:
src/app/api/oauth/authorize/route.ts - Flow: Authorization Code Flow (OAuth 2.0)
/api/oauth/callback
- Description: Handle OAuth 2.0 callback after authorization.
- Method:
GET - Location:
src/app/api/oauth/callback/route.ts
/api/logout
- Description: Handle user logout.
- Method:
GET - Location:
src/app/api/logout/route.ts
/api/config-login
- Description: Handle configuration-based login.
- Method:
POST - Location:
src/app/api/config-login/route.ts
Cache Management
/api/clear-cache
- Description: Clear all cache tables (requires ROLE_ADMIN).
- Method:
DELETE - Location:
src/app/api/clear-cache/route.ts - Authorization: Requires
ROLE_ADMINrole - Actions: Deletes all entries from AppCache and ConfigCache tables
Last updated on