• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/source/osm/api/api.php
  • Класс: BitrixLocationSourceOsmApiApi
  • Вызов: Api::getResponse
private function getResponse(HttpClient $client, string $body): array
{
	$status = $client->getStatus();

	if ($body === false)
	{
		$errors = $client->getError();

		throw new RuntimeException(
			implode('; ', array_map(
				function ($v, $k) { return sprintf("%s=%s", $k, $v); },
				$errors,
				array_keys($errors)
			))
		);
	}

	if ($status != 200)
	{
		throw new RuntimeException(sprintf('Unexpected status code - %s', $status));
	}

	try
	{
		$response = Json::decode($body);
	}
	catch (ArgumentException $e)
	{
		throw new RuntimeException('JSON decode error');
	}

	if (!is_array($response))
	{
		throw new RuntimeException('Response format error');
	}

	return $response;
}