CHANGE : Post enroll ment api call : GWM

This commit is contained in:
Gowtham M 2025-02-20 16:33:37 +05:30
parent 6858e77c94
commit ff74db6f26

View File

@ -64,6 +64,14 @@ class RestAuthenticationController extends AdminController
echo "Rest Authentication Logined Success........";
}
private function callThirdPartyAPI($postData , $endPoint)
{
$client = \Config\Services::curlrequest();
$url = env('POST_ENROLLMENT_BASEURL').$endPoint;
$response = $client->post( $url, ['json' => $postData, 'http_errors' => false ] );
return json_decode($response->getBody(), true);
}
@ -86,8 +94,11 @@ class RestAuthenticationController extends AdminController
$result = ['user_verification' => true ,'message' => "Verified Successfully" ];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
$result = ['user_verification' => false , 'message' => "User not found"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
// Call the third-party API function
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeNumber');
// $result = ['user_verification' => false , 'message' => "User not found"];
// return $this->respond(['status' => 'failed','code' => 404,'data' => $result, 'post_enrollment'=> $apiResponse],200);
}
} catch (\Throwable $th) {
@ -147,8 +158,11 @@ class RestAuthenticationController extends AdminController
} else {
$result = ['user_verification' => false , 'message' => "User not found"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
// Call the third-party API function
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId');
// $result = ['user_verification' => false , 'message' => "User not found"];
// return $this->respond(['status' => 'failed','code' => 404,'data' => $result, 'post_enrollment'=> $apiResponse],200);
}
} catch (\Throwable $th) {
@ -156,20 +170,6 @@ class RestAuthenticationController extends AdminController
}
}
private function callThirdPartyAPI($postData)
{
$client = \Config\Services::curlrequest();
$thirdPartyUrl = "https://venbait.in/nhance/dev/employeeRest/getVerifiedUserData";
$response = $client->post($thirdPartyUrl, [
'json' => $postData, // Sending JSON body
'http_errors' => false // Prevent errors from stopping execution
]);
return json_decode($response->getBody(), true);
}
public function getVerifiedUserData()
{
try {
@ -193,7 +193,8 @@ class RestAuthenticationController extends AdminController
}
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr) || $employeeData && isset($this->request->getJSON()->otp) ) {
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr) || $employeeData && isset($this->request->getJSON()->otp) )
{
$auth = HttpRequestHelper::getRequestInfo();
if ($auth) {
$data = [
@ -208,16 +209,21 @@ class RestAuthenticationController extends AdminController
$result = JWTToken::encode($employeeData);
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON());
if(isset($this->request->getJSON()->otp)){
$this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update();
}
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'getVerifiedUserData');
return $this->respond(['status' => 'success','code' => 200,'data' => $result , 'post_enrollment'=> $apiResponse],200);
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'getVerifiedUserData');
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP" , 'post_enrollment'=> $apiResponse],200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
@ -416,12 +422,14 @@ class RestAuthenticationController extends AdminController
}
$result = JWTToken::encode($employeeData);
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'verifyMpin');
return $this->respond(['status' => 'success','code' => 200,'data' => $result , 'post_enrollment'=> $apiResponse],200);
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
// Call the third-party API function
$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'getVerifiedUserData');
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP", 'post_enrollment'=> $apiResponse],200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
@ -433,7 +441,6 @@ class RestAuthenticationController extends AdminController
try {
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
$mpin = $this->request->getJSON()->mpin;
if (isset($mobile_number))
{
@ -442,9 +449,6 @@ class RestAuthenticationController extends AdminController
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
}
if ($employeeData && $employeeData["mpin"] != null) {
return $this->respond(['status' => 'success','code' => 200,'data' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"]],200);