diff --git a/Source/ZoomNet/Resources/IWebinars.cs b/Source/ZoomNet/Resources/IWebinars.cs index 7d1d5282..e57d9214 100644 --- a/Source/ZoomNet/Resources/IWebinars.cs +++ b/Source/ZoomNet/Resources/IWebinars.cs @@ -76,6 +76,23 @@ public interface IWebinars /// Thrown when an exception occured while creating the webinar. Task CreateRecurringWebinarAsync(string userId, string topic, string agenda, DateTime? start, int duration, RecurrenceInfo recurrence, string password = null, WebinarSettings settings = null, IDictionary trackingFields = null, CancellationToken cancellationToken = default); + /// + /// Updates an existing scheduled webinar. + /// + /// The webinar ID. + /// Webinar topic. + /// Webinar description. + /// Webinar start time. + /// Webinar duration (minutes). + /// 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. + /// Webinar settings. + /// Tracking fields. + /// The cancellation token. + /// + /// The async task. + /// + Task UpdateScheduledWebinarAsync(long webinarId, string topic = null, string agenda = null, DateTime? start = null, int? duration = null, string password = null, WebinarSettings settings = null, IDictionary trackingFields = null, CancellationToken cancellationToken = default); + /// /// Retrieve the details of a webinar. /// @@ -87,6 +104,24 @@ public interface IWebinars /// Task GetAsync(long webinarId, string occurrenceId = null, CancellationToken cancellationToken = default); + /// + /// Updates an existing recurring webinar for a user. + /// + /// The webinar ID. + /// Webinar topic. + /// Webinar description. + /// Webinar start time. + /// Webinar duration (minutes). + /// Recurrence information. + /// 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. + /// Webinar settings. + /// Tracking fields. + /// The cancellation token. + /// + /// The async task. + /// + 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 trackingFields = null, CancellationToken cancellationToken = default); + /// /// Delete a webinar. /// diff --git a/Source/ZoomNet/Resources/Meetings.cs b/Source/ZoomNet/Resources/Meetings.cs index 3e79b657..59e7c095 100644 --- a/Source/ZoomNet/Resources/Meetings.cs +++ b/Source/ZoomNet/Resources/Meetings.cs @@ -724,7 +724,7 @@ public Task StartLiveStreamAsync(long meetingId, bool displaySpeakerName, string { var data = new JObject() { - { "action", "Start" }, + { "action", "start" }, { "settings", new JObject() { diff --git a/Source/ZoomNet/Resources/Webinars.cs b/Source/ZoomNet/Resources/Webinars.cs index 2a8f4e56..126ecab9 100644 --- a/Source/ZoomNet/Resources/Webinars.cs +++ b/Source/ZoomNet/Resources/Webinars.cs @@ -90,7 +90,7 @@ public Task> GetAllAsync(string userId, int /// Webinar description. /// Webinar start time. /// Webinar duration (minutes). - /// Password to join the webinar. Password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters. + /// 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. /// Webinar settings. /// Tracking fields. /// The cancellation token. @@ -120,6 +120,47 @@ public Task CreateScheduledWebinarAsync(string userId, string .AsObject(); } + /// + /// Updates an existing scheduled webinar. + /// + /// The webinar ID. + /// Webinar topic. + /// Webinar description. + /// Webinar start time. + /// Webinar duration (minutes). + /// 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. + /// Webinar settings. + /// Tracking fields. + /// The cancellation token. + /// + /// The async task. + /// + public async Task UpdateScheduledWebinarAsync(long webinarId, string topic = null, string agenda = null, DateTime? start = null, int? duration = null, string password = null, WebinarSettings settings = null, IDictionary 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); + 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"); + } + } + /// /// Creates a recurring webinar for a user. /// @@ -129,7 +170,7 @@ public Task CreateScheduledWebinarAsync(string userId, string /// Webinar start time. /// Webinar duration (minutes). /// Recurrence information. - /// Password to join the webinar. Password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters. + /// 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. /// Webinar settings. /// Tracking fields. /// The cancellation token. @@ -162,6 +203,49 @@ public Task CreateRecurringWebinarAsync(string userId, string .AsObject(); } + /// + /// Updates an existing recurring webinar for a user. + /// + /// The webinar ID. + /// Webinar topic. + /// Webinar description. + /// Webinar start time. + /// Webinar duration (minutes). + /// Recurrence information. + /// 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. + /// Webinar settings. + /// Tracking fields. + /// The cancellation token. + /// + /// The async task. + /// + 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 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"); + } + } + /// /// Retrieve the details of a webinar. ///