FEAT_E_CARD_MAIL_SEND_OPTION_FOR_HR
This commit is contained in:
parent
d0e29cc5ac
commit
8718004f06
@ -737,6 +737,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel
|
||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||
$routes->get("getEcardURL", "EmployeeRestController::getEcardURL");
|
||||
$routes->post("sendMailForIndividualEmployeeEcard", "EmployeeRestController::sendMailForIndividualEmployeeEcard");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -5904,4 +5904,30 @@ class EmployeeRestController extends AdminController
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function sendMailForIndividualEmployeeEcard()
|
||||
{
|
||||
$received_data = $this->request->getJSON(true) ?? [];
|
||||
|
||||
$id = $received_data['emp_policy_id'] ?? null;
|
||||
$client_policy_id = $received_data['client_policy_id'] ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'emp_policy_id is required'], 200);
|
||||
}
|
||||
|
||||
if (empty($client_policy_id)) {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'client_policy_id is required'], 200);
|
||||
}
|
||||
|
||||
$ids[] = $id;
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
$result = $empDataServiceController->sendMailForDownloadingECard(['ids' => $ids, 'client_policy_id' => $client_policy_id], 1);
|
||||
|
||||
if (isset($result['status']) && $result['status'] == true) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail sent successfully', 'result' => $result], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to sent mail.', 'result' => $result], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
180
send-mail-individual-employee-ecard-api.md
Normal file
180
send-mail-individual-employee-ecard-api.md
Normal file
@ -0,0 +1,180 @@
|
||||
# Send Individual Employee E-Card Mail API
|
||||
|
||||
Sends the E-Card download mail to a single employee (Self relationship only).
|
||||
|
||||
**Controller:** `EmployeeRestController::sendMailForIndividualEmployeeEcard`
|
||||
**Method:** `POST`
|
||||
|
||||
---
|
||||
|
||||
## Endpoint
|
||||
|
||||
```
|
||||
POST /employeeRest/sendMailForIndividualEmployeeEcard
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Authentication
|
||||
|
||||
**JWT token is required.** This endpoint is available only in the authenticated route group.
|
||||
|
||||
| Filter | Description |
|
||||
|--------|-------------|
|
||||
| `GlobalPostFileUploadGuard` | POST upload guard |
|
||||
| `ratelimit` | Rate limiting |
|
||||
| `appSignature` | App signature validation |
|
||||
| `authJWT` | JWT token validation |
|
||||
|
||||
### Required Headers
|
||||
|
||||
| Header | Required | Description |
|
||||
|--------|----------|-------------|
|
||||
| `Content-Type` | Yes | `application/json` |
|
||||
| `App-Signature` | Yes | Must match server `APP_SIGNATURE` from `.env` |
|
||||
| `Authorization` | Yes | JWT token in format `Bearer <token>` |
|
||||
|
||||
### Example Headers
|
||||
|
||||
```
|
||||
Content-Type: application/json
|
||||
App-Signature: <your_app_signature>
|
||||
Authorization: Bearer <jwt_token>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Request Body (JSON)
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `emp_policy_id` | integer | Yes | Employee policy ID (`employee_polices.id`) |
|
||||
| `client_policy_id` | integer | Yes | Client policy ID |
|
||||
|
||||
### Example Request
|
||||
|
||||
```json
|
||||
{
|
||||
"emp_policy_id": 12345,
|
||||
"client_policy_id": 678
|
||||
}
|
||||
```
|
||||
|
||||
### cURL Example
|
||||
|
||||
```bash
|
||||
curl -X POST "https://<base_url>/employeeRest/sendMailForIndividualEmployeeEcard" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "App-Signature: <your_app_signature>" \
|
||||
-H "Authorization: Bearer <jwt_token>" \
|
||||
-d '{
|
||||
"emp_policy_id": 12345,
|
||||
"client_policy_id": 678
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Success Response
|
||||
|
||||
**HTTP Status:** `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": true,
|
||||
"code": 200,
|
||||
"message": "Mail sent successfully",
|
||||
"result": {}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Responses
|
||||
|
||||
### Missing `emp_policy_id`
|
||||
|
||||
**HTTP Status:** `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": false,
|
||||
"code": 404,
|
||||
"message": "emp_policy_id is required"
|
||||
}
|
||||
```
|
||||
|
||||
### Missing `client_policy_id`
|
||||
|
||||
**HTTP Status:** `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": false,
|
||||
"code": 404,
|
||||
"message": "client_policy_id is required"
|
||||
}
|
||||
```
|
||||
|
||||
### Mail Send Failed
|
||||
|
||||
**HTTP Status:** `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": false,
|
||||
"code": 404,
|
||||
"message": "Failed to sent mail.",
|
||||
"result": {}
|
||||
}
|
||||
```
|
||||
|
||||
### Missing / Invalid Token
|
||||
|
||||
**HTTP Status:** `401` or `403`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 401,
|
||||
"message": "Token is Invalid"
|
||||
}
|
||||
```
|
||||
|
||||
### Invalid App Signature
|
||||
|
||||
**HTTP Status:** `403`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": false,
|
||||
"message": "Forbidden: Invalid App Signature"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
- `emp_policy_id` is the **employee policy record ID**, not the employee master ID.
|
||||
- Mail is sent only when E-Card notification is enabled for the client.
|
||||
- Employee must be active with a valid corporate email and TPA ID.
|
||||
- This API uses the same logic as `EmployeeController::send_mail_for_individual_employee_ecard`.
|
||||
|
||||
---
|
||||
|
||||
## Route Registration
|
||||
|
||||
Defined in `app/Config/Routes.php`:
|
||||
|
||||
```php
|
||||
$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratelimit', 'appSignature', 'authJWT']], function ($routes) {
|
||||
$routes->post("sendMailForIndividualEmployeeEcard", "EmployeeRestController::sendMailForIndividualEmployeeEcard");
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Source
|
||||
|
||||
Implementation: `app/Controllers/EmployeeRestController.php` → `sendMailForIndividualEmployeeEcard()`
|
||||
Service: `app/Controllers/EmpDataServiceController.php` → `sendMailForDownloadingECard()`
|
||||
Loading…
Reference in New Issue
Block a user