private static JObject CreateJObject(Parameter <AlertType?> type, Parameter <string> emailTo, Parameter <Frequency?> frequency, Parameter <int?> percentage) { var result = new JObject(); result.AddPropertyIfEnumValue("type", type); result.AddPropertyIfValue("email_to", emailTo); result.AddPropertyIfEnumValue("frequency", frequency); result.AddPropertyIfValue("percentage", percentage); return(result); }
/// <summary> /// Creates a scheduled meeting for a user. /// </summary> /// <param name="userId">The user Id or email address.</param> /// <param name="topic">Meeting topic.</param> /// <param name="agenda">Meeting description.</param> /// <param name="start">Meeting start time.</param> /// <param name="duration">Meeting duration (minutes).</param> /// <param name="timeZone">The time zone for start time.</param> /// <param name="password">Password to join the meeting. Password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters.</param> /// <param name="settings">Meeting settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The new meeting. /// </returns> /// <exception cref="System.Exception">Thrown when an exception occured while creating the meeting.</exception> public Task <ScheduledMeeting> CreateScheduledMeetingAsync( string userId, string topic, string agenda, DateTime start, int duration, TimeZones?timeZone = TimeZones.UTC, string password = null, MeetingSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default) { var data = new JObject() { { "type", 2 } }; data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("start_time", start.ToZoomFormat(timeZone)); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfEnumValue("timezone", timeZone); data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject() { { "field", tf.Key }, { "value", tf.Value } })); return(_client .PostAsync($"users/{userId}/meetings") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <ScheduledMeeting>()); }
/// <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="timeZone">The time zone for start time.</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, TimeZones?timeZone = 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.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 } })); 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> /// 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>()); }
/// <summary> /// Update the details of a meeting occurence. /// </summary> /// <param name="meetingId">The meeting ID.</param> /// <param name="occurrenceId">The meeting occurrence id.</param> /// <param name="agenda">Meeting description.</param> /// <param name="start">Meeting start time.</param> /// <param name="duration">Meeting duration (minutes).</param> /// <param name="timeZone">The time zone for start time.</param> /// <param name="settings">Meeting settings.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public Task UpdateMeetingOccurrenceAsync(long meetingId, string occurrenceId, string agenda = null, DateTime?start = null, int?duration = null, TimeZones?timeZone = null, MeetingSettings 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($"meetings/{meetingId}") .WithArgument("occurrence_id", occurrenceId) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Creates a user. /// </summary> /// <param name="email">The email address.</param> /// <param name="firstName">First name.</param> /// <param name="lastName">Last name.</param> /// <param name="type">The type of 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) { var data = new JObject() { { "action", "create" } }; 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") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <User>()); }
private static JObject CreateJObject(Parameter <string> title, Parameter <long?> senderId, Parameter <string> subject, Parameter <string> htmlContent, Parameter <string> textContent, Parameter <IEnumerable <long> > listIds, Parameter <IEnumerable <long> > segmentIds, Parameter <IEnumerable <string> > categories, Parameter <long?> suppressionGroupId, Parameter <string> customUnsubscribeUrl, Parameter <string> ipPool, Parameter <EditorType?> editor) { var result = new JObject(); result.AddPropertyIfValue("title", title); result.AddPropertyIfValue("subject", subject); result.AddPropertyIfValue("sender_id", senderId); result.AddPropertyIfValue("html_content", htmlContent); result.AddPropertyIfValue("plain_content", textContent); result.AddPropertyIfValue("list_ids", listIds); result.AddPropertyIfValue("segment_ids", segmentIds); result.AddPropertyIfValue("categories", categories); result.AddPropertyIfValue("suppression_group_id", suppressionGroupId); result.AddPropertyIfValue("custom_unsubscribe_url", customUnsubscribeUrl); result.AddPropertyIfValue("ip_pool", ipPool); result.AddPropertyIfEnumValue("editor", editor); return(result); }
/// <summary> /// Creates a user. /// </summary> /// <param name="email">The email address.</param> /// <param name="firstName">First name.</param> /// <param name="lastName">Last name.</param> /// <param name="password">User password. Only used when createType is <see cref="UserCreateType.Auto"/>.</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> public Task <User> CreateAsync(string email, string firstName = null, string lastName = null, string password = null, UserType type = UserType.Basic, UserCreateType createType = UserCreateType.Normal, CancellationToken cancellationToken = default) { var data = new JObject() { { "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); data.AddPropertyIfValue("user_info/password", password); return(_client .PostAsync("users") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <User>()); }
/// <summary> /// Update a template version. /// </summary> /// <param name="templateId">The template identifier.</param> /// <param name="versionId">The version identifier.</param> /// <param name="name">The name.</param> /// <param name="subject">The subject.</param> /// <param name="htmlContent">Content of the HTML.</param> /// <param name="textContent">Content of the text.</param> /// <param name="isActive">The is active.</param> /// <param name="editorType">The type of editor.</param> /// <param name="testData">For dynamic templates only, the mock data that will be used for template preview and test sends.</param> /// <param name="onBehalfOf">The user to impersonate.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The <see cref="TemplateVersion" />. /// </returns> public Task <TemplateVersion> UpdateVersionAsync(string templateId, string versionId, Parameter <string> name = default(Parameter <string>), Parameter <string> subject = default(Parameter <string>), Parameter <string> htmlContent = default(Parameter <string>), Parameter <string> textContent = default(Parameter <string>), Parameter <bool> isActive = default(Parameter <bool>), Parameter <EditorType?> editorType = default(Parameter <EditorType?>), Parameter <object> testData = default(Parameter <object>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(); data.AddPropertyIfValue("name", name); data.AddPropertyIfValue("subject", subject); data.AddPropertyIfValue("html_content", htmlContent); data.AddPropertyIfValue("plain_content", textContent); data.AddPropertyIfValue("active", isActive, value => JToken.FromObject(value ? 1 : 0)); data.AddPropertyIfEnumValue("editor", editorType); data.AddPropertyIfValue("test_data", testData); return(_client .PatchAsync($"{_endpoint}/{templateId}/versions/{versionId}") .OnBehalfOf(onBehalfOf) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsSendGridObject <TemplateVersion>()); }
/// <summary> /// Create a template version. /// </summary> /// <param name="templateId">The template identifier.</param> /// <param name="name">The name.</param> /// <param name="subject">The subject.</param> /// <param name="htmlContent">Content of the HTML.</param> /// <param name="textContent">Content of the text.</param> /// <param name="isActive">if set to <c>true</c> [is active].</param> /// <param name="editorType">The type of editor.</param> /// <param name="testData">For dynamic templates only, the mock data that will be used for template preview and test sends.</param> /// <param name="onBehalfOf">The user to impersonate.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The <see cref="TemplateVersion" />. /// </returns> public Task <TemplateVersion> CreateVersionAsync(string templateId, string name, string subject, string htmlContent, string textContent, bool isActive, Parameter <EditorType?> editorType = default, Parameter <object> testData = default, string onBehalfOf = null, CancellationToken cancellationToken = default) { var data = new JObject { { "name", name }, { "subject", subject }, { "html_content", htmlContent }, { "plain_content", textContent }, { "active", isActive ? 1 : 0 } }; data.AddPropertyIfEnumValue("editor", editorType); data.AddPropertyIfValue("test_data", testData, value => JToken.Parse(JsonConvert.SerializeObject(value)).ToString()); return(_client .PostAsync($"{_endpoint}/{templateId}/versions") .OnBehalfOf(onBehalfOf) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsSendGridObject <TemplateVersion>()); }
/// <summary> /// Update the details of a scheduled meeting. /// </summary> /// <param name="meetingId">The meeting ID.</param> /// <param name="userId">The user Id or email address.</param> /// <param name="topic">Meeting topic.</param> /// <param name="agenda">Meeting description.</param> /// <param name="start">Meeting start time.</param> /// <param name="duration">Meeting duration (minutes).</param> /// <param name="timeZone">The time zone for start time.</param> /// <param name="password">Password to join the meeting. Password may only contain the following characters: [a-z A-Z 0-9 @ - _ *]. Max of 10 characters.</param> /// <param name="settings">Meeting settings.</param> /// <param name="trackingFields">Tracking fields.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public Task UpdateScheduledMeetingAsync(long meetingId, string userId = null, string topic = null, string agenda = null, DateTime?start = null, int?duration = null, TimeZones?timeZone = null, string password = null, MeetingSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default) { var data = new JObject(); data.AddPropertyIfValue("schedule_for", userId); data.AddPropertyIfValue("topic", topic); data.AddPropertyIfValue("password", password); data.AddPropertyIfValue("agenda", agenda); data.AddPropertyIfValue("start_time", start.ToZoomFormat(timeZone)); data.AddPropertyIfValue("duration", duration); data.AddPropertyIfEnumValue("timezone", timeZone); data.AddPropertyIfValue("settings", settings); data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject() { { "field", tf.Key }, { "value", tf.Value } })); return(_client .PatchAsync($"meetings/{meetingId}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Create a chat channel that allows users to communicate via chat in private or public groups. /// </summary> /// <param name="userId">The user Id or email address.</param> /// <param name="name">The name of the channel.</param> /// <param name="type">The type of channel.</param> /// <param name="emails">The email addresses of the members to include in the channel.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <remarks>Zoom allows a maximum of 5 members to be added at once.</remarks> /// <returns> /// The new <see cref="ChatChannel"/>. /// </returns> public Task <ChatChannel> CreateAccountChannelAsync(string userId, string name, ChatChannelType type, IEnumerable <string> emails = null, CancellationToken cancellationToken = default) { if (emails != null && emails.Count() > 5) { throw new ArgumentOutOfRangeException(nameof(emails), "You can invite up to 5 members at once"); } var data = new JObject() { { "name", name } }; data.AddPropertyIfEnumValue("type", type); data.AddPropertyIfValue("members", emails?.Select(e => new JObject() { { "email", e } })); return(_client .PostAsync($"chat/users/{userId}/channels") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <ChatChannel>()); }