src/Api.php
public function request($path, $content = '') {
    $url = $this->getWardenUrl() . $path;

    $options = [];

    if ($this->hasBasicAuthentication()) {
      $options['auth'] = [ $this->getUsername(), $this->getPassword()];
    }

    $method = 'GET';
    if (!empty($content)) {
      $method = 'POST';
      $options['body'] = $content;
    }

    if (!empty($this->hasCertificatePath())) {
      $options['cert'] = $this->getCertificatePath();
    }

    $client = new Client();

    $res = $client->request($method, $url, $options);

    if ($res->getStatusCode() !== 200) {
      throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase());
    }

    return $res;
  }
public function request($path, $content = '') {
    $url = $this->getWardenUrl() . $path;

    $options = [];

    if ($this->hasBasicAuthentication()) {
      $options['auth'] = [ $this->getUsername(), $this->getPassword()];
    }

    $method = 'GET';
    if (!empty($content)) {
      $method = 'POST';
      $options['body'] = $content;
    }

    if (!empty($this->hasCertificatePath())) {
      $options['cert'] = $this->getCertificatePath();
    }

    $client = new Client();

    $res = $client->request($method, $url, $options);

    if ($res->getStatusCode() !== 200) {
      throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase());
    }

    return $res;
  }
public function request ( $ path , $ content = '' ) { $ url = $ this -> getWardenUrl ( ) . $ path ; $ options = [ ] ; if ( $ this -> hasBasicAuthentication ( ) ) { $ options [ 'auth' ] = [ $ this -> getUsername ( ) , $ this -> getPassword ( ) ] ; } $ method = 'GET' ; if ( ! empty ( $ content ) ) { $ method = 'POST' ; $ options [ 'body' ] = $ content ; } if ( ! empty ( $ this -> hasCertificatePath ( ) ) ) { $ options [ 'cert' ] = $ this -> getCertificatePath ( ) ; } $ client = new Client ( ) ; $ res = $ client -> request ( $ method , $ url , $ options ) ; if ( $ res -> getStatusCode ( ) !== 200 ) { throw new WardenBadResponseException ( 'Unable to communicate with Warden (' . $ res -> getStatusCode ( ) . ') ' . $ res -> getReasonPhrase ( ) ) ; } return $ res ; }
Send a message to warden

@param string $path
The query path including the leading slash (e.g. '/public-key')
@param string $content
The body of the request. If this is not empty, the request is a post.

@return ResponseInterface
The response object

@throws WardenBadResponseException
If the response status was not 200
Send a message to warden