nhance/get-client-rm-api.md
2026-06-24 18:03:10 +05:30

212 lines
3.7 KiB
Markdown

# Get Client RM API
Returns Level 1 (Account Manager) and Level 2 (Head) contact details for a client.
**Controller:** `EmployeeRestController::getClientRM`
**Method:** `GET`
---
## Endpoint
```
GET /employeeRest/getClientRM
```
---
## Authentication
**JWT token is required.** This endpoint is available only in the authenticated route group.
| Filter | Description |
|--------|-------------|
| `ratelimit` | Rate limiting |
| `appSignature` | App signature validation |
| `authJWT` | JWT token validation |
### Required Headers
| Header | Required | Description |
|--------|----------|-------------|
| `App-Signature` | Yes | Must match server `APP_SIGNATURE` from `.env` |
| `Authorization` | Yes | JWT token in format `Bearer <token>` |
### Example Headers
```
App-Signature: <your_app_signature>
Authorization: Bearer <jwt_token>
```
---
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `client_id` | string | Yes | MD5 hash of the client ID (32-character hex string) |
### Example Request
```
GET /employeeRest/getClientRM?client_id=5d41402abc4b2a76b9719d911017c592
```
**Note:** Pass the MD5 hash of the numeric client ID, not the raw client ID.
Example:
```
MD5(123) = 202cb962ac59075b964b07152d234b70
```
```
GET /employeeRest/getClientRM?client_id=202cb962ac59075b964b07152d234b70
```
---
## Success Response
**HTTP Status:** `200`
```json
{
"status": "success",
"code": 200,
"data": {
"level_1": [
{
"first_name": "John",
"email": "john@example.com",
"mobile": "9876543210"
}
],
"level_2": [
{
"first_name": "Jane",
"email": "jane@example.com",
"mobile": "9123456789"
}
]
}
}
```
---
## Response Fields
| Key | Type | Description |
|-----|------|-------------|
| `status` | string | `success` or `failed` |
| `code` | integer | Response code |
| `data.level_1` | array | Account Manager contact list |
| `data.level_2` | array | Head contact list |
| `first_name` | string | RM name |
| `email` | string | RM email |
| `mobile` | string | RM mobile number |
If no RM is assigned for a level, the corresponding array will be empty (`[]`).
---
## Level Mapping
| Response Key | Role | `client_rm.level` in DB |
|--------------|------|-------------------------|
| `level_1` | Account Manager | `3` |
| `level_2` | Head | `1` |
**Notes:**
- Only active records are returned (`client_rm.is_active = 1`).
- Manager (DB level `2`) is not included in this API.
- `level_1` can contain multiple Account Managers.
---
## Error Responses
### Missing `client_id`
**HTTP Status:** `200`
```json
{
"status": "failed",
"code": 400,
"message": "client_id is required"
}
```
### Missing Token
**HTTP Status:** `403`
```json
{
"status": 403,
"message": "Access Forbidden"
}
```
### Invalid or Expired Token
**HTTP Status:** `401`
```json
{
"status": 401,
"message": "Token is Invalid"
}
```
```json
{
"status": 401,
"message": "Token expired"
}
```
### Invalid App Signature
**HTTP Status:** `403`
```json
{
"status": false,
"message": "Forbidden: Invalid App Signature"
}
```
### Server Error
**HTTP Status:** `500`
```json
{
"status": "failed",
"code": 500,
"data": "Error message"
}
```
---
## Route Registration
Defined in `app/Config/Routes.php` (authenticated group only):
```php
$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratelimit', 'appSignature', 'authJWT']], function ($routes) {
$routes->get("getClientRM", "EmployeeRestController::getClientRM");
});
```
---
## Source
Implementation: `app/Controllers/EmployeeRestController.php``getClientRM()`