You are here

class ZoomAPIUser in Zoom API 7

Zoom API User Class.

Hierarchy

Expanded class hierarchy of ZoomAPIUser

File

includes/zoomapi.user.classes.inc, line 14
User classes for Zoom API.

View source
class ZoomAPIUser extends ZoomAPI {

  /**
   * Create User.
   *
   * @param string $email
   *   The email to assign to the account.
   * @param int $type
   *   The type of account to create:
   *   - 1: Basic user.
   *   - 2: Pro user.
   *   - 3: Corp user.
   * @param array $options
   *   An array of the optional user configuration options.
   *
   * @return array
   *   The created user account.
   */
  public function create($email, $type, $options = []) {
    $options['email'] = $email;
    $options['type'] = $type;
    return $this
      ->sendRequest('user/create', $options);
  }

  /**
   * Create Custom User.
   *
   * A Zoom user account without a password. Users are not able to log into the
   * Zoom app or website with this account.
   *
   * @param string $email
   *   The email to assign to the account.
   * @param int $type
   *   The type of account to create:
   *   - 1: Basic user.
   *   - 2: Pro user.
   *   - 3: Corp user.
   * @param array $options
   *   An array of the optional user configuration options.
   *
   * @return array
   *   The created user account.
   */
  public function custcreate($email, $type, $options = []) {
    $options['email'] = $email;
    $options['type'] = $type;
    return $this
      ->sendRequest('user/custcreate', $options);
  }

  /**
   * Delete User.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   * @param int $type
   *   Optional value to indicate existing or pending user.
   *   - 0: Existing user (default).
   *   - 1: Pending user.
   *
   * @return array
   *   See api documentation.
   */
  public function delete($zoom_user_id, $type = 0) {
    $data = [
      'id' => $zoom_user_id,
      'type' => $type,
    ];
    return $this
      ->sendRequest('user/delete', $data);
  }

  /**
   * Deactivate User.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   *
   * @return array
   *   See api documentation.
   */
  public function deactivate($zoom_user_id) {
    $data = [
      'id' => $zoom_user_id,
    ];
    return $this
      ->sendRequest('user/deactivate', $data);
  }

  /**
   * List (existing) Users.
   *
   * @param int $page_size
   *   The number of results to return per page.
   * @param int $page_number
   *   The page number to return.
   *
   * @return array
   *   List of users and other metadata.
   *
   * @todo confirm that this does not include pending users.
   */
  public function list($page_size = 30, $page_number = 1) {
    $data = [
      'page_size' => $page_size,
      'page_number' => $page_number,
    ];
    return $this
      ->sendRequest('user/list', $data);
  }

  /**
   * List (pending) Users.
   *
   * @param int $page_size
   *   The number of results to return per page.
   * @param int $page_number
   *   The page number to return.
   *
   * @return array
   *   List of users and other metadata.
   */
  public function pending($page_size = 30, $page_number = 1) {
    $data = [
      'page_size' => $page_size,
      'page_number' => $page_number,
    ];
    return $this
      ->sendRequest('user/pending', $data);
  }

  /**
   * Get User Info.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   *
   * @return array
   *   The created user account.
   */
  public function get($zoom_user_id) {
    $data = [
      'id' => $zoom_user_id,
    ];
    return $this
      ->sendRequest('user/get', $data);
  }

  /**
   * Update User.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   * @param array $options
   *   An array of the optional user configuration options.
   *
   * @return array
   *   Array containing date/time updated.
   */
  public function update($zoom_user_id, array $options) {
    $options['id'] = $zoom_user_id;
    return $this
      ->sendRequest('user/update', $options);
  }

  /**
   * Update User Password.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   * @param string $password
   *   The user password.
   *
   * @return array
   *   Array containing date/time updated.
   */
  public function updatepassword($zoom_user_id, $password) {
    $data = [
      'id' => $zoom_user_id,
      'password' => $password,
    ];
    return $this
      ->sendRequest('user/updatepassword', $data);
  }

  /**
   * Set User Assistant.
   *
   * @param string $assistant_email
   *   The email address for the assistant account.
   * @param array $host
   *   At least one of the following must be provided. If the zoom_user_id is
   *   provided the the email is ignored.
   *   - zoom_user_id: The host Zoom user ID.
   *   - email: The host Zoom user email address.
   *
   * @return array
   *   An array containing transaction metadata.
   *
   * @todo confirm only one assistant per host.
   */
  public function assistantSet($assistant_email, array $host) {
    $data = [
      'assistant_email' => $assistant_email,
    ];
    if (!empty($host['zoom_user_id'])) {
      $data['id'] = $host['zoom_user_id'];
    }
    else {
      $data['host_email'] = $host['email'];
    }
    return $this
      ->sendRequest('user/assistant/set', $data);
  }

  /**
   * Delete User Assistant.
   *
   * @param array $host
   *   At least one of the following must be provided. If the zoom_user_id is
   *   provided the the email is ignored.
   *   - zoom_user_id: The host Zoom user ID.
   *   - email: The host Zoom user email address.
   *
   * @return array
   *   An array containing transaction metadata.
   */
  public function assistantDelete(array $host) {
    if (!empty($host['zoom_user_id'])) {
      $data['id'] = $host['zoom_user_id'];
    }
    else {
      $data['host_email'] = $host['email'];
    }
    return $this
      ->sendRequest('user/assistant/delete', $data);
  }

  /**
   * Delete User Permanently.
   *
   * @param array $user_identification
   *   At least one of the following must be provided. If the zoom_user_id is
   *   provided the the email is ignored.
   *   - zoom_user_id: The host Zoom user ID.
   *   - email: The host Zoom user email address.
   *
   * @return array
   *   An array containing transaction metadata.
   */
  public function permanentdelete(array $user_identification) {
    if (!empty($user_identification['zoom_user_id'])) {
      $data['id'] = $user_identification['zoom_user_id'];
    }
    else {
      $data['email'] = $user_identification['email'];
    }
    return $this
      ->sendRequest('user/permanentdelete', $data);
  }

  /**
   * Upload User Picture.
   *
   * @param string $zoom_user_id
   *   The user ID generated when the user account was created.
   * @param string $image_url
   *   A publicly accessible URL to the image. Must be a jpg/jpeg file.
   *
   * @return array
   *   An array containing transaction metadata.
   *
   * @todo confirm only jpg/jpeg images.
   */
  public function uploadpicture($zoom_user_id, $image_url) {
    $data = [
      'id' => $zoom_user_id,
      'pic_file' => $image_url,
    ];
    return $this
      ->sendRequest('user/uploadpicture', $data);
  }

  /**
   * Check User Email.
   *
   * Check if the user exists.
   *
   * @param string $email
   *   The email to check if account exists.
   *
   * @return bool
   *   TRUE if the account exists, FALSE otherwise.
   */
  public function checkemail($email) {
    $data['email'] = $email;
    $response = $this
      ->sendRequest('user/checkemail', $data);
    return !empty($response['existed_email']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ZoomAPI::$apiKey private property API Key.
ZoomAPI::$apiSecret private property API Secret.
ZoomAPI::$apiUrl private property API URL.
ZoomAPI::sendRequest protected function Send Request.
ZoomAPI::__construct public function Class constructor.
ZoomAPIUser::assistantDelete public function Delete User Assistant.
ZoomAPIUser::assistantSet public function Set User Assistant.
ZoomAPIUser::checkemail public function Check User Email.
ZoomAPIUser::create public function Create User.
ZoomAPIUser::custcreate public function Create Custom User.
ZoomAPIUser::deactivate public function Deactivate User.
ZoomAPIUser::delete public function Delete User.
ZoomAPIUser::get public function Get User Info.
ZoomAPIUser::list public function List (existing) Users.
ZoomAPIUser::pending public function List (pending) Users.
ZoomAPIUser::permanentdelete public function Delete User Permanently.
ZoomAPIUser::update public function Update User.
ZoomAPIUser::updatepassword public function Update User Password.
ZoomAPIUser::uploadpicture public function Upload User Picture.