/// <summary> /// Add or Update a Contact. /// </summary> /// <param name="email">The email.</param> /// <param name="firstName">The first name.</param> /// <param name="lastName">The last name.</param> /// <param name="addressLine1">The first line of the address.</param> /// <param name="addressLine2">The second line of the address.</param> /// <param name="city">The city.</param> /// <param name="stateOrProvince">The state or province.</param> /// <param name="country">The country.</param> /// <param name="postalCode">The postal code.</param> /// <param name="alternateEmails">The additional emails associated with the contact.</param> /// <param name="customFields">The custom fields.</param> /// <param name="listIds">The identifiers of the lists where the contacts will be added to.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The job id. /// </returns> /// <exception cref="SendGridException">Thrown when an exception occurred while adding or updating the contact.</exception> public Task <string> UpsertAsync( string email, Parameter <string> firstName = default, Parameter <string> lastName = default, Parameter <string> addressLine1 = default, Parameter <string> addressLine2 = default, Parameter <string> city = default, Parameter <string> stateOrProvince = default, Parameter <string> country = default, Parameter <string> postalCode = default, Parameter <IEnumerable <string> > alternateEmails = default, Parameter <IEnumerable <Field> > customFields = default, IEnumerable <string> listIds = null, CancellationToken cancellationToken = default) { // SendGrid expects an array despite the fact we are creating a single contact var contacts = new[] { ConvertToJson(email, firstName, lastName, addressLine1, addressLine2, city, stateOrProvince, country, postalCode, alternateEmails, customFields) }; var data = new StrongGridJsonObject(); data.AddProperty("list_ids", listIds); data.AddProperty("contacts", contacts); return(_client .PutAsync(_endpoint) .WithJsonBody(data, true) .WithCancellationToken(cancellationToken) .AsObject <string>("job_id")); }
/// <summary> /// Update a Subuser. /// </summary> /// <param name="username">The template identifier.</param> /// <param name="disabled">The name.</param> /// <param name="ips">The ips.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public async Task UpdateAsync(string username, Parameter <bool> disabled, Parameter <IEnumerable <string> > ips, CancellationToken cancellationToken = default) { if (disabled.HasValue) { var data = new JObject() { { "disabled", disabled.Value } }; await _client .PatchAsync($"{_endpoint}/{username}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage() .ConfigureAwait(false); } if (ips.HasValue) { var ipdata = JArray.FromObject(ips.Value); await _client .PutAsync($"{_endpoint}/{username}/ips") .WithJsonBody(ipdata) .WithCancellationToken(cancellationToken) .AsMessage() .ConfigureAwait(false); } }
/// <summary> /// Recover all deleted recordings of a specific meeting from trash. /// </summary> /// <param name="meetingId">The meeting Id or UUID.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> /// <remarks>Zoom allows recordings to be recovered from trash for up to 30 days from deletion date.</remarks> public Task RecoverRecordingsAsync(string meetingId, CancellationToken cancellationToken = default) { return(_client .PutAsync($"meetings/{meetingId}/recordings/status") .WithArgument("action", "recover") .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Update the email address on file for your account /// </summary> /// <param name="email">The email.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The email address from your user profile. /// </returns> public Task <string> UpdateEmailAsync(string email, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(); data.Add("email", email); return(_client .PutAsync("user/email") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsSendGridObject <string>("email")); }
/// <summary> /// Update the email address on file for your account. /// </summary> /// <param name="email">The email.</param> /// <param name="onBehalfOf">The user to impersonate.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The email address from your user profile. /// </returns> public Task <string> UpdateEmailAsync(string email, string onBehalfOf = null, CancellationToken cancellationToken = default) { var data = new StrongGridJsonObject(); data.AddProperty("email", email); return(_client .PutAsync("user/email") .OnBehalfOf(onBehalfOf) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <string>("email")); }
/// <summary> /// Deactivate a specific user on a Zoom account. /// </summary> /// <param name="userId">The user Id or email address.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public Task DeactivateAsync(string userId, CancellationToken cancellationToken = default) { var data = new JObject() { { "action", "deactivate" } }; return(_client .PutAsync($"users/{userId}/status") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Update an API Key /// </summary> /// <param name="keyId">The key identifier.</param> /// <param name="name">The name.</param> /// <param name="scopes">The scopes.</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>The <see cref="ApiKey"/>.</returns> public Task<ApiKey> UpdateAsync(string keyId, string name, Parameter<IEnumerable<string>> scopes = default(Parameter<IEnumerable<string>>), CancellationToken cancellationToken = default(CancellationToken)) { var data = CreateJObject(name, scopes); return (scopes.HasValue && (scopes.Value ?? Enumerable.Empty<string>()).Any() ? _client.PutAsync($"{_endpoint}/{keyId}") : _client.PatchAsync($"{_endpoint}/{keyId}")) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsSendGridObject<ApiKey>(); }
/// <summary> /// Update a list. /// </summary> /// <param name="name">The name of the IP pool.</param> /// <param name="newName">The new name of the IP pool.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The name of the updated <see cref="IpPool" />. /// </returns> public Task <string> UpdateAsync(string name, string newName, CancellationToken cancellationToken = default) { var data = new StrongGridJsonObject(); data.AddProperty("name", newName); return(_client .PutAsync($"{_endpoint}/{name}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <string>("name")); }
/// <summary> /// End a webinar. /// </summary> /// <param name="webinarId">The webinar ID.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The async task. /// </returns> public Task EndAsync(long webinarId, CancellationToken cancellationToken = default) { var data = new JObject() { { "action", "end" } }; return(_client .PutAsync($"webinars/{webinarId}/status") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Update a list. /// </summary> /// <param name="name">The name of the IP pool.</param> /// <param name="newName">The new name of the IP pool.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The name of the updated <see cref="IpPool" />. /// </returns> public Task <string> UpdateAsync(string name, string newName, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject() { { "name", newName } }; return(_client .PutAsync($"{_endpoint}/{name}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsSendGridObject <string>("name")); }
private Task UpdateMessageAsync(string messageId, string userId, string recipientEmail, string channelId, string message, IEnumerable <ChatMention> mentions, CancellationToken cancellationToken) { Debug.Assert(recipientEmail != null || channelId != null, "You must provide either recipientEmail or channelId"); Debug.Assert(recipientEmail == null || channelId == null, "You can't provide both recipientEmail and channelId"); var data = new JObject(); data.AddPropertyIfValue("message", message); data.AddPropertyIfValue("to_contact", recipientEmail); data.AddPropertyIfValue("to_channel", channelId); data.AddPropertyIfValue("at_items", mentions); return(_client .PutAsync($"chat/users/{userId}/messages/{messageId}") .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsMessage()); }
/// <summary> /// Update an API Key. /// </summary> /// <param name="keyId">The key identifier.</param> /// <param name="name">The name.</param> /// <param name="scopes">The scopes.</param> /// <param name="onBehalfOf">The user to impersonate.</param> /// <param name="cancellationToken">Cancellation token.</param> /// <returns>The <see cref="ApiKey"/>.</returns> public Task <ApiKey> UpdateAsync(string keyId, string name, Parameter <IEnumerable <string> > scopes = default, string onBehalfOf = null, CancellationToken cancellationToken = default) { var data = ConvertToJson(name, scopes); return((scopes.HasValue && (scopes.Value ?? Enumerable.Empty <string>()).Any() ? _client.PutAsync($"{_endpoint}/{keyId}") : _client.PatchAsync($"{_endpoint}/{keyId}")) .OnBehalfOf(onBehalfOf) .WithJsonBody(data) .WithCancellationToken(cancellationToken) .AsObject <ApiKey>()); }