src/drivers/Fastly.php
protected function sendRequest(string $method = 'PURGE', string $uri, array $headers = [])
    {
        $client = new Client([
            'base_uri' => self::API_ENDPOINT,
            'headers'  => array_merge($headers, [
                'Content-Type' => 'application/json',
                'Fastly-Key'   => $this->apiToken
            ])
        ]);

        // Prepend the service endpoint
        if (in_array($method, ['POST','GET'])) {
            $uri = "service/{$this->serviceId}/{$uri}";
        }

        try {

            $client->request($method, $uri);

        } catch (BadResponseException $e) {

            throw FastlyApiException::create(
                $e->getRequest(),
                $e->getResponse()
            );
        }

        return true;
    }
protected function sendRequest(string $method = 'PURGE', string $uri, array $headers = [])
    {
        $client = new Client([
            'base_uri' => self::API_ENDPOINT,
            'headers'  => array_merge($headers, [
                'Content-Type' => 'application/json',
                'Fastly-Key'   => $this->apiToken
            ])
        ]);

        // Prepend the service endpoint
        if (in_array($method, ['POST','GET'])) {
            $uri = "service/{$this->serviceId}/{$uri}";
        }

        try {

            $client->request($method, $uri);

        } catch (BadResponseException $e) {

            throw FastlyApiException::create(
                $e->getRequest(),
                $e->getResponse()
            );
        }

        return true;
    }
protected function sendRequest ( string $ method = 'PURGE' , string $ uri , array $ headers = [ ] ) { $ client = new Client ( [ 'base_uri' => self :: API_ENDPOINT , 'headers' => array_merge ( $ headers , [ 'Content-Type' => 'application/json' , 'Fastly-Key' => $ this -> apiToken ] ) ] ) ; // Prepend the service endpoint if ( in_array ( $ method , [ 'POST' , 'GET' ] ) ) { $ uri = "service/{$this->serviceId}/{$uri}" ; } try { $ client -> request ( $ method , $ uri ) ; } catch ( BadResponseException $ e ) { throw FastlyApiException :: create ( $ e -> getRequest ( ) , $ e -> getResponse ( ) ) ; } return true ; }
Send API call

@param string $method HTTP verb
@param string $uri
@param array  $headers

@return bool
@throws \ostark\upper\exceptions\FastlyApiException
Send API call