public function getApiRequest($apiUrl, $deferred)
    {
        return new Request([
            'url' => $apiUrl,
            'resolveCallback' =>
                function (Response $response) use ($deferred) {
                    $data = (string) $response->getBody();
                    $headers = $response->getHeaders();
                    $code = $response->getStatusCode();
                    $shortUrl = $this->handleResponse($data, $headers, $code);
                    if ($shortUrl === false) {
                        $deferred->reject();
                    } else {
                        $deferred->resolve($shortUrl);
                    }
                },
            'rejectCallback' => [$deferred, 'reject']
        ]);
    }
public function getApiRequest($apiUrl, $deferred)
    {
        return new Request([
            'url' => $apiUrl,
            'resolveCallback' =>
                function (Response $response) use ($deferred) {
                    $data = (string) $response->getBody();
                    $headers = $response->getHeaders();
                    $code = $response->getStatusCode();
                    $shortUrl = $this->handleResponse($data, $headers, $code);
                    if ($shortUrl === false) {
                        $deferred->reject();
                    } else {
                        $deferred->resolve($shortUrl);
                    }
                },
            'rejectCallback' => [$deferred, 'reject']
        ]);
    }
public function getApiRequest ( $ apiUrl , $ deferred ) { return new Request ( [ 'url' => $ apiUrl , 'resolveCallback' => function ( Response $ response ) use ( $ deferred ) { $ data = ( string ) $ response -> getBody ( ) ; $ headers = $ response -> getHeaders ( ) ; $ code = $ response -> getStatusCode ( ) ; $ shortUrl = $ this -> handleResponse ( $ data , $ headers , $ code ) ; if ( $ shortUrl === false ) { $ deferred -> reject ( ) ; } else { $ deferred -> resolve ( $ shortUrl ) ; } } , 'rejectCallback' => [ $ deferred , 'reject' ] ] ) ; }
Create the API Request

@param string $apiUrl
@param Deferred $deferred
@return Request
Create the API Request