public function makeRequest(
        string $relativeUrl,
        array $variables = [],
        string $httpMethod = ClientInterface::HTTP_GET,
        bool $shouldCache = true,
        string $contentType = ClientInterface::CONTENT_TYPE_JSON
    ) : BookboonResponse {
        if (strpos($relativeUrl, '/') !== 0) {
            throw new UsageException('Location must begin with forward slash');
        }

        $queryUrl = $this->getBaseApiUri() . $relativeUrl;
        $postVariables = [];

        if ($httpMethod === ClientInterface::HTTP_GET && count($variables) !== 0) {
            $queryUrl .= '?' . http_build_query($variables);
        }

        if ($httpMethod === ClientInterface::HTTP_POST) {
            $postVariables = $variables;
        }


        if ($this->isCachable($queryUrl, $httpMethod) && $shouldCache) {
            $result = $this->getFromCache($queryUrl);

            if ($result === null) {
                $result = $this->executeQuery($queryUrl, $httpMethod, $postVariables);
                $this->saveInCache($queryUrl, $result);
            }

            return $result;
        }

        return $this->executeQuery($queryUrl, $httpMethod, $postVariables, $contentType);
    }
public function makeRequest(
        string $relativeUrl,
        array $variables = [],
        string $httpMethod = ClientInterface::HTTP_GET,
        bool $shouldCache = true,
        string $contentType = ClientInterface::CONTENT_TYPE_JSON
    ) : BookboonResponse {
        if (strpos($relativeUrl, '/') !== 0) {
            throw new UsageException('Location must begin with forward slash');
        }

        $queryUrl = $this->getBaseApiUri() . $relativeUrl;
        $postVariables = [];

        if ($httpMethod === ClientInterface::HTTP_GET && count($variables) !== 0) {
            $queryUrl .= '?' . http_build_query($variables);
        }

        if ($httpMethod === ClientInterface::HTTP_POST) {
            $postVariables = $variables;
        }


        if ($this->isCachable($queryUrl, $httpMethod) && $shouldCache) {
            $result = $this->getFromCache($queryUrl);

            if ($result === null) {
                $result = $this->executeQuery($queryUrl, $httpMethod, $postVariables);
                $this->saveInCache($queryUrl, $result);
            }

            return $result;
        }

        return $this->executeQuery($queryUrl, $httpMethod, $postVariables, $contentType);
    }
public function makeRequest ( string $ relativeUrl , array $ variables = [ ] , string $ httpMethod = ClientInterface :: HTTP_GET , bool $ shouldCache = true , string $ contentType = ClientInterface :: CONTENT_TYPE_JSON ) : BookboonResponse { if ( strpos ( $ relativeUrl , '/' ) !== 0 ) { throw new UsageException ( 'Location must begin with forward slash' ) ; } $ queryUrl = $ this -> getBaseApiUri ( ) . $ relativeUrl ; $ postVariables = [ ] ; if ( $ httpMethod === ClientInterface :: HTTP_GET && count ( $ variables ) !== 0 ) { $ queryUrl .= '?' . http_build_query ( $ variables ) ; } if ( $ httpMethod === ClientInterface :: HTTP_POST ) { $ postVariables = $ variables ; } if ( $ this -> isCachable ( $ queryUrl , $ httpMethod ) && $ shouldCache ) { $ result = $ this -> getFromCache ( $ queryUrl ) ; if ( $ result === null ) { $ result = $ this -> executeQuery ( $ queryUrl , $ httpMethod , $ postVariables ) ; $ this -> saveInCache ( $ queryUrl , $ result ) ; } return $ result ; } return $ this -> executeQuery ( $ queryUrl , $ httpMethod , $ postVariables , $ contentType ) ; }
Prepares the call to the api and if enabled tries cache provider first for GET calls.

@param string $relativeUrl     The url relative to the address. Must begin with '/'
@param array  $variables       Array of variables
@param string $httpMethod      Override http method
@param bool   $shouldCache     manually disable object cache for query
@param string $contentType     Request Content type

@return BookboonResponse results of call

@throws UsageException
Prepares the call to the api and if enabled tries cache provider first for GET calls .