Merge branch 'dev' of bitbucket.org:jubilian/nhance-enrollment into dev
This commit is contained in:
commit
4eccdbdcec
@ -1774,53 +1774,28 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
public function getClientDetails()
|
||||
{
|
||||
log_message('error', 'STEP 1: getClientDetails called');
|
||||
|
||||
try {
|
||||
// STEP 2: Extract Authorization header
|
||||
$jwt = $this->request->getHeaderLine('Authorization');
|
||||
log_message('error', 'STEP 2: Authorization header: ' . $jwt);
|
||||
$pre_client_id = $this->request->getGet('pre_client_id');
|
||||
$pre_branch_id = $this->request->getGet('pre_branch_id');
|
||||
$post_client_id = $this->request->getGet('post_client_id');
|
||||
$post_branch_id = $this->request->getGet('post_branch_id');
|
||||
|
||||
|
||||
$jwtParts = explode(' ', $jwt);
|
||||
if (count($jwtParts) < 2) {
|
||||
log_message('error', 'STEP 2.1: Invalid Authorization header format');
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Invalid Authorization header'], 400);
|
||||
}
|
||||
if ($pre_client_id != null) {
|
||||
|
||||
|
||||
$token = $jwtParts[1];
|
||||
log_message('error', 'STEP 3: Extracted JWT token');
|
||||
|
||||
$tokenParts = explode('.', $token);
|
||||
if (count($tokenParts) !== 3) {
|
||||
log_message('error', 'STEP 3.1: Invalid JWT structure');
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Invalid JWT token'], 400);
|
||||
}
|
||||
|
||||
$decodedPayload = json_decode(base64_decode($tokenParts[1]), true);
|
||||
log_message('error', 'STEP 4: Decoded JWT payload: ' . json_encode($decodedPayload));
|
||||
|
||||
$token_type = $decodedPayload['token_type'] ?? null;
|
||||
log_message('error', 'STEP 5: Token type = ' . $token_type);
|
||||
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||
log_message('error', 'STEP 6: Query params - client_id: ' . $client_id . ', client_branch_id: ' . $client_branch_id);
|
||||
|
||||
if ($token_type === 'pre') {
|
||||
log_message('error', 'STEP 7: Handling "pre" token type');
|
||||
|
||||
$client = $this->clientModel->where('id', $client_id)->first();
|
||||
$client = $this->clientModel->where('id', $pre_client_id)->first();
|
||||
if ($client) {
|
||||
log_message('error', 'STEP 8: Found client: ' . json_encode($client));
|
||||
|
||||
|
||||
$client['client_logo'] = base_url() . 'public/uploads/logo/' . $client['client_logo'];
|
||||
|
||||
$clientPolicy = $this->clientPolicyModel
|
||||
->where('client_id', $client_id)
|
||||
->where('client_branch_id', $client_branch_id)
|
||||
->where('client_id', $pre_client_id)
|
||||
->where('client_branch_id', $pre_branch_id)
|
||||
->findAll();
|
||||
|
||||
log_message('error', 'STEP 9: Found client policy count: ' . count($clientPolicy));
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
@ -1831,33 +1806,34 @@ class EmployeeRestController extends AdminController
|
||||
]
|
||||
], 200);
|
||||
} else {
|
||||
log_message('error', 'STEP 10: No client found for client_id: ' . $client_id);
|
||||
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404);
|
||||
}
|
||||
} elseif ($token_type === 'post') {
|
||||
log_message('error', 'STEP 11: Handling "post" token type');
|
||||
} elseif ($post_client_id != null) {
|
||||
|
||||
|
||||
$restAuthController = new RestAuthenticationController;
|
||||
|
||||
$queryParams = [
|
||||
'client_id' => $client_id,
|
||||
'client_branch_id' => $client_branch_id
|
||||
'client_id' => $post_client_id,
|
||||
'client_branch_id' => $post_branch_id
|
||||
];
|
||||
|
||||
log_message('error', 'STEP 12: Calling post enrollment API with params: ' . json_encode($queryParams));
|
||||
return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
|
||||
|
||||
return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails', ['token' => $jwt]);
|
||||
} else {
|
||||
log_message('error', 'STEP 13: Unknown token_type: ' . $token_type);
|
||||
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'STEP 14: Exception occurred - ' . $e->getMessage());
|
||||
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getSiMappedArray($policy_id,$base_policy_id)
|
||||
{
|
||||
$selfGMC = $this->employeeModel->select('employees.name , employee_polices.basic_cover_si')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user