Skip to content

Commit

Permalink
(GH-176) Create invite links
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Feb 18, 2022
1 parent 094c6ef commit 0238622
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/ZoomNet.IntegrationTests/Tests/Meetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
await log.WriteLineAsync($"This meeting has {pendingRegistrations.TotalRecords} registrations awaiting approval and {approvedRegistrations.TotalRecords} approved registrations").ConfigureAwait(false);

await client.Meetings.CancelRegistrantAsync(scheduledMeeting.Id, registrantInfo1.Id, "[email protected]", null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Regristration {registrant1.Id} was canceled").ConfigureAwait(false);
await log.WriteLineAsync($"Registration {registrant1.Id} was canceled").ConfigureAwait(false);

await client.Meetings.RejectRegistrantAsync(scheduledMeeting.Id, registrantInfo2.Id, "[email protected]", null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Regristration {registrant2.Id} was rejected").ConfigureAwait(false);
await log.WriteLineAsync($"Registration {registrant2.Id} was rejected").ConfigureAwait(false);

await client.Meetings.DeleteRegistrantAsync(scheduledMeeting.Id, registrantInfo1.Id, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Regristration {registrant1.Id} was deleted").ConfigureAwait(false);
await log.WriteLineAsync($"Registration {registrant1.Id} was deleted").ConfigureAwait(false);

await client.Meetings.DeleteRegistrantAsync(scheduledMeeting.Id, registrantInfo2.Id, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Regristration {registrant1.Id} was deleted").ConfigureAwait(false);
await log.WriteLineAsync($"Registration {registrant1.Id} was deleted").ConfigureAwait(false);

await client.Meetings.DeleteAsync(newScheduledMeeting.Id, null, false, false, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Scheduled meeting {newScheduledMeeting.Id} deleted").ConfigureAwait(false);
Expand All @@ -179,6 +179,9 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
var recurringMeeting = (RecurringMeeting)await client.Meetings.GetAsync(newRecurringMeeting.Id, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Recurring meeting {recurringMeeting.Id} retrieved").ConfigureAwait(false);

var inviteLinks = await client.Meetings.CreateInviteLinksAsync(recurringMeeting.Id, new[] { "Bob", "Bill", "John" }, 7200, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"{inviteLinks.Length} invite links created").ConfigureAwait(false);

var occurenceId = recurringMeeting.Occurrences[0].OccurrenceId;
await client.Meetings.UpdateMeetingOccurrenceAsync(newRecurringMeeting.Id, occurenceId, duration: 99, cancellationToken: cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Recurring meeting {newRecurringMeeting.Id} occurence {occurenceId} updated").ConfigureAwait(false);
Expand Down
23 changes: 23 additions & 0 deletions Source/ZoomNet/Models/InviteLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Newtonsoft.Json;

namespace ZoomNet.Models
{
/// <summary>
/// Meeting invite link.
/// </summary>
public class InviteLink
{
/// <summary>
/// Gets or sets the display name of the invited attendee.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the URL to join the meeting.
/// </summary>
/// <value>The join URL.</value>
[JsonProperty(PropertyName = "join_url", NullValueHandling = NullValueHandling.Ignore)]
public string JoinUrl { get; set; }
}
}
12 changes: 12 additions & 0 deletions Source/ZoomNet/Resources/IMeetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,5 +482,17 @@ public interface IMeetings
/// An array of <see cref="MeetingTemplate" />.
/// </returns>
Task<MeetingTemplate[]> GetTemplatesAsync(string userId, CancellationToken cancellationToken = default);

/// <summary>
/// Create a batch of invitation links for a meeting.
/// </summary>
/// <param name="meetingId">The meeting ID.</param>
/// <param name="names">The display name of the attendees.</param>
/// <param name="timeToLive">The invite link's expiration time, in seconds.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// An array of <see cref="InviteLink" />.
/// </returns>
Task<InviteLink[]> CreateInviteLinksAsync(long meetingId, IEnumerable<string> names, long timeToLive = 7200, CancellationToken cancellationToken = default);
}
}
18 changes: 18 additions & 0 deletions Source/ZoomNet/Resources/Meetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,24 @@ public Task<MeetingTemplate[]> GetTemplatesAsync(string userId, CancellationToke
.AsObject<MeetingTemplate[]>("templates");
}

/// <inheritdoc/>
public Task<InviteLink[]> CreateInviteLinksAsync(long meetingId, IEnumerable<string> names, long timeToLive = 7200, CancellationToken cancellationToken = default)
{
if (names == null || !names.Any()) throw new ArgumentNullException("You must provide at least one name", nameof(names));

var data = new JObject()
{
{ "ttl", timeToLive }
};
data.AddPropertyIfValue("attendees", names?.Select(n => new JObject { { "name", n } }).ToArray());

return _client
.PostAsync($"meetings/{meetingId}/invite_links")
.WithBody(data)
.WithCancellationToken(cancellationToken)
.AsObject<InviteLink[]>("attendees");
}

private Task UpdateRegistrantsStatusAsync(long meetingId, IEnumerable<(string RegistrantId, string RegistrantEmail)> registrantsInfo, string status, string occurrenceId = null, CancellationToken cancellationToken = default)
{
var data = new JObject();
Expand Down

0 comments on commit 0238622

Please sign in to comment.