src/Publisher.php
private function sendRequest(RequestInterface $request, int $attempt = 0): \Psr\Http\Message\StreamInterface
    {
        if ($attempt >= $this->options->get('max_attempt')) {
            throw new \Exception('MAX attempt reached for ' . $request->getUri() . ' with payload ' . (string) $request);
        }

        try {
            $response = $this->httpClient->send(
                $request,
                [
                    'allow_redirects' => false,
                    'synchronous' => true,
                    'curl' => [
                        CURLOPT_FORBID_REUSE => true,
                        CURLOPT_MAXCONNECTS => 30,
                        CURLOPT_SSL_VERIFYPEER => false,
                        CURLOPT_SSL_VERIFYSTATUS => false,
                    ],
                ]
            );
            if ($response->getStatusCode() === 200) {
                return $response->getBody();
            }

            return $this->sendRequest($request, $attempt++);
        } catch (ClientException $err) {
            if ($err->getResponse()->getStatusCode() === 401 && $request->getRequestTarget() !== self::AUTHENTICATION) {
                $this->renewAuthToken();
                return $this->sendRequest($request, $attempt++);
            }

            throw $err;
        } catch (\Throwable $err) {
            throw $err;
        }
    }
private function sendRequest(RequestInterface $request, int $attempt = 0): \Psr\Http\Message\StreamInterface
    {
        if ($attempt >= $this->options->get('max_attempt')) {
            throw new \Exception('MAX attempt reached for ' . $request->getUri() . ' with payload ' . (string) $request);
        }

        try {
            $response = $this->httpClient->send(
                $request,
                [
                    'allow_redirects' => false,
                    'synchronous' => true,
                    'curl' => [
                        CURLOPT_FORBID_REUSE => true,
                        CURLOPT_MAXCONNECTS => 30,
                        CURLOPT_SSL_VERIFYPEER => false,
                        CURLOPT_SSL_VERIFYSTATUS => false,
                    ],
                ]
            );
            if ($response->getStatusCode() === 200) {
                return $response->getBody();
            }

            return $this->sendRequest($request, $attempt++);
        } catch (ClientException $err) {
            if ($err->getResponse()->getStatusCode() === 401 && $request->getRequestTarget() !== self::AUTHENTICATION) {
                $this->renewAuthToken();
                return $this->sendRequest($request, $attempt++);
            }

            throw $err;
        } catch (\Throwable $err) {
            throw $err;
        }
    }
private function sendRequest ( RequestInterface $ request , int $ attempt = 0 ) : \ Psr \ Http \ Message \ StreamInterface { if ( $ attempt >= $ this -> options -> get ( 'max_attempt' ) ) { throw new \ Exception ( 'MAX attempt reached for ' . $ request -> getUri ( ) . ' with payload ' . ( string ) $ request ) ; } try { $ response = $ this -> httpClient -> send ( $ request , [ 'allow_redirects' => false , 'synchronous' => true , 'curl' => [ CURLOPT_FORBID_REUSE => true , CURLOPT_MAXCONNECTS => 30 , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_SSL_VERIFYSTATUS => false , ] , ] ) ; if ( $ response -> getStatusCode ( ) === 200 ) { return $ response -> getBody ( ) ; } return $ this -> sendRequest ( $ request , $ attempt ++ ) ; } catch ( ClientException $ err ) { if ( $ err -> getResponse ( ) -> getStatusCode ( ) === 401 && $ request -> getRequestTarget ( ) !== self :: AUTHENTICATION ) { $ this -> renewAuthToken ( ) ; return $ this -> sendRequest ( $ request , $ attempt ++ ) ; } throw $ err ; } catch ( \ Throwable $ err ) { throw $ err ; } }
actually send request created here, separated for easier attempt count and handling exception

@throws \Exception
@throws \GuzzleHttp\Exception\ClientException
@throws \GuzzleHttp\Exception\BadResponseException
actually send request created here separated for easier attempt count and handling exception