You are here

function zoomapi_migrate_webhooks in Zoom API 7.2

Migrate Webhooks.

File

./zoomapi.migrate.inc, line 11
Logic to migrate from v1 to v2.

Code

function zoomapi_migrate_webhooks() {

  // Do not create webhooks v2 if they are not currently enabled for v1.
  if (!variable_get('zoomapi_webhooks_enabled', FALSE)) {
    return;
  }

  // If we do not have the webhooks username/password then do not create
  // webhooks v2.
  $auth_user = variable_get('zoomapi_webhooks_username', FALSE);
  $auth_password = variable_get('zoomapi_webhooks_password', FALSE);
  if (!$auth_user || !$auth_password) {
    return;
  }
  $zoom_client = zoomapi_client();
  $zoom_client
    ->webhooks()
    ->options([
    'version' => 'v2',
  ]);
  $webhook = [
    'url' => url('zoomapi/webhook', [
      'absolute' => TRUE,
    ]),
    'auth_user' => $auth_user,
    'auth_password' => $auth_password,
    'events' => [
      'meeting_started',
      'meeting_ended',
      'meeting_jbh',
      'meeting_join',
      'recording_completed',
      'participant_joined',
      'participant_left',
      'meeting_registered',
      'recording_transcript_completed',
    ],
  ];
  $zoom_client
    ->api('webhook')
    ->create($webhook);
}