src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php
public function sendRequestAsync($type, $uri, $options = null)
    {
        $request = null;
        switch ($type) {
            case 'GET':
                $request = $this->oauthRequestClient
                    ->getAsync($uri, $options);
                break;
            case 'POST':
                $request = $this->oauthRequestClient
                    ->postAsync($uri, $options);
                break;
            case 'DELETE':
                $request = $this->oauthRequestClient
                    ->deleteAsync($uri, $options);
                break;
            default :
                throw new Exception("The request type you entered is not valid.");
                break;
        }
        return $request->then(
            function (ResponseInterface $response) {
                $contentType = self::checkResponseContentType($response->getHeader('Content-Type'));
                switch ($contentType) {
                    case 'json':
                        return json_decode($response->getBody(), true);
                        break;
                    case 'string':
                        return (string)$response->getBody();
                        break;
                    case 'html':
                        return $response;
                        break;
                    default:
                        // If we don't know the response type but it was a successful request, it's probably okay.
                        if($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
                            return $response;
                        }
                        throw new Exception("The response type not recognized.");
                }
            }
        );
    }
public function sendRequestAsync($type, $uri, $options = null)
    {
        $request = null;
        switch ($type) {
            case 'GET':
                $request = $this->oauthRequestClient
                    ->getAsync($uri, $options);
                break;
            case 'POST':
                $request = $this->oauthRequestClient
                    ->postAsync($uri, $options);
                break;
            case 'DELETE':
                $request = $this->oauthRequestClient
                    ->deleteAsync($uri, $options);
                break;
            default :
                throw new Exception("The request type you entered is not valid.");
                break;
        }
        return $request->then(
            function (ResponseInterface $response) {
                $contentType = self::checkResponseContentType($response->getHeader('Content-Type'));
                switch ($contentType) {
                    case 'json':
                        return json_decode($response->getBody(), true);
                        break;
                    case 'string':
                        return (string)$response->getBody();
                        break;
                    case 'html':
                        return $response;
                        break;
                    default:
                        // If we don't know the response type but it was a successful request, it's probably okay.
                        if($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
                            return $response;
                        }
                        throw new Exception("The response type not recognized.");
                }
            }
        );
    }
public function sendRequestAsync ( $ type , $ uri , $ options = null ) { $ request = null ; switch ( $ type ) { case 'GET' : $ request = $ this -> oauthRequestClient -> getAsync ( $ uri , $ options ) ; break ; case 'POST' : $ request = $ this -> oauthRequestClient -> postAsync ( $ uri , $ options ) ; break ; case 'DELETE' : $ request = $ this -> oauthRequestClient -> deleteAsync ( $ uri , $ options ) ; break ; default : throw new Exception ( "The request type you entered is not valid." ) ; break ; } return $ request -> then ( function ( ResponseInterface $ response ) { $ contentType = self :: checkResponseContentType ( $ response -> getHeader ( 'Content-Type' ) ) ; switch ( $ contentType ) { case 'json' : return json_decode ( $ response -> getBody ( ) , true ) ; break ; case 'string' : return ( string ) $ response -> getBody ( ) ; break ; case 'html' : return $ response ; break ; default : // If we don't know the response type but it was a successful request, it's probably okay. if ( $ response -> getStatusCode ( ) >= 200 && $ response -> getStatusCode ( ) < 300 ) { return $ response ; } throw new Exception ( "The response type not recognized." ) ; } } ) ; }
Sends a request to the Bynder API. All requests are async for now and the
query array is parsed as request filter.

@param string $type
@param string $uri
@param array $options

@return PromiseInterface
@throws Exception
Sends a request to the Bynder API . All requests are async for now and the query array is parsed as request filter .