34 lines
985 B
PHP
34 lines
985 B
PHP
<?php
|
|
return [
|
|
'pattern' => '/mapado-api.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;
|
|
}
|
|
];
|