Yandex\Market\Partner\PartnerClient::sendRequest PHP Method

sendRequest() protected method

Sends a request
protected sendRequest ( string $method, string | Psr\Http\Message\UriInterface $uri, array $options = [] ) : Response
$method string HTTP method
$uri string | Psr\Http\Message\UriInterface URI object or string.
$options array Request options to apply.
return GuzzleHttp\Psr7\Response
    protected function sendRequest($method, $uri, array $options = [])
    {
        try {
            $response = $this->getClient()->request($method, $uri, $options);
        } catch (ClientException $ex) {
            $result = $ex->getResponse();
            $code = $result->getStatusCode();
            $message = $result->getReasonPhrase();
            $body = $result->getBody();
            if ($body) {
                $jsonBody = json_decode($body);
                if ($jsonBody && isset($jsonBody->error) && isset($jsonBody->error->message)) {
                    $message = $jsonBody->error->message;
                }
            }
            if ($code === 403) {
                throw new ForbiddenException($message);
            }
            if ($code === 401) {
                throw new UnauthorizedException($message);
            }
            throw new PartnerRequestException('Service responded with error code: "' . $code . '" and message: "' . $message . '"', $code);
        }
        return $response;
    }