onResponse() public méthode

Called on successful responses
public onResponse ( Psr\Http\Message\ResponseInterface $response )
$response Psr\Http\Message\ResponseInterface
 /**
  * Send asynchronous guzzle request
  *
  * @param RequestInterface $request
  * @param \Tebru\Retrofit\Http\Callback $callback
  * @return null
  */
 public function sendAsync(RequestInterface $request, Callback $callback)
 {
     $this->promises[] = $this->client->sendAsync($request)->then(function (ResponseInterface $response) use($callback, $request) {
         if (null !== $this->eventDispatcher) {
             $this->eventDispatcher->dispatch(AfterSendEvent::NAME, new AfterSendEvent($request, $response));
         }
         $callback->onResponse($response);
     }, function (Exception $exception) use($callback, $request) {
         $response = null;
         $context = [];
         if ($exception instanceof \GuzzleHttp\Exception\RequestException) {
             $request = $exception->getRequest();
             $response = $exception->getResponse();
             $context = $exception->getHandlerContext();
         }
         $requestException = new RequestException($exception->getMessage(), $exception->getCode(), $exception->getPrevious(), $request, $response, $context);
         if (null !== $this->eventDispatcher) {
             $this->eventDispatcher->dispatch(ApiExceptionEvent::NAME, new ApiExceptionEvent($requestException, $request));
         }
         $callback->onFailure($requestException);
     });
 }
 /**
  * Send asynchronous guzzle request
  *
  * @param RequestInterface $psrRequest
  * @param \Tebru\Retrofit\Http\Callback $callback
  * @return null
  */
 public function sendAsync(RequestInterface $psrRequest, Callback $callback)
 {
     $request = $this->createRequest($psrRequest, true);
     /** @var FutureInterface $response */
     $response = $this->client->send($request);
     $response->then(function (ResponseInterface $response) {
         return new Psr7Response($response->getStatusCode(), $response->getHeaders(), $response->getBody(), $response->getProtocolVersion(), $response->getReasonPhrase());
     }, function (Exception $exception) use($callback, $psrRequest) {
         $request = $psrRequest;
         $response = null;
         if ($exception instanceof \GuzzleHttp\Exception\RequestException) {
             $request = $exception->getRequest();
             $response = $exception->getResponse();
         }
         $requestException = new RequestException($exception->getMessage(), $exception->getCode(), $exception->getPrevious(), $request, $response);
         if (null !== $this->eventDispatcher) {
             $this->eventDispatcher->dispatch(ApiExceptionEvent::NAME, new ApiExceptionEvent($requestException, $request));
         }
         $callback->onFailure($requestException);
     })->then(function (Psr7Response $response) use($callback, $psrRequest) {
         if (null !== $this->eventDispatcher) {
             $this->eventDispatcher->dispatch(AfterSendEvent::NAME, new AfterSendEvent($psrRequest, $response));
         }
         $callback->onResponse($response);
     });
     $this->responses[] = $response;
 }