/// <summary> /// Creates a recurring webinar for a user. /// </summary> /// <param name="userId">The user Id or email address.</param> /// <param name="topic">Webinar topic.</param> /// <param name="agenda">Webinar description.</param> /// <param name="start">Webinar start time.</param> /// <param name="duration">Webinar duration (minutes).</param> /// <param name="recurrence">Recurrence information.</param> /// <param name="password"> /// Password to join the webinar. Password may only contain the following characters: [a-z A-Z 0-9 @ /// - _ *]. Max of 10 characters. /// </param> /// <param name="settings">Webinar settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The new webinar. /// </returns> /// <exception cref="System.Exception">Thrown when an exception occured while creating the webinar.</exception> public Task <RecurringWebinar> CreateRecurringWebinarAsync(string userId, string topic, string agenda, DateTime?start, int duration, RecurrenceInfo recurrence, string password = null, WebinarSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default) { var data = new JObject { // 6 = Recurring with no fixed time // 9 = Recurring with fixed time { "type", start.HasValue ? 9 : 6 } }; data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("start_time", start?.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfValue("recurrence", recurrence); data.AddPropertyIfValue("timezone", "UTC"); data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject { { "field", tf.Key }, { "value", tf.Value } })); return(_client .PostAsync($"users/{userId}/webinars") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <RecurringWebinar>()); }
public async Task RunAsync(string userId, IZoomClient client, TextWriter log, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return; } await log.WriteLineAsync("\n***** WEBINARS *****\n").ConfigureAwait(false); // GET ALL THE WEBINARS var paginatedWebinars = await client.Webinars.GetAllAsync(userId, 30, null, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"There are {paginatedWebinars.TotalRecords} webinars for user {userId}").ConfigureAwait(false); // CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES var cleanUpTasks = paginatedWebinars.Records .Union(paginatedWebinars.Records) .Where(m => m.Topic.StartsWith("ZoomNet Integration Testing:")) .Select(async oldWebinar => { await client.Webinars.DeleteAsync(oldWebinar.Id, null, false, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Webinar {oldWebinar.Id} deleted").ConfigureAwait(false); await Task.Delay(250, cancellationToken).ConfigureAwait(false); // Brief pause to ensure Zoom has time to catch up }); await Task.WhenAll(cleanUpTasks).ConfigureAwait(false); var settings = new WebinarSettings() { ApprovalType = MeetingApprovalType.Manual }; var trackingFields = new Dictionary <string, string>() { { "field1", "value1" }, { "field2", "value2" } }; // Scheduled webinar var start = DateTime.UtcNow.AddMonths(1); var duration = 30; var newScheduledWebinar = await client.Webinars.CreateScheduledWebinarAsync(userId, "ZoomNet Integration Testing: scheduled webinar", "The agenda", start, duration, "p@ss!w0rd", settings, trackingFields, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Scheduled webinar {newScheduledWebinar.Id} created").ConfigureAwait(false); await client.Webinars.DeleteAsync(newScheduledWebinar.Id, null, false, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Scheduled webinar {newScheduledWebinar.Id} deleted").ConfigureAwait(false); // Recurring webinar var recurrenceInfo = new RecurrenceInfo() { EndTimes = 2, WeeklyDays = new[] { DayOfWeek.Monday, DayOfWeek.Friday }, Type = RecurrenceType.Weekly }; var newRecurringWebinar = await client.Webinars.CreateRecurringWebinarAsync(userId, "ZoomNet Integration Testing: recurring webinar", "The agenda", start, duration, recurrenceInfo, "p@ss!w0rd", settings, trackingFields, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Recurring webinar {newRecurringWebinar.Id} created").ConfigureAwait(false); await client.Webinars.DeleteAsync(newRecurringWebinar.Id, null, false, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Recurring webinar {newRecurringWebinar.Id} deleted").ConfigureAwait(false); }
/// <summary> /// Update a scheduled webinar for a user. /// </summary> /// <param name="webinarId">Webinar Id.</param> /// <param name="topic">Webinar topic.</param> /// <param name="agenda">Webinar description.</param> /// <param name="start">Webinar start time.</param> /// <param name="duration">Webinar duration (minutes).</param> /// <param name="password">Password to join the webinar. Password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters.</param> /// <param name="settings">Webinar settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> /// <exception cref="System.Exception">Thrown when an exception occured while updating the webinar.</exception> public Task UpdateScheduledWebinarAsync(string webinarId, string topic, string agenda, DateTime start, int duration, string password = null, WebinarSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default) { var data = new JObject() { { "type", 5 } }; data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("start_time", start.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfValue("timezone", "UTC"); data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject() { { "field", tf.Key }, { "value", tf.Value } })); return(_client .PatchAsync($"webinars/{webinarId}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Updates an existing recurring webinar for a user. /// </summary> /// <param name="webinarId">The webinar ID.</param> /// <param name="topic">Webinar topic.</param> /// <param name="agenda">Webinar description.</param> /// <param name="start">Webinar start time.</param> /// <param name="duration">Webinar duration (minutes).</param> /// <param name="recurrence">Recurrence information.</param> /// <param name="password">Password to join the webinar. By default the password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters. This can be updated within Zoom account settings.</param> /// <param name="settings">Webinar settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public async Task UpdateRecurringWebinarAsync(long webinarId, string topic = null, string agenda = null, DateTime?start = null, int?duration = null, RecurrenceInfo recurrence = null, string password = null, WebinarSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default) { var data = new JObject(); data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("start_time", start?.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfValue("recurrence", recurrence); if (start.HasValue) { data.Add("timezone", "UTC"); } data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject() { { "field", tf.Key }, { "value", tf.Value } })); var result = await _client .PatchAsync($"webinars/{webinarId}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage() .ConfigureAwait(false); if (result.StatusCode == System.Net.HttpStatusCode.OK) { // Zoom returns an HTTP 200 message when there is no webinar subscription and instead returns a 204 after a successful update throw new NotSupportedException("Webinar subscription plan is missing. Enable webinar for this user once the subscription is added"); } }
/// <summary> /// Update the details of a webinar occurence. /// </summary> /// <param name="webinarId">The webinar ID.</param> /// <param name="occurrenceId">The webinar occurrence id.</param> /// <param name="agenda">Webinar description.</param> /// <param name="start">Webinar start time.</param> /// <param name="duration">Webinar duration (minutes).</param> /// <param name="timeZone">The time zone for start time.</param> /// <param name="settings">Webinar settings.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public Task UpdateWebinarOccurrenceAsync(long webinarId, string occurrenceId, string agenda = null, DateTime?start = null, int?duration = null, TimeZones?timeZone = null, WebinarSettings settings = null, CancellationToken cancellationToken = default) { var data = new JObject(); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("start_time", start.ToZoomFormat(timeZone)); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfEnumValue("timezone", timeZone); data.AddPropertyIfValue("settings", settings); return(_client .PatchAsync($"webinars/{webinarId}") .WithArgument("occurrence_id", occurrenceId) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Creates a recurring webinar for a user. /// </summary> /// <param name="userId">The user Id or email address.</param> /// <param name="topic">Webinar topic.</param> /// <param name="agenda">Webinar description.</param> /// <param name="start">Webinar start time.</param> /// <param name="duration">Webinar duration (minutes).</param> /// <param name="recurrence">Recurrence information.</param> /// <param name="timeZone">The time zone for start time.</param> /// <param name="password">Password to join the webinar. By default the password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters. This can be updated within Zoom account settings.</param> /// <param name="settings">Webinar settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="templateId">Template Identifer. If passed in, Zoom advise using the userId in the <paramref name="userId"/> field, rather than email address.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The new webinar. /// </returns> /// <exception cref="System.Exception">Thrown when an exception occured while creating the webinar.</exception> public Task <RecurringWebinar> CreateRecurringWebinarAsync(string userId, string topic, string agenda, DateTime?start, int duration, RecurrenceInfo recurrence, TimeZones?timeZone = TimeZones.UTC, string password = null, WebinarSettings settings = null, IDictionary <string, string> trackingFields = null, string templateId = null, CancellationToken cancellationToken = default) { var data = new JObject() { // 6 = Recurring with no fixed time // 9 = Recurring with fixed time { "type", start.HasValue ? 9 : 6 } }; data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("start_time", start.ToZoomFormat(timeZone)); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfValue("recurrence", recurrence); data.AddPropertyIfEnumValue("timezone", timeZone); data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject() { { "field", tf.Key }, { "value", tf.Value } })); data.AddPropertyIfValue("template_id", templateId); return(_client .PostAsync($"users/{userId}/webinars") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <RecurringWebinar>()); }