diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 66ec5bb8..cc528822 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -595,4 +595,7 @@ $routes->post("retrieveWebhookDataClaim","ClientWebHooksController::pullData_cla //Third party Api Call -$routes->get('testCall','ICICILombardController::testCall'); \ No newline at end of file +$routes->get('generateAuthToken','ICICILombardController::generateAuthToken'); +$routes->get('createEnrollmentBatch','ICICILombardController::createEnrollmentBatch'); +$routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBatchStatus'); +$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails'); \ No newline at end of file diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 74a18bbe..383cb7bc 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -6,7 +6,7 @@ use CodeIgniter\Controller; class ICICILombardController extends AdminController { - public function generateAuthToken($scope) + public function generateAuthToken($scope = 'esbhealth') { helper('api'); @@ -26,10 +26,157 @@ class ICICILombardController extends AdminController $response = call_third_party_api($url, $method, $headers, $body); - if($response['status'] != false){ + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Token generation failed.', + 'data' => $response + ]); } + return $response; + } + + public function createEnrollmentBatch() + { + helper('api'); + + //fetch token + $tokenResponse = $this->generateAuthToken('esbgpabatchcreation'); + if (!$tokenResponse || empty($tokenResponse['data']['access_token'])) { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Token generation failed.', + 'data' => $tokenResponse + ]); + } + $token = $tokenResponse['data']['access_token']; + + + $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchcreation'; + $headers = [ + 'Authorization: Bearer ' . $token, + 'Content-Type: application/json' + ]; + + $body = [ + "PolicyNumber" => "4016/A/51974976/00/000", + "CDBGAccountNumber" => "CD-MUM-3344", + "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f", + "MemberDetails" => [ + [ + "EmployeeMemberId" => "EMPID3625556", + "DOJ" => "21-MAR-2019", + "InsuredName" => "ABC28144", + "DOB" => "7-JUL-1983", + "Relationship" => "SELF", + "Gender" => "MALE", + "DOC" => "20-JAN-2020", + "SumInsured" => "600000", + "EmailId" => "ABC@GMAIL.COM", + "FlagStatus" => "A" + ], + [ + "EmployeeMemberId" => "EMPID3625556", + "DOJ" => "21-MAR-2019", + "InsuredName" => "ABC28146", + "DOB" => "8-AUG-1970", + "Relationship" => "MOTHER", + "Gender" => "FEMALE", + "DOC" => "20-JAN-2020", + "SumInsured" => "600000", + "EmailId" => "ABC@GMAIL.COM", + "FlagStatus" => "A" + ], + [ + "EmployeeMemberId" => "EMPID0502220011", + "UHID" => "IL00688842553", + "InsuredName" => "ABC28142", + "DOB" => "8-SEP-1970", + "Gender" => "MALE", + "SumInsured" => "600000", + "EmailId" => "ABC@GMAIL.COM", + "FlagStatus" => "M" + ], + [ + "UHID" => "IL00688842552", + "DOL" => "20-JAN-2020", + "FlagStatus" => "D" + ] + ] + ]; + + $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); // true = raw body mode + return $this->response->setJSON($response); } + + public function getEnrollmentBatchStatus() + { + helper('api'); + + //fetch token + $tokenResponse = $this->generateAuthToken('esbgpabatchstatus'); + if (!$tokenResponse || empty($tokenResponse['data']['access_token'])) { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Token generation failed.', + 'data' => $tokenResponse + ]); + } + $token = $tokenResponse['data']['access_token']; + + + $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchstatus'; + $headers = [ + 'Authorization: Bearer ' . $token, + 'Content-Type: application/json' + ]; + + $body = [ + "PolicyNumber" => "4016/A/51974976/00/000", + "BatchId" => "2345617878", + "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f" + ]; + + $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); + + return $this->response->setJSON($response); + } + + public function fetchUHIDDetails() + { + helper('api'); + + //fetch token + $tokenResponse = $this->generateAuthToken('esbgpauhid'); + if (!$tokenResponse || empty($tokenResponse['data']['access_token'])) { + return $this->response->setJSON([ + 'status' => false, + 'message' => 'Token generation failed.', + 'data' => $tokenResponse + ]); + } + $token = $tokenResponse['data']['access_token']; + + $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/fetchuhid'; + $headers = [ + 'Authorization: Bearer ' . $token, + 'Content-Type: application/json' + ]; + + $body = [ + "PolicyNumber" => "4016/A/51974976/00/000", + "IMID" => "2345617878", + "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f" + ]; + + $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); + + return $this->response->setJSON($response); + } + + + } diff --git a/app/Helpers/api_helper.php b/app/Helpers/api_helper.php index 7dd13bd7..de9a0b64 100644 --- a/app/Helpers/api_helper.php +++ b/app/Helpers/api_helper.php @@ -16,13 +16,11 @@ if (!function_exists('call_third_party_api')) { } } - // return $contentType; // echo '
';
// print_r($headers);
// print_r($body);
// die;
-
// Setup curl options
$options = [
CURLOPT_URL => $url,
@@ -50,7 +48,7 @@ if (!function_exists('call_third_party_api')) {
$response = curl_exec($ch);
$error = curl_error($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
+
curl_close($ch);
if ($error) {