Skip to content

Commit

Permalink
Merge branch 'release/0.19.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Feb 9, 2021
2 parents 8972b5d + 9115336 commit ab12571
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 16 deletions.
22 changes: 21 additions & 1 deletion Source/ZoomNet.IntegrationTests/Tests/Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,44 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
// GET MY USER
var myUser = await client.Users.GetCurrentAsync(cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"My user retrieved. My email address is {myUser.Email}").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// GET MY ASSISTANTS
var myAssistants = await client.Users.GetAssistantsAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"My user has {myAssistants.Length} assistants").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// GET MY SCHEDULERS
var mySchedulers = await client.Users.GetSchedulersAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"My user has {mySchedulers.Length} schedulers").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// GET MY SETTINGS
var mySettings = await client.Users.GetSettingsAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("My settings retrieved").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

var myMeetingAuthSettings = await client.Users.GetMeetingAuthenticationSettingsAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("My meeting settings retrieved").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

var myRecordingAuthSettings = await client.Users.GetRecordingAuthenticationSettingsAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync("My settings retrieved").ConfigureAwait(false);
await log.WriteLineAsync("My recording authentication settings retrieved").ConfigureAwait(false);
await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// GET MY PERMISSIONS
var myPermissions = await client.Users.GetPermissionsAsync(myUser.Id, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"My permissions retrieved: I have been granted {myPermissions.Length} permissions").ConfigureAwait(false);
//await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// CREATE NEW USER (commenting out this integration test because I currently do not have permission to create users)
//var newUser = await client.Users.CreateAsync("[email protected]", "ZoomNet", "Integration Testing", UserType.Basic, UserCreateType.Normal, cancellationToken).ConfigureAwait(false);
//await log.WriteLineAsync($"New user created: {newUser.Id}").ConfigureAwait(false);
//await Task.Delay(500, cancellationToken).ConfigureAwait(false);

// DELETE USER
//await client.Users.DeleteAsync(newUser.Id, null, false, false, false, cancellationToken).ConfigureAwait(false);
//await log.WriteLineAsync($"User {newUser.Id} deleted").ConfigureAwait(false);
}
}
}
2 changes: 1 addition & 1 deletion Source/ZoomNet.IntegrationTests/Tests/Webinars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
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);
var newRecurringWebinar = await client.Webinars.CreateRecurringWebinarAsync(userId, "ZoomNet Integration Testing: recurring webinar", "The agenda", start, duration, recurrenceInfo, "p@ss!w0rd", settings, trackingFields, cancellationToken: cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Recurring webinar {newRecurringWebinar.Id} created").ConfigureAwait(false);

await client.Webinars.DeleteAsync(newRecurringWebinar.Id, null, false, cancellationToken).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomNet/Models/Recording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Recording
/// <summary>Gets or sets the recording id.</summary>
/// <value>The id.</value>
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public long Id { get; set; }
public string Id { get; set; }

/// <summary>Gets or sets the ID of the user account.</summary>
/// <value>The account id.</value>
Expand Down
22 changes: 22 additions & 0 deletions Source/ZoomNet/Models/Template.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace ZoomNet.Models
{
/// <summary>
/// Details of a webinar template.
/// </summary>
public class Template
{
/// <summary>
/// Gets or sets the Id of the template.
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }

/// <summary>
/// Gets or sets the Name of the template.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
}
}
45 changes: 45 additions & 0 deletions Source/ZoomNet/Models/UserCreateType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;

namespace ZoomNet.Models
{
/// <summary>
/// Enumeration to specify how to create a new user.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum UserCreateType
{
/// <summary>
/// User will get an email sent from Zoom.
/// There is a confirmation link in this email.
/// User will then need to click this link to activate their account to the Zoom service.
/// The user can set or change their password in Zoom.
/// </summary>
[EnumMember(Value = "create")]
Normal,

/// <summary>
/// This action is provided for enterprise customer who has a managed domain.
/// This feature is disabled by default because of the security risk involved in creating a user who does not belong to your domain without notifying the user.
/// </summary>
[EnumMember(Value = "autoCreate")]
Auto,

/// <summary>
/// This action is provided for API partner only.
/// User created in this way has no password and is not able to log into the Zoom web site or client.
/// </summary>
[EnumMember(Value = "custCreate")]
Cust,

/// <summary>
/// This action is provided for enabled "Pre-provisioning SSO User" option.
/// User created in this way has no password.
/// If it is not a basic user, will generate a Personal Vanity URL using user name (no domain) of the provisioning email.
/// If user name or pmi is invalid or occupied, will use random number/random personal vanity URL.
/// </summary>
[EnumMember(Value = "ssoCreate")]
SSo
}
}
3 changes: 2 additions & 1 deletion Source/ZoomNet/Resources/IUsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public interface IUsers
/// <param name="firstName">First name.</param>
/// <param name="lastName">Last name.</param>
/// <param name="type">The type of user.</param>
/// <param name="createType">Specify how to create the user.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The new user.
/// </returns>
Task<User> CreateAsync(string email, string firstName = null, string lastName = null, UserType type = UserType.Basic, CancellationToken cancellationToken = default);
Task<User> CreateAsync(string email, string firstName = null, string lastName = null, UserType type = UserType.Basic, UserCreateType createType = UserCreateType.Normal, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve the information of a specific user on a Zoom account.
Expand Down
13 changes: 12 additions & 1 deletion Source/ZoomNet/Resources/IWebinars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ public interface IWebinars
/// <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="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>
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);
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, string templateId = null, CancellationToken cancellationToken = default);

/// <summary>
/// Update the details of a webinar occurrence.
Expand Down Expand Up @@ -431,5 +432,15 @@ public interface IWebinars
/// An array of <see cref="TrackingSource" />.
/// </returns>
Task<TrackingSource[]> GetTrackingSourcesAsync(long webinarId, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve all the templates created for a user.
/// </summary>
/// <param name="userId">The user Id or email address.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// An array of <see cref="Template" />.
/// </returns>
Task<Template[]> GetWebinarTemplatesAsync(string userId, CancellationToken cancellationToken = default);
}
}
12 changes: 4 additions & 8 deletions Source/ZoomNet/Resources/Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,24 @@ public Task<PaginatedResponse<User>> GetAllAsync(UserStatus status = UserStatus.
/// <param name="firstName">First name.</param>
/// <param name="lastName">Last name.</param>
/// <param name="type">The type of user.</param>
/// <param name="createType">Specify how to create the user.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The new user.
/// </returns>
/// <remarks>
/// User will get an email sent from Zoom. There is a confirmation link in this email.
/// The user will then need to use the link to activate their Zoom account.
/// The user can then set or change their password.
/// </remarks>
public Task<User> CreateAsync(string email, string firstName = null, string lastName = null, UserType type = UserType.Basic, CancellationToken cancellationToken = default)
public Task<User> CreateAsync(string email, string firstName = null, string lastName = null, UserType type = UserType.Basic, UserCreateType createType = UserCreateType.Normal, CancellationToken cancellationToken = default)
{
var data = new JObject()
{
{ "action", "create" }
{ "action", JToken.Parse(JsonConvert.SerializeObject(createType)).ToString() }
};
data.AddPropertyIfValue("user_info/email", email);
data.AddPropertyIfEnumValue("user_info/type", type);
data.AddPropertyIfValue("user_info/first_name", firstName);
data.AddPropertyIfValue("user_info/last_name", lastName);

return _client
.PostAsync($"users")
.PostAsync("users")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsObject<User>();
Expand Down
24 changes: 21 additions & 3 deletions Source/ZoomNet/Resources/Webinars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Task<PaginatedResponseWithToken<Webinar>> GetAllAsync(string userId, int
/// <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.</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.
Expand All @@ -113,10 +113,10 @@ public Task<ScheduledWebinar> CreateScheduledWebinarAsync(string userId, string
data.AddPropertyIfValue("timezone", "UTC");
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")
.WithArgument("template_id", templateId)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsObject<ScheduledWebinar>();
Expand All @@ -134,12 +134,13 @@ public Task<ScheduledWebinar> CreateScheduledWebinarAsync(string userId, string
/// <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, string password = null, WebinarSettings settings = null, IDictionary<string, string> trackingFields = null, CancellationToken cancellationToken = default)
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, string templateId = null, CancellationToken cancellationToken = default)
{
var data = new JObject()
{
Expand All @@ -156,6 +157,7 @@ public Task<RecurringWebinar> CreateRecurringWebinarAsync(string userId, string
data.AddPropertyIfValue("timezone", "UTC");
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")
Expand Down Expand Up @@ -774,6 +776,22 @@ public Task<TrackingSource[]> GetTrackingSourcesAsync(long webinarId, Cancellati
.AsObject<TrackingSource[]>("tracking_sources");
}

/// <summary>
/// Retrieve all the templates created for a user.
/// </summary>
/// <param name="userId">The user Id or email address.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// An array of <see cref="Template" />.
/// </returns>
public Task<Template[]> GetWebinarTemplatesAsync(string userId, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"users/{userId}/webinar_templates")
.WithCancellationToken(cancellationToken)
.AsObject<Template[]>("templates");
}

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

0 comments on commit ab12571

Please sign in to comment.