mapado route -> 'mapado-api'
This commit is contained in:
parent
37a84058d1
commit
dde1813f78
12 changed files with 127 additions and 42 deletions
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
return [
|
||||
'pattern' => '/mapado.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents("php://input");
|
||||
$request = json_decode($jsonRequest, true);
|
||||
|
||||
$token = site()->mapadoToken();
|
||||
$contractId = site()->mapadoContractId();
|
||||
$requestEndPoint = $request['requestEndPoint'];
|
||||
$requestParams = $request['requestParams'];
|
||||
$requestFields = $request['requestFields'];
|
||||
|
||||
$url = "https://ticketing.mapado.net/v1/$requestEndPoint?contract=$contractId&";
|
||||
|
||||
$url .= buildParamsString($requestParams);
|
||||
$url .= buildFieldsString($requestFields);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $token
|
||||
]);
|
||||
|
||||
$responseString = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$responseJson = json_encode(json_decode($responseString));
|
||||
|
||||
return $responseJson;
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue