GWM : API rate filter added
This commit is contained in:
parent
3e575a9f3c
commit
b0e035dd0d
@ -19,6 +19,7 @@ use App\Filters\Cors;
|
||||
use App\Filters\SecurityInputFilter;
|
||||
use App\Filters\GlobalPostFileUploadGuard;
|
||||
use App\Filters\AclFilter;
|
||||
use App\Filters\RateLimitFilter;
|
||||
|
||||
use App\Filters\AuthJWT;
|
||||
|
||||
@ -49,6 +50,8 @@ class Filters extends BaseConfig
|
||||
'SecurityInputFilter' => SecurityInputFilter::class,
|
||||
'GlobalPostFileUploadGuard' => GlobalPostFileUploadGuard::class,
|
||||
'AclFilter' => AclFilter::class,
|
||||
'ratelimit' => RateLimitFilter::class,
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -546,7 +546,7 @@ $routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
|
||||
|
||||
|
||||
//api
|
||||
$routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->group("/api", ["filter" => [ 'ratelimit' , 'authJWT']], function ($routes) {
|
||||
$routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type");
|
||||
$routes->post("logined", "RestAuthenticationController::logined");
|
||||
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
|
||||
@ -557,7 +557,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl");
|
||||
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
|
||||
|
||||
$routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) {
|
||||
$routes->group("employeeRest", ['filter' => ['ratelimit' , 'appSignature'] ], function ($routes) {
|
||||
|
||||
//Employee login api's
|
||||
$routes->post("verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
|
||||
@ -600,7 +600,7 @@ $routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($route
|
||||
|
||||
});
|
||||
|
||||
$routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], function ($routes) {
|
||||
$routes->group("employeeRest", ["filter" => [ 'ratelimit' , 'appSignature' , 'authJWT']], function ($routes) {
|
||||
|
||||
$routes->post('logout', 'RestAuthenticationController::logout');
|
||||
|
||||
@ -663,7 +663,7 @@ $routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], funct
|
||||
$routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType');
|
||||
|
||||
//this route for nhance website contact form (sales/service)
|
||||
$routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) {
|
||||
$routes->group("employeeRest", ['filter' => ['ratelimit' , 'appSignature'] ], function ($routes) {
|
||||
$routes->post("ticketSave", "ThzController::ticketSave");
|
||||
});
|
||||
|
||||
@ -777,7 +777,7 @@ $routes->get('EcardRequest','FhplApiController::EcardRequest');
|
||||
$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork');
|
||||
$routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails');
|
||||
$routes->get('ClaimDetail','FhplApiController::ClaimDetail');
|
||||
$routes->get('SubmitClaim','VidalApiController::SubmitClaim');
|
||||
$routes->get('SubmitClaim','HealthIndiaApiController::SubmitClaim');
|
||||
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
|
||||
$routes->get('IRSubmission','MediAssistApiController::IRSubmission');
|
||||
$routes->get('ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
|
||||
|
||||
@ -28,6 +28,7 @@ class ApiServiceController extends BaseController
|
||||
protected $vidal_primary_key;
|
||||
protected $icici_primary_key;
|
||||
protected $fhpl_primary_key;
|
||||
protected $health_india_primary_key;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -37,6 +38,7 @@ class ApiServiceController extends BaseController
|
||||
$this->vidal_primary_key = getenv('VIDAL_PRIMARY_KEY_CONSTANT');
|
||||
$this->icici_primary_key = getenv('ICICI_PRIMARY_KEY_CONSTANT');
|
||||
$this->fhpl_primary_key = getenv('FHPL_PRIMARY_KEY_CONSTANT');
|
||||
$this->health_india_primary_key = getenv('HEALTH_INDIA_PRIMARY_KEY_CONSTANT');
|
||||
}
|
||||
|
||||
// Push Claims
|
||||
|
||||
@ -35,14 +35,18 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_USERPWD => $username . ':' . $password,
|
||||
CURLOPT_POSTFIELDS => '{}',
|
||||
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic ' . base64_encode($username . ':' . $password),
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
],
|
||||
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
@ -75,7 +79,7 @@ class HealthIndiaApiController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
public function SubmitClaim($claimId = null)
|
||||
public function SubmitClaim($claimId = 515)
|
||||
{
|
||||
helper('api');
|
||||
|
||||
@ -88,16 +92,19 @@ class HealthIndiaApiController extends BaseController
|
||||
tm.emp_mail as emailId,
|
||||
tm.doa as admissionDate,
|
||||
tm.dod as dischargeDate,
|
||||
tm.hospital_pin_code as hospitalCode,
|
||||
tm.hospital_name as hospitalName,
|
||||
tm.hospital_address as hospitalAddress,
|
||||
tm.hospital_phone_no as hospitalNumber,
|
||||
tm.claim_amount as claimedAmount,
|
||||
tm.tpa_no as memberId,
|
||||
tm.ailment as ailmentDescription,
|
||||
tm.claim_description as ailmentDescription,
|
||||
cp.policy_no as policyNumber,
|
||||
e.emp_code as employeeCode,
|
||||
tn.note as disease,
|
||||
cf.url as filePath,
|
||||
tm.claim_type as claimType,
|
||||
tm.claim_category as benefitType
|
||||
tm.claim_type as benefitType
|
||||
')
|
||||
->join('employees e', 'e.id = tm.emp_id', 'left')
|
||||
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
||||
@ -107,6 +114,8 @@ class HealthIndiaApiController extends BaseController
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
// dd($data);
|
||||
|
||||
if (!$data) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - Claim not found");
|
||||
return;
|
||||
@ -161,13 +170,30 @@ class HealthIndiaApiController extends BaseController
|
||||
"claimeD_AMOUNT" => (string) $data['claimedAmount'],
|
||||
"datE_OF_ADMISSION" => date('Y-m-d', strtotime($data['admissionDate'])),
|
||||
"ailmenT_DESCRIPTION" => $data['ailmentDescription'] ?? 'NA',
|
||||
"hospitaL_CODE" => "", // Not available in your data
|
||||
"hospitaL_CODE" => $data['hospitalCode'] ?? '',
|
||||
"hospitaL_NAME" => $data['hospitalName'] ?? '',
|
||||
"hospitaL_ADDRESS" => "", // Not available
|
||||
"hospitaL_NUMBER" => "", // Not available
|
||||
"hospitaL_ADDRESS" => $data['hospitalAddress'] ?? '',
|
||||
"hospitaL_NUMBER" => $data['hospitalNumber'] ?? '',
|
||||
"pdF_BYTES" => [$fileContent]
|
||||
];
|
||||
|
||||
// $body = [
|
||||
// 'policY_NUMBER' => '141600_POLICY_AWAITED',
|
||||
// 'employeE_CODE' => 'DECP000',
|
||||
// 'membeR_ID' => '10662420SE',
|
||||
// 'claiM_TYPE' => 'Reimbursement',
|
||||
// 'benefiT_TYPE' => 'IPD',
|
||||
// 'claimeD_AMOUNT' => '102',
|
||||
// 'datE_OF_ADMISSION' => '2026-01-19',
|
||||
// 'ailmenT_DESCRIPTION' => 'Fever',
|
||||
// 'hospitaL_CODE' => '100900',
|
||||
// 'hospitaL_NAME' => 'Test',
|
||||
// 'hospitaL_ADDRESS' => 'YEst',
|
||||
// 'hospitaL_NUMBER' => '2233445566',
|
||||
// "pdF_BYTES" => [$fileContent]
|
||||
// ];
|
||||
|
||||
|
||||
$url = getenv('HEALTH_INDIA_BASE_URL') . "/Intimation/GetClaimIntimation";
|
||||
|
||||
$headers = [
|
||||
@ -175,10 +201,12 @@ class HealthIndiaApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | claimId: ' . $claimId . ' | URL: ' . $url . ' | payload: ' . json_encode($body));
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | claimId: ' . $claimId . ' | URL: ' . $url );
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
dd($response);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA RESPONSE | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
|
||||
if ($response['status'] != true) {
|
||||
@ -89,29 +89,28 @@ class ICICILombardController extends AdminController
|
||||
$body = [
|
||||
"PolicyNumber" => "4016/PPN/A/O/53167743/00/000",
|
||||
"CDBGAccountNumber" => "CD-MUM-0026",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440012",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440014",
|
||||
"MemberDetails" => [
|
||||
[
|
||||
"MemberEmpId" => "EMPID3625559",
|
||||
"MemberEmpId" => "EMPID3625560",
|
||||
"DOJ" => "21-MAR-2019",
|
||||
"InsuredName" => "Gowtham",
|
||||
"DOB" => "7-JUL-1993",
|
||||
"Relationship" => "SELF",
|
||||
"Gender" => "MALE",
|
||||
"DOC" => '2025-10-27',
|
||||
"SumInsured" => "400000",
|
||||
"SumInsured" => "500000",
|
||||
"EmailId" => "Gowtham@GMAIL.COM",
|
||||
"FlagStatus" => "A"
|
||||
],
|
||||
[
|
||||
"MemberEmpId" => "EMPID3625559",
|
||||
"MemberEmpId" => "EMPID3625560",
|
||||
"DOJ" => "21-MAR-2019",
|
||||
"InsuredName" => "Lavanya",
|
||||
"DOB" => "8-AUG-1970",
|
||||
"Relationship" => "MOTHER",
|
||||
"Gender" => "FEMALE",
|
||||
"DOC" => '2025-10-27',
|
||||
"SumInsured" => "400000",
|
||||
"EmailId" => "Lavanya@GMAIL.COM",
|
||||
"FlagStatus" => "A"
|
||||
],
|
||||
@ -149,8 +148,8 @@ class ICICILombardController extends AdminController
|
||||
|
||||
$body = [
|
||||
"PolicyNumber" => "4016/PPN/A/O/53167743/00/000",
|
||||
"BatchId" => "3672146",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440012"
|
||||
"BatchId" => "3723144",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440014"
|
||||
];
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body, true);
|
||||
@ -181,10 +180,10 @@ class ICICILombardController extends AdminController
|
||||
'Content-Type: application/json'
|
||||
];
|
||||
|
||||
$body = [
|
||||
$body = [
|
||||
"PolicyNumber" => "4016/PPN/A/O/53167743/00/000",
|
||||
"IMID" => "3672145",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440011"
|
||||
"IMID" => "201580517901",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440014"
|
||||
];
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body, true);
|
||||
|
||||
34
app/Filters/RateLimitFilter.php
Normal file
34
app/Filters/RateLimitFilter.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
|
||||
class RateLimitFilter implements FilterInterface
|
||||
{
|
||||
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$throttler = service('throttler');
|
||||
|
||||
// sanitize IP for cache
|
||||
$key = preg_replace('/[^a-zA-Z0-9_]/', '_', $request->getIPAddress());
|
||||
|
||||
if ($throttler->check($key, 25, MINUTE) === false) {
|
||||
return service('response')
|
||||
->setStatusCode(429)
|
||||
->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Too many requests. Try again later.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user