Código Fonte
<?php
require_once '../vendor/autoload.php';
use Swagger\Client\Api\DocumentApi;
use Swagger\Client\ApiException;
// PARAMETERS
$offset = clear('offset');
$limit = clear('limit');
$number = clear('number');
$start_date = formatDate('start_date');
$end_date = formatDate('end_date');
$type1 = clear('type1');
$type2 = clear('type2');
$update_date = formatDate('update_date');
$account = null;
$product = null;
$product_category = null;
$deleted = false;
$document_name = null;
$type = clearArray('type');
$serie = clearArray('serie');
$salesman = null;
// E2E ACCESS KEYS
$client = new GuzzleHttp\Client([
'headers' => [
'api_key' => 'JHSV2V6KyqcbxvMHshRlPfunJymVt7GDfXyoK229o=',
'company_key' => 'E2ELIVE',
]
]);
try {
// SEARCH DOCUMENTS
$api = new DocumentApi($client);
$result = $api->documentList(
$offset,
$limit,
$number,
$start_date,
$end_date,
$type1,
$type2,
$update_date,
$account,
$product,
$product_category,
$deleted,
$document_name,
$type,
$serie,
$salesman
);
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 clearArray($field)
{
$val = clear($field);
if (empty($val)) {
return null;
}
return array($val);
}
function formatDate($field)
{
$date = clear($field);
if (!empty($date)) {
$date = DateTime::createFromFormat('Y-m-d', $date);
$date = $date->format(DateTime::ISO8601);
}
return $date;
}