26 $httpClientOptions = [];
27 if (array_key_exists(
'HTTP_CLIENT_OPTIONS', $options) && is_array($options[
'HTTP_CLIENT_OPTIONS']))
29 $httpClientOptions = $options[
'HTTP_CLIENT_OPTIONS'];
32 $httpClient =
new HttpClient($httpClientOptions);
34 $isJsonRequest = isset($options[
'JSON_REQUEST']) && $options[
'JSON_REQUEST'] ===
true;
38 $httpClient->setHeader(
'Content-Type',
'application/json');
41 $response = $httpClient->post(
45 if ($response ===
false)
47 $errors = $httpClient->getError();
48 foreach ($errors as $code => $message)
50 $result->addError(
new Main\
Error($message, $code));
56 $httpStatus = $httpClient->getStatus();
57 if ($httpStatus === 200)
62 $response = array_change_key_case($response, CASE_UPPER);
63 $response = Main\Text\Encoding::convertEncoding($response,
'UTF-8', LANG_CHARSET);
69 new Main\
Error(
'Response decoding error',
'RESPONSE_DECODING_ERROR')
73 $result->setData($response);