From 9fe763caff9a44c47ccbb5d02174944d8cdc890e Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 24 Feb 2024 18:42:35 -0500 Subject: [PATCH] Wrencg Jobs --- www-api/app/Config/Routes.php | 3 +- www-api/app/Controllers/WrenchJobs.php | 38 ++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index adb6b044..2aa9a06b 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -70,7 +70,8 @@ $routes->post('/en/wrench/api/v1/homebanners', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/startjoblist', 'WrenchApi::apigate'); $routes->get('/en/wrench/api/v1/startjoblist', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/dashdata', 'WrenchApi::apigate'); -$routes->post('/en/wrench/api/v1/getjobsdata', 'WrenchApi::apigate'); + +$routes->post('/en/wrench/api/v1/getjobsdata', 'WrenchJobs::apigate'); //WrenchJobs WrenchApi $routes->post('/en/wrench/api/v1/offerslist', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/offersresponse', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchJobs.php b/www-api/app/Controllers/WrenchJobs.php index 399e2975..9af1b338 100644 --- a/www-api/app/Controllers/WrenchJobs.php +++ b/www-api/app/Controllers/WrenchJobs.php @@ -89,9 +89,16 @@ class WrenchJobs extends BaseController // TOKEN VERIFICATION WILL GAPPEN } + switch($endpoint) { + case 'getjobsdata': + $in["action"] = 'marketjobs'; //WRENCHBOARD_ACCOUNT_JOBLIST; + break; + } + + if ( $call_backend == true && $in["action"] !='' ){ - $wrenchboard = new \App\Models\BackendModel(); - $ret = $wrenchboard->wrenchboard_api($in, $out); + // $wrenchboard = new \App\Models\BackendModel(); + $ret = $this->wrenchboard_api($in, $out); $out['internal_return'] = $ret; } else @@ -109,6 +116,33 @@ class WrenchJobs extends BaseController return json_encode( $final_out ); } + public function wrenchboard_api($in, &$out = array(),$pathWay='') { + $ret = 0; + $local_url = "http://10.10.10.120:3033/marketjobs"; + $url = $local_url ; // ."/".$urlPath; //"/generics"; + $data = $in; + $content = json_encode($data); + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type" => "application/json")); + curl_setopt($curl, CURLOPT_POST, false); // true to make POST + curl_setopt($curl, CURLOPT_POSTFIELDS, $content); + + $json_response = curl_exec($curl); + $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($status != 200) { + echo ("Error: call to URL $url failed with status $status, response $json_response, | curl_error " . curl_error($curl) . ", | curl_errno " . curl_errno($curl)); + } + + curl_close($curl); + $response = json_decode($json_response, true); + $out = $response; + return $response["internal_return"]; + } } \ No newline at end of file