You are here

class ApiClient in Auth0 Single Sign On 8.2

Hierarchy

Expanded class hierarchy of ApiClient

7 files declare their use of ApiClient
Authentication.php in vendor/auth0/auth0-php/src/API/Authentication.php
AuthHelper.php in src/Util/AuthHelper.php
Contains \Drupal\auth0\Util\AuthHelper.
GenericResource.php in vendor/auth0/auth0-php/src/API/Management/GenericResource.php
InformationHeadersExtendTest.php in vendor/auth0/auth0-php/tests/API/Helpers/InformationHeadersExtendTest.php
InformationHeadersTest.php in vendor/auth0/auth0-php/tests/API/Helpers/InformationHeadersTest.php

... See full list

File

vendor/auth0/auth0-php/src/API/Helpers/ApiClient.php, line 7

Namespace

Auth0\SDK\API\Helpers
View source
class ApiClient {
  const API_VERSION = '5.7.0';
  protected static $infoHeadersDataEnabled = true;
  protected static $infoHeadersData;
  public static function setInfoHeadersData(InformationHeaders $infoHeadersData) {
    if (!self::$infoHeadersDataEnabled) {
      return null;
    }
    self::$infoHeadersData = $infoHeadersData;
  }
  public static function getInfoHeadersData() {
    if (!self::$infoHeadersDataEnabled) {
      return null;
    }
    if (self::$infoHeadersData === null) {
      self::$infoHeadersData = new InformationHeaders();
      self::$infoHeadersData
        ->setCorePackage();
    }
    return self::$infoHeadersData;
  }
  public static function disableInfoHeaders() {
    self::$infoHeadersDataEnabled = false;
  }
  protected $domain;
  protected $basePath;
  protected $headers;
  protected $guzzleOptions;
  protected $returnType;
  public function __construct($config) {
    $this->basePath = $config['basePath'];
    $this->domain = $config['domain'];
    $this->returnType = isset($config['returnType']) ? $config['returnType'] : null;
    $this->headers = isset($config['headers']) ? $config['headers'] : [];
    $this->guzzleOptions = isset($config['guzzleOptions']) ? $config['guzzleOptions'] : [];
    if (self::$infoHeadersDataEnabled) {
      $this->headers[] = new Telemetry(self::getInfoHeadersData()
        ->build());
    }
  }

  /**
   * Magic method to map HTTP verbs to request types.
   *
   * @deprecated 5.6.0, use $this->method().
   *
   * @param string $name      - Method name used to call the magic method.
   * @param array  $arguments - Arguments used in the magic method call.
   *
   * @return RequestBuilder
   */
  public function __call($name, $arguments) {
    $builder = new RequestBuilder([
      'domain' => $this->domain,
      'basePath' => $this->basePath,
      'method' => $name,
      'guzzleOptions' => $this->guzzleOptions,
      'returnType' => $this->returnType,
    ]);
    return $builder
      ->withHeaders($this->headers);
  }

  /**
   * Create a new RequestBuilder.
   * Similar to the above but does not use a magic method.
   *
   * @param string  $method           - HTTP method to use (GET, POST, PATCH, etc).
   * @param boolean $set_content_type - Automatically set a content-type header.
   *
   * @return RequestBuilder
   */
  public function method($method, $set_content_type = true) {
    $method = strtolower($method);
    $builder = new RequestBuilder([
      'domain' => $this->domain,
      'basePath' => $this->basePath,
      'method' => $method,
      'guzzleOptions' => $this->guzzleOptions,
      'returnType' => $this->returnType,
    ]);
    $builder
      ->withHeaders($this->headers);
    if ($set_content_type && in_array($method, [
      'patch',
      'post',
      'put',
      'delete',
    ])) {
      $builder
        ->withHeader(new ContentType('application/json'));
    }
    return $builder;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ApiClient::$basePath protected property
ApiClient::$domain protected property
ApiClient::$guzzleOptions protected property
ApiClient::$headers protected property
ApiClient::$infoHeadersData protected static property
ApiClient::$infoHeadersDataEnabled protected static property
ApiClient::$returnType protected property
ApiClient::API_VERSION constant
ApiClient::disableInfoHeaders public static function
ApiClient::getInfoHeadersData public static function
ApiClient::method public function Create a new RequestBuilder. Similar to the above but does not use a magic method.
ApiClient::setInfoHeadersData public static function
ApiClient::__call Deprecated public function Magic method to map HTTP verbs to request types.
ApiClient::__construct public function