Código Fonte
<?php
require_once '../vendor/autoload.php';
use Swagger\Client\Api\PriceApi;
use Swagger\Client\ApiException;
// PARAMETERS
$offset = clear('offset');
$limit = clear('limit');
$price_type = clearInt('price_type');
$currency = clear('currency');
$product_ids = clearArray('product_ids');
$unit = clear('unit');
// E2E ACCESS KEYS
$client = new GuzzleHttp\Client([
'headers' => [
'api_key' => 'JHSV2V6KyqcbxvMHshRlPfunJymVt7GDfXyoK229o=',
'company_key' => 'E2ELIVE',
]
]);
try {
// SEARCH PRICES
$api = new PriceApi($client);
$result = $api->priceList(
$offset,
$limit,
$price_type,
$currency,
$unit,
$product_ids
);
header('Content-Type: application/json; charset=utf-8');
echo $result->__toString();
} catch (Exception $e) {
http_response_code($e->getCode());
$msg = $e instanceof ApiException ? $e->getResponseBody() : $e->getMessage();
if (!empty($msg)) {
echo $msg;
}
}
function clear($field)
{
return empty($_REQUEST[$field]) ? null : $_REQUEST[$field];
}
function clearInt($field)
{
return !isset($_REQUEST[$field]) || $_REQUEST[$field] == null || $_REQUEST[$field] == '' ? null : $_REQUEST[$field];
}
function clearArray($field)
{
$val = clear($field);
if (empty($val)) {
return null;
}
return explode(",", $val);
}