GWM : api test
This commit is contained in:
parent
6a7e60393f
commit
93d642b270
@ -156,6 +156,14 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
|||||||
|
|
||||||
$routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath");
|
$routes->get("api/policy/PolicyFilePath", "PolicyController::PolicyFilePath");
|
||||||
|
|
||||||
|
$routes->group('test', [ ], function ($routes) {
|
||||||
|
|
||||||
|
$routes->get("policyCommissionCalculationAndGeminiPolicyRead", "PolicyController::policyCommissionCalculationAndGeminiPolicyRead");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies");
|
// $routes->get("policy/searchThePolicies", "PolicyController::searchThePolicies");
|
||||||
// $routes->get("dashboard/businessDashboard", "DashboardController::businessDashboard");
|
// $routes->get("dashboard/businessDashboard", "DashboardController::businessDashboard");
|
||||||
// $routes->get("dashboard/partnerDashboard", "DashboardController::partnerDashboard");
|
// $routes->get("dashboard/partnerDashboard", "DashboardController::partnerDashboard");
|
||||||
|
|||||||
@ -700,6 +700,13 @@ class EnquiryController extends ResourceController
|
|||||||
])->setStatusCode(400);
|
])->setStatusCode(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($reg_no == 'New' || $reg_no == 'new' || $reg_no == 'NEW') {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
"status" => "not exists",
|
||||||
|
"message" => "No active record found for this vehicle number in enquiries."
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// --- 2. Step 1: Check in partner_enquiry (Active/Latest Record) ---
|
// --- 2. Step 1: Check in partner_enquiry (Active/Latest Record) ---
|
||||||
// Get the LATEST ACTIVE enquiry record for the registration number
|
// Get the LATEST ACTIVE enquiry record for the registration number
|
||||||
$enquiry = $this->db->table("partner_enquiry")
|
$enquiry = $this->db->table("partner_enquiry")
|
||||||
|
|||||||
@ -568,7 +568,12 @@ class PolicyController extends ResourceController
|
|||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
if (!file_exists($filePath)) {
|
if (!file_exists($filePath)) {
|
||||||
log_message('info',"Error: File not found at {$filePath}");
|
log_message('info',"Error: File not found at {$filePath}");
|
||||||
return ['status'=>"failed", 'message'=> "File not found at {$filePath}"];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "File not found at {$filePath}"], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "File not found at {$filePath}"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the file's MIME type using the finfo extension
|
// Get the file's MIME type using the finfo extension
|
||||||
@ -665,7 +670,12 @@ class PolicyController extends ResourceController
|
|||||||
if (curl_errno($ch)) {
|
if (curl_errno($ch)) {
|
||||||
$curl_error = curl_error($ch);
|
$curl_error = curl_error($ch);
|
||||||
log_message('info',"cURL Error: " . $curl_error);
|
log_message('info',"cURL Error: " . $curl_error);
|
||||||
return ['status'=>"failed", 'message'=> "cURL Error: " . $curl_error];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "cURL Error: " . $curl_error], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "cURL Error: " . $curl_error];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
@ -675,7 +685,12 @@ class PolicyController extends ResourceController
|
|||||||
// Check for non-successful HTTP status codes
|
// Check for non-successful HTTP status codes
|
||||||
if ($http_code < 200 || $http_code >= 300) {
|
if ($http_code < 200 || $http_code >= 300) {
|
||||||
log_message('info',"API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200));
|
log_message('info',"API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200));
|
||||||
return ['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the JSON response
|
// Decode the JSON response
|
||||||
@ -704,7 +719,12 @@ class PolicyController extends ResourceController
|
|||||||
|
|
||||||
if (empty($json_string)) {
|
if (empty($json_string)) {
|
||||||
log_message('info',"Could not extract a valid JSON string from the generated text.");
|
log_message('info',"Could not extract a valid JSON string from the generated text.");
|
||||||
return ['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "Could not extract a valid JSON string from the generated text."];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the extracted JSON string
|
// Decode the extracted JSON string
|
||||||
@ -712,11 +732,24 @@ class PolicyController extends ResourceController
|
|||||||
|
|
||||||
log_message('info', "Extracted and decoded final JSON data successfully.");
|
log_message('info', "Extracted and decoded final JSON data successfully.");
|
||||||
|
|
||||||
return ['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $final_data ], 200);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
return ['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log_message('info',"Response structure invalid or no generated text candidate found.");
|
log_message('info',"Response structure invalid or no generated text candidate found.");
|
||||||
return ['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "Response structure invalid or no generated text candidate found"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -725,12 +758,17 @@ class PolicyController extends ResourceController
|
|||||||
// curl_close($ch);
|
// curl_close($ch);
|
||||||
// }
|
// }
|
||||||
log_message('error', "Fatal Error: " . $e->getMessage());
|
log_message('error', "Fatal Error: " . $e->getMessage());
|
||||||
return ['status'=>"failed", 'message'=> "Error: " . $e->getMessage()];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond(['status'=>"failed", 'message'=> "Error: " . $e->getMessage()], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "Error: " . $e->getMessage()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateCommission($policyId = null)
|
public function calculateCommission($policyId = null , $return = null)
|
||||||
{
|
{
|
||||||
log_message('debug', 'calculateCommission() started with policyId: ' . $policyId);
|
log_message('debug', 'calculateCommission() started with policyId: ' . $policyId);
|
||||||
|
|
||||||
@ -799,7 +837,13 @@ class PolicyController extends ResourceController
|
|||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
log_message('error', 'cURL Error: ' . $error);
|
log_message('error', 'cURL Error: ' . $error);
|
||||||
return ['status'=>"failed", 'message'=> 'cURL Error: ' . $error];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond( ['status'=>"failed", 'message'=> 'cURL Error: ' . $error], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> 'cURL Error: ' . $error];
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
log_message('debug', 'API Response: ' . $response);
|
log_message('debug', 'API Response: ' . $response);
|
||||||
@ -819,21 +863,48 @@ class PolicyController extends ResourceController
|
|||||||
|
|
||||||
log_message('debug', 'Updating Policy (ID=75) With: ' . json_encode($policyData));
|
log_message('debug', 'Updating Policy (ID=75) With: ' . json_encode($policyData));
|
||||||
|
|
||||||
// Update record
|
if($return == true)
|
||||||
$this->PolicyModel->update($policyId, $policyData);
|
{
|
||||||
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $policyData ], 200);
|
||||||
|
}else{
|
||||||
|
// Update record
|
||||||
|
$this->PolicyModel->update($policyId, $policyData);
|
||||||
|
log_message('debug', 'Policy update successful!');
|
||||||
|
return ['status'=>"success", 'message'=> "Commission Updated!"];
|
||||||
|
}
|
||||||
|
|
||||||
log_message('debug', 'Policy update successful!');
|
|
||||||
|
|
||||||
return ['status'=>"success", 'message'=> "Commission Updated!"];
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log_message('debug', 'calculateCommission() - Invalid API Response');
|
log_message('debug', 'calculateCommission() - Invalid API Response');
|
||||||
|
|
||||||
return ['status'=>"failed", 'message'=> "Invalid API Response!"];
|
if($return == true)
|
||||||
|
{
|
||||||
|
return $this->respond( ['status'=>"failed", 'message'=> "Invalid API Response!"], 200);
|
||||||
|
}else{
|
||||||
|
return ['status'=>"failed", 'message'=> "Invalid API Response!"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function policyCommissionCalculationAndGeminiPolicyRead()
|
||||||
|
{
|
||||||
|
|
||||||
|
$type = $this->request->getGet('type');
|
||||||
|
$policyId = $this->request->getGet('policy_id');
|
||||||
|
|
||||||
|
if($type == 'commission')
|
||||||
|
{
|
||||||
|
return $this->calculateCommission($policyId , true);
|
||||||
|
|
||||||
|
}else if($type == 'read')
|
||||||
|
{
|
||||||
|
return $this->checkPolicyDoc($policyId , true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function searchThePolicies() {
|
public function searchThePolicies() {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user