Example #1
0
        /// <summary>
        /// Updates an existing scheduled webinar.
        /// </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="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 UpdateScheduledWebinarAsync(long webinarId, string topic = null, string agenda = null, DateTime?start = null, int?duration = 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?.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");
            }
        }
Example #2
0
 /// <summary>
 /// Approve an attempt to access your account.
 /// </summary>
 /// <param name="requestId">The ID of the request that you want to approve.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The async task.
 /// </returns>
 public Task ApproveAccessRequestAsync(string requestId, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_client
            .PatchAsync($"scopes/requests/{requestId}")
            .WithCancellationToken(cancellationToken)
            .AsMessage());
 }
Example #3
0
        /// <summary>
        /// Update a chat channel.
        /// </summary>
        /// <param name="userId">The user Id or email address.</param>
        /// <param name="channelId">The channel Id.</param>
        /// <param name="name">The name of the channel.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        public Task UpdateAccountChannelAsync(string userId, string channelId, string name, CancellationToken cancellationToken = default)
        {
            var data = new JObject()
            {
                { "name", name }
            };

            return(_client
                   .PatchAsync($"chat/users/{userId}/channels/{channelId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsMessage());
        }
Example #4
0
        /// <summary>
        /// Update a template.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Template" />.
        /// </returns>
        public Task <Template> UpdateAsync(string templateId, string name, string onBehalfOf = null, CancellationToken cancellationToken = default)
        {
            var data = new StrongGridJsonObject();

            data.AddProperty("name", name);

            return(_client
                   .PatchAsync($"{_endpoint}/{templateId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <Template>());
        }
Example #5
0
        /// <summary>
        /// Update a template.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Template" />.
        /// </returns>
        public Task <Template> UpdateAsync(string templateId, string name, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject
            {
                { "name", name }
            };

            return(_client
                   .PatchAsync($"{_endpoint}/{templateId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Template>());
        }
Example #6
0
        /// <summary>
        /// Update a whitelabel domain.
        /// </summary>
        /// <param name="domainId">The domain identifier.</param>
        /// <param name="isDefault">if set to <c>true</c> [is default].</param>
        /// <param name="customSpf">if set to <c>true</c> [custom SPF].</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="WhitelabelDomain" />.
        /// </returns>
        public Task <WhitelabelDomain> UpdateDomainAsync(long domainId, bool isDefault = false, bool customSpf = false, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject
            {
                { "custom_spf", customSpf },
                { "default", isDefault }
            };

            return(_client
                   .PatchAsync($"{_endpoint}/domains/{domainId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <WhitelabelDomain>());
        }
Example #7
0
        /// <summary>
        /// Update an authenticated domain.
        /// </summary>
        /// <param name="domainId">The domain identifier.</param>
        /// <param name="isDefault">if set to <c>true</c> [is default].</param>
        /// <param name="customSpf">if set to <c>true</c> [custom SPF].</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        /// The <see cref="AuthenticatedDomain" />.
        /// </returns>
        public Task <AuthenticatedDomain> UpdateDomainAsync(long domainId, Parameter <bool> isDefault = default, Parameter <bool> customSpf = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
        {
            var data = new StrongGridJsonObject();

            data.AddProperty("custom_spf", customSpf);
            data.AddProperty("default", isDefault);

            return(_client
                   .PatchAsync($"{_endpoint}/domains/{domainId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <AuthenticatedDomain>());
        }
Example #8
0
        /// <summary>
        /// Update an authenticated domain.
        /// </summary>
        /// <param name="domainId">The domain identifier.</param>
        /// <param name="isDefault">if set to <c>true</c> [is default].</param>
        /// <param name="customSpf">if set to <c>true</c> [custom SPF].</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        /// The <see cref="AuthenticatedDomain" />.
        /// </returns>
        public Task <AuthenticatedDomain> UpdateDomainAsync(long domainId, bool isDefault = false, bool customSpf = false, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject
            {
                { "custom_spf", customSpf },
                { "default", isDefault }
            };

            return(_client
                   .PatchAsync($"{_endpoint}/domains/{domainId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <AuthenticatedDomain>());
        }
Example #9
0
        /// <summary>
        /// Update a scheduled webinar for a user.
        /// </summary>
        /// <param name="webinarId">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="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="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        /// <exception cref="System.Exception">Thrown when an exception occured while updating the webinar.</exception>
        public Task UpdateScheduledWebinarAsync(string webinarId, string topic, string agenda, DateTime start, int duration, string password = null, WebinarSettings settings = null, IDictionary <string, string> trackingFields = null, CancellationToken cancellationToken = default)
        {
            var data = new JObject()
            {
                { "type", 5 }
            };

            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("timezone", "UTC");
            data.AddPropertyIfValue("settings", settings);
            data.AddPropertyIfValue("tracking_fields", trackingFields?.Select(tf => new JObject()
            {
                { "field", tf.Key }, { "value", tf.Value }
            }));

            return(_client
                   .PatchAsync($"webinars/{webinarId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsMessage());
        }
Example #10
0
        /// <summary>
        /// Updates the contact.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="firstName">The first name.</param>
        /// <param name="lastName">The last name.</param>
        /// <param name="customFields">The custom fields.</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        /// <exception cref="System.Exception">Thrown when an exception occured while updating the contact.</exception>
        public async Task UpdateAsync(
            string email,
            Parameter <string> firstName = default(Parameter <string>),
            Parameter <string> lastName  = default(Parameter <string>),
            Parameter <IEnumerable <Field> > customFields = default(Parameter <IEnumerable <Field> >),
            string onBehalfOf = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            // SendGrid expects an array despite the fact we are updating a single contact
            var data = new[] { ConvertToJObject(email, firstName, lastName, customFields) };

            var responseContent = await _client
                                  .PatchAsync(_endpoint)
                                  .OnBehalfOf(onBehalfOf)
                                  .WithJsonBody(data)
                                  .WithCancellationToken(cancellationToken)
                                  .AsString(null)
                                  .ConfigureAwait(false);

            var importResult = JObject.Parse(responseContent).ToObject <ImportResult>();

            if (importResult.ErrorCount > 0)
            {
                // There should only be one error message but to be safe let's combine all error messages into a single string
                var errorMsg = string.Join(Environment.NewLine, importResult.Errors.Select(e => e.Message));
                throw new Exception(errorMsg);
            }
        }
Example #11
0
        /// <summary>
        /// Update a segment.
        /// </summary>
        /// <param name="segmentId">The segment identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="listId">The list identifier.</param>
        /// <param name="conditions">The conditions.</param>
        /// <param name="onBehalfOf">The user to impersonate</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Segment" />.
        /// </returns>
        public Task <Segment> UpdateAsync(long segmentId, string name = null, long?listId = null, IEnumerable <SearchCondition> conditions = null, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            conditions = conditions ?? Enumerable.Empty <SearchCondition>();

            var data = new JObject();

            if (!string.IsNullOrEmpty(name))
            {
                data.Add("name", name);
            }
            if (listId.HasValue)
            {
                data.Add("list_id", listId.Value);
            }
            if (conditions.Any())
            {
                data.Add("conditions", JArray.FromObject(conditions.ToArray()));
            }

            return(_client
                   .PatchAsync($"{_endpoint}/{segmentId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Segment>());
        }
Example #12
0
        /// <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);
            }
        }
Example #13
0
        /// <summary>
        /// Update a Sub Account's options under the Master Account.
        /// </summary>
        /// <param name="accountId">The account Id.</param>
        /// <param name="useSharedVirtualRoomConnectors">Enable/disable the option for a sub account to use shared Virtual Room Connector(s).</param>
        /// <param name="roomConnectorsIpAddresses">The IP addresses of the Room Connectors that you would like to share with the sub account.</param>
        /// <param name="useSharedMeetingConnectors">Enable/disable the option for a sub account to use shared Meeting Connector(s).</param>
        /// <param name="meetingConnectorsIpAddresses">The IP addresses of the Meeting Connectors that you would like to share with the sub account.</param>
        /// <param name="payMode">Payee.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        public Task UpdateOptionsAsync(long accountId, bool?useSharedVirtualRoomConnectors = null, IEnumerable <string> roomConnectorsIpAddresses = null, bool?useSharedMeetingConnectors = null, IEnumerable <string> meetingConnectorsIpAddresses = null, PayMode?payMode = null, CancellationToken cancellationToken = default)
        {
            var data = new JObject();

            data.AddPropertyIfValue("share_rc", useSharedVirtualRoomConnectors);
            data.AddPropertyIfValue("room_connectors", roomConnectorsIpAddresses, ipAddresses => JToken.Parse(string.Join(",", ipAddresses)));
            data.AddPropertyIfValue("share_mc", useSharedMeetingConnectors);
            data.AddPropertyIfValue("meeting_connectors", meetingConnectorsIpAddresses, ipAddresses => JToken.Parse(string.Join(",", ipAddresses)));
            data.AddPropertyIfValue("pay_mode", payMode);

            return(_client
                   .PatchAsync($"accounts/{accountId}/options")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsMessage());
        }
Example #14
0
        /// <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());
        }
Example #15
0
        /// <summary>
        /// Update an alert.
        /// </summary>
        /// <param name="alertId">The alert identifier.</param>
        /// <param name="type">The type.</param>
        /// <param name="emailTo">The email to.</param>
        /// <param name="frequency">The frequency.</param>
        /// <param name="percentage">The percentage.</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="Alert" />.
        /// </returns>
        public Task <Alert> UpdateAsync(long alertId, Parameter <AlertType?> type = default(Parameter <AlertType?>), Parameter <string> emailTo = default(Parameter <string>), Parameter <Frequency?> frequency = default(Parameter <Frequency?>), Parameter <int?> percentage = default(Parameter <int?>), CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = CreateJObject(type, emailTo, frequency, percentage);

            return(_client
                   .PatchAsync($"{_endpoint}/{alertId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Alert>());
        }
Example #16
0
        /// <summary>
        /// Change the event webhook settings.
        /// </summary>
        /// <param name="enabled">if set to <c>true</c> [enabled].</param>
        /// <param name="url">the webhook endpoint url.</param>
        /// <param name="bounce">if set to <c>true</c> [bounce].</param>
        /// <param name="click">if set to <c>true</c> [click].</param>
        /// <param name="deferred">if set to <c>true</c> [deferred].</param>
        /// <param name="delivered">if set to <c>true</c> [delivered].</param>
        /// <param name="dropped">if set to <c>true</c> [dropped].</param>
        /// <param name="groupResubscribe">if set to <c>true</c> [groupResubscribe].</param>
        /// <param name="groupUnsubscribe">if set to <c>true</c> [groupUnsubscribe].</param>
        /// <param name="open">if set to <c>true</c> [open].</param>
        /// <param name="processed">if set to <c>true</c> [processed].</param>
        /// <param name="spamReport">if set to <c>true</c> [spamReport].</param>
        /// <param name="unsubscribe">if set to <c>true</c> [unsubscribe].</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="EventWebhookSettings" />.
        /// </returns>
        public Task <EventWebhookSettings> UpdateEventWebhookSettingsAsync(
            bool enabled,
            string url,
            bool bounce           = default,
            bool click            = default,
            bool deferred         = default,
            bool delivered        = default,
            bool dropped          = default,
            bool groupResubscribe = default,
            bool groupUnsubscribe = default,
            bool open             = default,
            bool processed        = default,
            bool spamReport       = default,
            bool unsubscribe      = default,
            string onBehalfOf     = null,
            CancellationToken cancellationToken = default)
        {
            var eventWebhookSettings = new EventWebhookSettings
            {
                Enabled          = enabled,
                Url              = url,
                Bounce           = bounce,
                Click            = click,
                Deferred         = deferred,
                Delivered        = delivered,
                Dropped          = dropped,
                GroupResubscribe = groupResubscribe,
                GroupUnsubscribe = groupUnsubscribe,
                Open             = open,
                Processed        = processed,
                SpamReport       = spamReport,
                Unsubscribe      = unsubscribe
            };
            var data = JObject.FromObject(eventWebhookSettings);

            return(_client
                   .PatchAsync($"{_eventWebhookEndpoint}/settings")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <EventWebhookSettings>());
        }
Example #17
0
        /// <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="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, MeetingSettings settings = null, CancellationToken cancellationToken = default)
        {
            var data = new JObject();

            data.AddPropertyIfValue("agenda", agenda);
            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);

            return(_client
                   .PatchAsync($"meetings/{meetingId}")
                   .WithArgument("occurrence_id", occurrenceId)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsMessage());
        }
Example #18
0
        /// <summary>
        /// Update an alert.
        /// </summary>
        /// <param name="alertId">The alert identifier.</param>
        /// <param name="type">The type.</param>
        /// <param name="emailTo">The email to.</param>
        /// <param name="frequency">The frequency.</param>
        /// <param name="percentage">The percentage.</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        /// The <see cref="Alert" />.
        /// </returns>
        public Task <Alert> UpdateAsync(long alertId, Parameter <AlertType?> type = default, Parameter <string> emailTo = default, Parameter <Frequency?> frequency = default, Parameter <int?> percentage = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
        {
            var data = ConvertToJson(type, emailTo, frequency, percentage);

            return(_client
                   .PatchAsync($"{_endpoint}/{alertId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <Alert>());
        }
Example #19
0
        /// <summary>
        /// Update a list.
        /// </summary>
        /// <param name="listId">The list identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The updated list.
        /// </returns>
        public Task <List> UpdateAsync(string listId, string name, CancellationToken cancellationToken = default)
        {
            var data = new StrongGridJsonObject();

            data.AddProperty("name", name);

            return(_client
                   .PatchAsync($"{_endpoint}/{listId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <List>());
        }
Example #20
0
        /// <summary>
        /// Update the name of a custom field.
        /// </summary>
        /// <param name="fieldId">The field identifier.</param>
        /// <param name="name">The new name.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="FieldMetadata">metadata</see> about the field.
        /// </returns>
        public Task <FieldMetadata> UpdateAsync(string fieldId, string name = null, CancellationToken cancellationToken = default)
        {
            var data = new StrongGridJsonObject();

            data.AddProperty("id", fieldId);
            data.AddProperty("name", name);

            return(_client
                   .PatchAsync($"{_endpoint}/{fieldId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <FieldMetadata>());
        }
Example #21
0
        /// <summary>
        /// Update a list.
        /// </summary>
        /// <param name="listId">The list identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The async task.
        /// </returns>
        public Task UpdateAsync(long listId, string name, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject
            {
                new JProperty("name", name)
            };

            return(_client
                   .PatchAsync($"{_endpoint}/{listId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsMessage());
        }
Example #22
0
        /// <summary>
        /// Update a campaign
        /// </summary>
        /// <param name="campaignId">The id of the campaign</param>
        /// <param name="title">The title.</param>
        /// <param name="senderId">The sender identifier.</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="listIds">The list ids.</param>
        /// <param name="segmentIds">The segment ids.</param>
        /// <param name="categories">The categories.</param>
        /// <param name="suppressionGroupId">The suppression group identifier.</param>
        /// <param name="customUnsubscribeUrl">The custom unsubscribe URL.</param>
        /// <param name="ipPool">The ip pool.</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="Campaign" />.
        /// </returns>
        public Task <Campaign> UpdateAsync(
            long campaignId,
            Parameter <string> title                     = default(Parameter <string>),
            Parameter <long?> senderId                   = default(Parameter <long?>),
            Parameter <string> subject                   = default(Parameter <string>),
            Parameter <string> htmlContent               = default(Parameter <string>),
            Parameter <string> textContent               = default(Parameter <string>),
            Parameter <IEnumerable <long> > listIds      = default(Parameter <IEnumerable <long> >),
            Parameter <IEnumerable <long> > segmentIds   = default(Parameter <IEnumerable <long> >),
            Parameter <IEnumerable <string> > categories = default(Parameter <IEnumerable <string> >),
            Parameter <long?> suppressionGroupId         = default(Parameter <long?>),
            Parameter <string> customUnsubscribeUrl      = default(Parameter <string>),
            Parameter <string> ipPool                    = default(Parameter <string>),
            CancellationToken cancellationToken          = default(CancellationToken))
        {
            var data = CreateJObject(title, senderId, subject, htmlContent, textContent, listIds, segmentIds, categories, suppressionGroupId, customUnsubscribeUrl, ipPool);

            return(_client
                   .PatchAsync($"{_endpoint}/{campaignId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Campaign>());
        }
Example #23
0
        /// <summary>
        /// Update the name of a custom field.
        /// </summary>
        /// <param name="fieldId">The field identifier.</param>
        /// <param name="name">The new name.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="FieldMetadata">metadata</see> about the field.
        /// </returns>
        public Task <FieldMetadata> UpdateAsync(string fieldId, string name = null, CancellationToken cancellationToken = default)
        {
            var data = new JObject
            {
                { "id", fieldId },
                { "name", name }
            };

            return(_client
                   .PatchAsync($"{_endpoint}/{fieldId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <FieldMetadata>());
        }
Example #24
0
        /// <summary>
        /// Update an existing suppression group.
        /// </summary>
        /// <param name="groupId">The group identifier.</param>
        /// <param name="name">The name of the new suppression group</param>
        /// <param name="description">A description of the suppression group</param>
        /// <param name="onBehalfOf">The user to impersonate</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="SuppressionGroup" />.
        /// </returns>
        public Task <SuppressionGroup> UpdateAsync(long groupId, Parameter <string> name = default(Parameter <string>), Parameter <string> description = default(Parameter <string>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject();

            data.AddPropertyIfValue("name", name.Value);
            data.AddPropertyIfValue("description", description);

            return(_client
                   .PatchAsync($"{_endpoint}/{groupId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <SuppressionGroup>());
        }
Example #25
0
        /// <summary>
        /// Update a campaign.
        /// </summary>
        /// <param name="campaignId">The id of the campaign.</param>
        /// <param name="title">The title.</param>
        /// <param name="senderId">The sender identifier.</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="listIds">The list ids.</param>
        /// <param name="segmentIds">The segment ids.</param>
        /// <param name="categories">The categories.</param>
        /// <param name="suppressionGroupId">The suppression group identifier.</param>
        /// <param name="customUnsubscribeUrl">The custom unsubscribe URL.</param>
        /// <param name="ipPool">The ip pool.</param>
        /// <param name="editor">The editor used in the UI. Allowed values: code, design.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        /// The <see cref="Models.Legacy.Campaign" />.
        /// </returns>
        public Task <Models.Legacy.Campaign> UpdateAsync(
            long campaignId,
            Parameter <string> title                     = default,
            Parameter <long?> senderId                   = default,
            Parameter <string> subject                   = default,
            Parameter <string> htmlContent               = default,
            Parameter <string> textContent               = default,
            Parameter <IEnumerable <long> > listIds      = default,
            Parameter <IEnumerable <long> > segmentIds   = default,
            Parameter <IEnumerable <string> > categories = default,
            Parameter <long?> suppressionGroupId         = default,
            Parameter <string> customUnsubscribeUrl      = default,
            Parameter <string> ipPool                    = default,
            Parameter <EditorType?> editor               = default,
            CancellationToken cancellationToken          = default)
        {
            var data = ConvertToJson(title, senderId, subject, htmlContent, textContent, listIds, segmentIds, categories, suppressionGroupId, customUnsubscribeUrl, ipPool, editor);

            return(_client
                   .PatchAsync($"{_endpoint}/{campaignId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsObject <Models.Legacy.Campaign>());
        }
Example #26
0
        /// <summary>
        /// Update a segment.
        /// </summary>
        /// <param name="segmentId">The segment identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="filterConditions">The query.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Segment" />.
        /// </returns>
        public Task <Segment> UpdateAsync(string segmentId, Parameter <string> name = default, Parameter <IEnumerable <KeyValuePair <SearchLogicalOperator, IEnumerable <SearchCriteria <ContactsFilterField> > > > > filterConditions = default, CancellationToken cancellationToken = default)
        {
            var data = new JObject();

            data.AddPropertyIfValue("name", name);
            if (filterConditions.HasValue)
            {
                data.AddPropertyIfValue("query_dsl", ToQueryDsl(filterConditions.Value));
            }

            return(_client
                   .PatchAsync($"{_endpoint}/{segmentId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Segment>());
        }
Example #27
0
        /// <summary>
        /// Update a segment.
        /// </summary>
        /// <param name="segmentId">The segment identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="listId">The list identifier.</param>
        /// <param name="conditions">The conditions.</param>
        /// <param name="onBehalfOf">The user to impersonate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="Models.Legacy.Segment" />.
        /// </returns>
        public Task <Models.Legacy.Segment> UpdateAsync(long segmentId, string name = null, long?listId = null, IEnumerable <Models.Legacy.SearchCondition> conditions = null, string onBehalfOf = null, CancellationToken cancellationToken = default)
        {
            conditions = conditions ?? Enumerable.Empty <Models.Legacy.SearchCondition>();

            var data = new JObject();

            data.AddPropertyIfValue("name", name);
            data.AddPropertyIfValue("list_id", listId);
            data.AddPropertyIfValue("conditions", conditions);

            return(_client
                   .PatchAsync($"{_endpoint}/{segmentId}")
                   .OnBehalfOf(onBehalfOf)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <Models.Legacy.Segment>());
        }
Example #28
0
        /// <summary>
        /// Update an existing suppression group.
        /// </summary>
        /// <param name="groupId">The group identifier.</param>
        /// <param name="name">The name of the new suppression group</param>
        /// <param name="description">A description of the suppression group</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="SuppressionGroup" />.
        /// </returns>
        public Task <SuppressionGroup> UpdateAsync(int groupId, Parameter <string> name = default(Parameter <string>), Parameter <string> description = default(Parameter <string>), CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new JObject();

            if (name.HasValue)
            {
                data.Add("name", name.Value);
            }
            if (description.HasValue)
            {
                data.Add("description", description.Value);
            }

            return(_client
                   .PatchAsync($"{_endpoint}/{groupId}")
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <SuppressionGroup>());
        }
Example #29
0
        /// <summary>
        /// Update a sender identity.
        /// </summary>
        /// <param name="senderId">The sender identifier.</param>
        /// <param name="nickname">The nickname.</param>
        /// <param name="from">From.</param>
        /// <param name="replyTo">The reply to.</param>
        /// <param name="address1">The address1.</param>
        /// <param name="address2">The address2.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="country">The country.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="SenderIdentity" />.
        /// </returns>
        public Task <SenderIdentity> UpdateAsync(
            long senderId,
            Parameter <string> nickname         = default(Parameter <string>),
            Parameter <MailAddress> from        = default(Parameter <MailAddress>),
            Parameter <MailAddress> replyTo     = default(Parameter <MailAddress>),
            Parameter <string> address1         = default(Parameter <string>),
            Parameter <string> address2         = default(Parameter <string>),
            Parameter <string> city             = default(Parameter <string>),
            Parameter <string> state            = default(Parameter <string>),
            Parameter <string> zip              = default(Parameter <string>),
            Parameter <string> country          = default(Parameter <string>),
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = CreateJObject(nickname, from, replyTo, address1, address2, city, state, zip, country);

            return(_client
                   .PatchAsync($"{_endpoint}/{senderId}")
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <SenderIdentity>());
        }
Example #30
0
        /// <summary>
        /// Update your user profile
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="city">The city.</param>
        /// <param name="company">The company.</param>
        /// <param name="country">The country.</param>
        /// <param name="firstName">The first name.</param>
        /// <param name="lastName">The last name.</param>
        /// <param name="phone">The phone.</param>
        /// <param name="state">The state.</param>
        /// <param name="website">The website.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The <see cref="UserProfile" />.
        /// </returns>
        public Task <UserProfile> UpdateProfileAsync(
            Parameter <string> address          = default(Parameter <string>),
            Parameter <string> city             = default(Parameter <string>),
            Parameter <string> company          = default(Parameter <string>),
            Parameter <string> country          = default(Parameter <string>),
            Parameter <string> firstName        = default(Parameter <string>),
            Parameter <string> lastName         = default(Parameter <string>),
            Parameter <string> phone            = default(Parameter <string>),
            Parameter <string> state            = default(Parameter <string>),
            Parameter <string> website          = default(Parameter <string>),
            Parameter <string> zip              = default(Parameter <string>),
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = CreateJObject(address, city, company, country, firstName, lastName, phone, state, website, zip);

            return(_client
                   .PatchAsync(_endpoint)
                   .WithJsonBody(data)
                   .WithCancellationToken(cancellationToken)
                   .AsSendGridObject <UserProfile>());
        }