You are here

public function ZoomApiClient::request in Zoom API 2.0.x

Same name and namespace in other branches
  1. 8 src/Client/ZoomApiClient.php \Drupal\zoomapi\Client\ZoomApiClient::request()

Utilizes Drupal's httpClient to connect to the Zoom API.

Info: https://marketplace.zoom.us/docs/api-reference/introduction Currently just supports JWT authentication.

Parameters

string $method: get, post, patch, delete, etc. See Guzzle documentation.

string $endpoint: The Zoom API endpoint (ex. users)

array $query: Any Query Parameters defined in the API spec.

array $body: Array that will get converted to JSON for some requests.

Return value

mixed RequestException or \GuzzleHttp\Psr7\Response body

Overrides ZoomApiClientInterface::request

File

src/Client/ZoomApiClient.php, line 125

Class

ZoomApiClient
Uses http client to interact with the Zoom API.

Namespace

Drupal\zoomapi\Client

Code

public function request(string $method, string $endpoint, array $query = [], array $body = []) {
  try {
    $response = $this->httpClient
      ->{$method}($this->baseUri . $endpoint, $this
      ->buildOptions($query, $body));

    // TODO: Add additional response options.
    $payload = Json::decode($response
      ->getBody()
      ->getContents());
    return $payload;
  } catch (RequestException $exception) {

    // Log Any exceptions.
    $this->logger
      ->error('Failed to complete Zoom API Task "%error"', [
      '%error' => $exception
        ->getMessage(),
    ]);
    throw $exception;
  }
}