Added Other AP

This commit is contained in:
dev-chiefworks
2022-04-26 11:30:34 -04:00
parent 5e006a6a21
commit 47f4fad75c
251 changed files with 29298 additions and 4 deletions
+27
View File
@@ -0,0 +1,27 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /SAVVY/banklogin/
#RewriteBase /
#Checks to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
#Header add Access-Control-Allow-Origin "*"
#Header add Access-Control-Expose-Headers "Access-Control-Allow-Origin"
#Header add Access-Control-Allow-Headers "Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"
#Header add Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
#Header add Content-type "application/json"
@@ -0,0 +1,10 @@
<?php
class Banklogin {
}
// vi:ts=2
@@ -0,0 +1,106 @@
<?php
class BankloginApi extends Api
{
public $apiName = 'banklogin';
public function indexAction()
{
return $this->response(
array(
"error" => "Data not found"
), 400);
}
/**
* Method GET
* Get single record (by id)
* http://DOMAIN/geocode/1
* @return string
*/
public function viewAction()
{
return $this->response(
array(
'error'=> 'Data not found'
), 404);
}
public function createAction()
{
global $savvyext;
$path = $this->requestParams['path'];
$method = $this->requestParams['method'];
$authToken = $this->requestParams['auth_token'] ?? "";
$data = $this->requestParams['data'] ?? array();
$url = $savvyext->cfgReadChar('microservices.account') . "/api/v1/" . rtrim($path, '/') . '/';
$opts = array(
'http' => array(
'method' => $method,
'protocol_version' => 1.1,
'header' =>
"Accept: application/json\r\n"
),
"ssl" => array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)
);
if(!empty($authToken)){
$opts['http']['header'] .= "Authorization: Token ${authToken}\r\n";
}
if($method == 'GET') {
if(is_array($data)) {
$data = "?" . http_build_query($data);
}
$url .= $data;
$opts['http']['header'] .= "Content-Type: application/x-www-form-urlencoded\r\n";
}
else {
$opts['http']['content'] = json_encode($data);
$opts['http']['header'] .= "Content-Type: application/json\r\nConnection: close\r\n";
$opts['http']['header'] .= "Content-length: " . strlen($opts['http']['content']);
}
$context = stream_context_create($opts);
try {
$body = file_get_contents($url, false, $context);
$result = json_decode($body,true);
return $this->response(
array(
'data'=>$result,
'options'=>""), 200);
} catch (Exception $e) {
error_log(json_encode($e));
$message = $e->getMessage();
}
return $this->response(
array(
"error" => $message
), 500);
}
public function updateAction()
{
return $this->response(
array(
"error" => "Update error"
), 400);
}
public function deleteAction()
{
return $this->response(
array(
"error" => "Delete error"
), 500);
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
require_once('../../core/backend.php');
require_once('../constants.php');
require_once('../common/Api.php');
require_once('../common/Db.php');
require_once('Banklogin.php');
require_once('BankloginApi.php');
$httpAuthToken = $savvyext->cfgReadChar('system.oauth2_token');
$bankloginAuthToken = $savvyext->cfgReadChar('system.bank_token');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, client_id");
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
header('Content-type: application/json');
if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) {
exit();
}
$headers = getallheaders();
if ((!isset($headers["Authorization"]) || substr($headers["Authorization"],-strlen($httpAuthToken))!=$httpAuthToken) &&
(!isset($headers["authorization"]) || substr($headers["authorization"],-strlen($httpAuthToken))!=$httpAuthToken)) {
header('HTTP/1.1 401 Unauthorized');
header('Status: 401 Unauthorized');
echo "{\"status\":\"Missing authorization\"}";
exit();
}
try {
if (strpos($_SERVER['REQUEST_URI'],'/api/')===false) {
throw new Exception("Invalid API request");
}
$requestUri = explode('/', trim($_SERVER['REQUEST_URI'],'/'));
while (array_shift($requestUri) !== 'api') {
};
if ($requestUri[0]=='banklogin') {
$api = new BankloginApi($requestUri);
}
else {
echo json_encode(Array('error' => 'Invalid API request'));
}
echo $api->run();
}
catch (Exception $e) {
echo json_encode(Array('error' => $e->getMessage()));
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

@@ -0,0 +1,60 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="swagger-ui.css" >
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="swagger-ui-bundle.js"> </script>
<script src="swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "../swagger.php",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region
window.ui = ui
}
</script>
</body>
</html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
<?php
require('../../../adminsavvy/vendor/autoload.php');
$openapi = \OpenApi\scan('.');
header('Content-Type: application/json');
echo $openapi->toJson();
?>