src/Pool.php
private function createStartingPromise(
        ClientRequestInterface $request,
        callable $startingSuccessCallback = null,
        callable $startingFailCallback = null
    ): ApiResponseInterface {
        if (!$startingSuccessCallback) {
            $startingSuccessCallback = function (ResponseInterface $response) use ($request) {
                return $request->mapFromResponse($request->buildResponse($response));
            };
        }

        if (!$startingFailCallback) {
            $startingFailCallback = function (RequestException $exception) {
                return ApiException::create($exception->getRequest(), $exception->getResponse(), $exception);
            };
        }

        return $this->getClient()->executeAsync($request)->then($startingSuccessCallback, $startingFailCallback);
    }
private function createStartingPromise(
        ClientRequestInterface $request,
        callable $startingSuccessCallback = null,
        callable $startingFailCallback = null
    ): ApiResponseInterface {
        if (!$startingSuccessCallback) {
            $startingSuccessCallback = function (ResponseInterface $response) use ($request) {
                return $request->mapFromResponse($request->buildResponse($response));
            };
        }

        if (!$startingFailCallback) {
            $startingFailCallback = function (RequestException $exception) {
                return ApiException::create($exception->getRequest(), $exception->getResponse(), $exception);
            };
        }

        return $this->getClient()->executeAsync($request)->then($startingSuccessCallback, $startingFailCallback);
    }
private function createStartingPromise ( ClientRequestInterface $ request , callable $ startingSuccessCallback = null , callable $ startingFailCallback = null ) : ApiResponseInterface { if ( ! $ startingSuccessCallback ) { $ startingSuccessCallback = function ( ResponseInterface $ response ) use ( $ request ) { return $ request -> mapFromResponse ( $ request -> buildResponse ( $ response ) ) ; } ; } if ( ! $ startingFailCallback ) { $ startingFailCallback = function ( RequestException $ exception ) { return ApiException :: create ( $ exception -> getRequest ( ) , $ exception -> getResponse ( ) , $ exception ) ; } ; } return $ this -> getClient ( ) -> executeAsync ( $ request ) -> then ( $ startingSuccessCallback , $ startingFailCallback ) ; }
Makes a ctp response out of the default async response and returns the promise for the next chaining level.
@param ClientRequestInterface $request
@param callable $startingSuccessCallback Overwrite the starting success callback.
@param callable $startingFailCallback Overwrite the failing success callback.
@return ApiResponseInterface
Makes a ctp response out of the default async response and returns the promise for the next chaining level .