From 4920294afabaeda75b1552dea6c14d3efb48e570 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Wed, 12 Jul 2023 13:00:25 -0400 Subject: [PATCH] Nofifications --- www-api/app/Config/Routes.php | 4 +- .../app/Controllers/WrenchNotifications.php | 112 ++++++++++++++++++ 2 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 www-api/app/Controllers/WrenchNotifications.php diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index fc16803a..7c8dbff1 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -47,7 +47,7 @@ $routes->post('/en/wrench/api/v1/authstart', 'WrenchOauth::apigate'); $routes->post('/en/wrench/api/v1/faq', 'WrenchFaq::apigate'); $routes->post('/en/wrench/api/v1/faqdata', 'WrenchFaq::apigate'); -$routes->post('/en/wrench/api/v1/mynotifications', 'WrenchApi::apigate'); + $routes->post('/en/wrench/api/v1/apigate', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/generics', 'WrenchApi::apigate'); @@ -179,11 +179,11 @@ $routes->post('/en/wrench/api/v1/blogdata/', 'WrenchBlog::website'); //$routes->post('/en/wrench/api/v1/blogdata/(:any)', 'WrenchBlog::blogLimitedData/$1'); - $routes->post('/en/wrench/api/v1/startcredit', 'WrenchTransactions::apigate'); $routes->post('/en/wrench/api/v1/confirmcredit', 'WrenchTransactions::apigate'); +$routes->post('/en/wrench/api/v1/mynotifications', 'WrenchNotifications::apigate'); diff --git a/www-api/app/Controllers/WrenchNotifications.php b/www-api/app/Controllers/WrenchNotifications.php new file mode 100644 index 00000000..6818c89c --- /dev/null +++ b/www-api/app/Controllers/WrenchNotifications.php @@ -0,0 +1,112 @@ + OPTIONS DIE*****" ); + die(); + } + + //$request = service('request'); + // what is the endpoint + $uri = urldecode(current_url(true)); + $findme = '?'; + $pos = strpos($uri, $findme); + if ($pos > 5) { + $uri = substr($uri, 0, $pos); + } + log_message('critical', "API-GATE URI -> ".$uri ); + $pieces = explode('/', $uri); + $psc = count($pieces); + + $endpoint = $psc > 0 ? $pieces[$psc - 1] : ''; + log_message('critical', "Enpoint-> ".$endpoint ); + + $endpoints = $this->endPointList(); + $out = array(); + $res1 = []; + if (array_key_exists($endpoint, $endpoints)) { + } else { + http_response_code(404); + // tell the user product does not exist + return json_encode([ + 'message' => 'Endpoint not found.', + 'URI' => $uri, + ]); + } + + // echo "EXYTACT INPUT DATA HERE"; + $raw_json = file_get_contents('php://input'); + $raw_array = json_decode($raw_json, true); + + $local_out =[]; + if ($_SERVER["REQUEST_METHOD"] == "POST") { // if upload lets modify all the data + if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) { + $raw_array = array_merge($_POST,$_FILES); + } + } + + if ($_SERVER['REQUEST_METHOD'] == 'GET') { + log_message('critical', "Enpoint LOC2 HERE -> ".$endpoint ); + $get_param = $_GET['reqData'] ?? null; + $raw_array = ($get_param!=null) ? json_decode($get_param, true):[]; + } + //$in = $raw_array; + log_message('critical', "wrenchboard_api-CALL RAW DATA".serialize($raw_array) ); + //-- move to another module start + + + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + + switch ($endpoints){ + + case 'startcredit': + + break; + case 'confirmcredit': + // Confrim + break; + case 'mynotifications': + $in["action"] = WRENCHBOARD_ACCOUNT_NOTIFICATIONS; + break; + } + + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + log_message('critical', "wrenchboard_api-CALL PREPARE DATA".serialize($in) ); + + + if ( $call_backend == true && $in["action"] !='' ){ + $wrenchboard = new \App\Models\BackendModel(); + $ret = $wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + } + else + { + $out = $local_out; + } + + $this->doCacheStep($in, $out); + return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); + + return $this->response->setJson($response); + } + + +} \ No newline at end of file