FEAT_HR_HELP_API
This commit is contained in:
parent
2ec49e3e7e
commit
ad9e658a9b
@ -726,6 +726,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel
|
|||||||
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
|
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
|
||||||
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
|
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
|
||||||
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
|
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
|
||||||
|
$routes->get("getClientRM", "EmployeeRestController::getClientRM");
|
||||||
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
|
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
|
||||||
$routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
|
$routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
|
||||||
$routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId");
|
$routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId");
|
||||||
|
|||||||
@ -1643,6 +1643,53 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getClientRM()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
|
||||||
|
if (empty($client_id)) {
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'client_id is required'], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
$clientRmRecords = $this->clientRMModel
|
||||||
|
->select('client_rm.level, user_profiles.first_name, user_profiles.email, user_profiles.mobile')
|
||||||
|
->join('user_profiles', 'user_profiles.id = client_rm.user_id')
|
||||||
|
->where('md5(client_rm.client_id)', $client_id)
|
||||||
|
->where('client_rm.is_active', 1)
|
||||||
|
->whereIn('client_rm.level', [1, 3])
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
$level_1 = [];
|
||||||
|
$level_2 = [];
|
||||||
|
|
||||||
|
foreach ($clientRmRecords as $record) {
|
||||||
|
$user = [
|
||||||
|
'first_name' => $record['first_name'],
|
||||||
|
'email' => $record['email'],
|
||||||
|
'mobile' => $record['mobile'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ((int) $record['level'] === 3) {
|
||||||
|
$level_1[] = $user;
|
||||||
|
} else {
|
||||||
|
$level_2[] = $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'success',
|
||||||
|
'code' => 200,
|
||||||
|
'data' => [
|
||||||
|
'level_1' => $level_1,
|
||||||
|
'level_2' => $level_2,
|
||||||
|
],
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getAddOnPolicy()
|
public function getAddOnPolicy()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
211
get-client-rm-api.md
Normal file
211
get-client-rm-api.md
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
# 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()`
|
||||||
Loading…
Reference in New Issue
Block a user