You are here

class HttpClientWrapper in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Client/HttpClientWrapper.php \Drupal\salesforce\Client\HttpClientWrapper
  2. 8.3 src/Client/HttpClientWrapper.php \Drupal\salesforce\Client\HttpClientWrapper

Wraps Guzzle HTTP client for an OAuth ClientInterface.

Hierarchy

  • class \Drupal\salesforce\Client\HttpClientWrapper implements \OAuth\Common\Http\Client\ClientInterface

Expanded class hierarchy of HttpClientWrapper

1 string reference to 'HttpClientWrapper'
salesforce.services.yml in ./salesforce.services.yml
salesforce.services.yml
1 service uses HttpClientWrapper
salesforce.http_client_wrapper in ./salesforce.services.yml
Drupal\salesforce\Client\HttpClientWrapper

File

src/Client/HttpClientWrapper.php, line 12

Namespace

Drupal\salesforce\Client
View source
class HttpClientWrapper implements ClientInterface {

  /**
   * Guzzle HTTP Client service.
   *
   * @var \GuzzleHttp\ClientInterface
   */
  protected $httpClient;

  /**
   * HttpClientWrapper constructor.
   *
   * @param \GuzzleHttp\ClientInterface $httpClient
   *   Guzzle HTTP client service, from core http_client.
   */
  public function __construct(GuzzleClientInterface $httpClient) {
    $this->httpClient = $httpClient;
  }

  /**
   * {@inheritdoc}
   */
  public function retrieveResponse(UriInterface $endpoint, $requestBody, array $extraHeaders = [], $method = 'POST') {
    $response = $this->httpClient
      ->request($method, $endpoint
      ->getAbsoluteUri(), [
      'headers' => $extraHeaders,
      'form_params' => $requestBody,
    ]);
    return $response
      ->getBody()
      ->getContents();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HttpClientWrapper::$httpClient protected property Guzzle HTTP Client service.
HttpClientWrapper::retrieveResponse public function
HttpClientWrapper::__construct public function HttpClientWrapper constructor.