From cbc07b938b1fc964f5bacf16568e5eba5b9ba21e Mon Sep 17 00:00:00 2001 From: jeremy <517429+JeremyMelton@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:33:50 -0600 Subject: [PATCH] fix: update email channel --- .../Email/EmailChannelProviderClient.cs | 50 +++++-- .../Email/EmailDeliveryReport.cs | 35 +++++ .../Email/EmailDeliveryStatusReportAdaptor.cs | 68 +++++++++ .../Email/EmailField.cs | 11 +- .../Email/EmailPrice.cs | 25 ++++ .../Email/EmailStatusReport.cs | 57 +++++++ .../Email/EmailStatusReports.cs | 24 +++ .../Email/ExtendedEmailChannelProperties.cs | 31 +++- .../ExtendedEmailDeliveryReportProperties.cs | 141 ++++++++++++++++++ .../ExtendedVoiceDeliveryReportExtension.cs | 34 +++++ .../InfobipChannelProviderExtensions.cs | 1 + 11 files changed, 460 insertions(+), 17 deletions(-) create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryReport.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryStatusReportAdaptor.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/EmailPrice.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReport.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReports.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailDeliveryReportProperties.cs create mode 100644 src/Transmitly.ChannelProvider.Infobip/Email/ExtendedVoiceDeliveryReportExtension.cs diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailChannelProviderClient.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailChannelProviderClient.cs index 8c51dc1..946c946 100644 --- a/src/Transmitly.ChannelProvider.Infobip/Email/EmailChannelProviderClient.cs +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailChannelProviderClient.cs @@ -17,24 +17,19 @@ using System.Threading.Tasks; using System.Net.Http; using System.Text.Json; -using Transmitly.ChannelProvider.Infobip.Sms.SendSmsMessage; using Transmitly.Infobip; using System; using Transmitly.Delivery; +using Transmitly.ChannelProvider.Infobip.Sms.SendSmsMessage; namespace Transmitly.ChannelProvider.Infobip.Email { - internal sealed class EmailChannelProviderClient(InfobipChannelProviderConfiguration configuration, HttpClient? httpClient) : ChannelProviderRestClient(httpClient) + internal sealed class EmailChannelProviderClient(InfobipChannelProviderConfiguration configuration) : ChannelProviderRestClient(null) { private const string SendEmailPath = "email/3/send"; private readonly InfobipChannelProviderConfiguration _configuration = configuration; - public EmailChannelProviderClient(InfobipChannelProviderConfiguration configuration) : this(configuration, null) - { - System.Text.Json.JsonSerializer.Serialize(new { }); - } - protected override void ConfigureHttpClient(HttpClient client) { RestClientConfiguration.Configure(client, _configuration); @@ -53,7 +48,7 @@ protected override void ConfigureHttpClient(HttpClient client) var result = await restClient .PostAsync( SendEmailPath, - CreateMessageContent(recipientList, communication, communicationContext), + await CreateMessageContent(recipientList, communication, communicationContext), cancellationToken ) .ConfigureAwait(false); @@ -89,30 +84,55 @@ protected override void ConfigureHttpClient(HttpClient client) return results; } - private static HttpContent CreateMessageContent(IAudienceAddress[] recipients, IEmail email, IDispatchCommunicationContext context) + private static async Task CreateMessageContent(IAudienceAddress[] recipients, IEmail email, IDispatchCommunicationContext context) { MultipartFormDataContent form = []; var emailProperties = new ExtendedEmailChannelProperties(email.ExtendedProperties); bool hasTemplateId = emailProperties.TemplateId.HasValue && emailProperties.TemplateId.Value > 0; - + var messageId = Guid.NewGuid().ToString("N"); TryAddRecipients(recipients, email, form); AddStringContent(form, EmailField.TemplateId, emailProperties.TemplateId?.ToString()); AddStringContent(form, EmailField.From, email.From?.ToEmailAddress(), !hasTemplateId); AddStringContent(form, EmailField.Subject, email.Subject, !hasTemplateId); AddStringContent(form, EmailField.TextBody, email.TextBody); AddStringContent(form, EmailField.HtmlBody, email.HtmlBody); + await TryAddAmpContent(email, context, form, emailProperties); AddStringContent(form, EmailField.IntermediateReport, emailProperties.IntermediateReport?.ToString().ToLowerInvariant()); - AddStringContent(form, EmailField.NotifyUrl, GetNotifyUrl(emailProperties.NotifyUrl, Guid.NewGuid().ToString("N"), context)); + AddStringContent(form, EmailField.NotifyUrl, await GetNotifyUrl(messageId, emailProperties, email, context)); AddStringContent(form, EmailField.Track, emailProperties.Track.ToString().ToLowerInvariant()); + AddStringContent(form, EmailField.TrackClicks, emailProperties.TrackClicks?.ToString().ToLowerInvariant()); + AddStringContent(form, EmailField.trackOpens, emailProperties.TrackOpens?.ToString().ToLowerInvariant()); + AddStringContent(form, EmailField.MessageId, messageId); + AddStringContent(form, EmailField.ApplicationId, emailProperties.ApplicationId); + AddStringContent(form, EmailField.EntityId, emailProperties.EntityId); return form; } - private static string? GetNotifyUrl(string? notifyUrl, string messageId, IDispatchCommunicationContext context) + + private static async Task TryAddAmpContent(IEmail email, IDispatchCommunicationContext context, MultipartFormDataContent form, ExtendedEmailChannelProperties emailProperties) { - if (string.IsNullOrWhiteSpace(notifyUrl)) - return null; + if (emailProperties.AmpHtml == null) + return; + if (string.IsNullOrWhiteSpace(email.HtmlBody)) + throw new InfobipException("HtmlBody is required when using AmpHtml"); - return new Uri(notifyUrl).AddPipelineContext(messageId, context.PipelineName, Id.Channel.Email(), Id.ChannelProvider.Infobip()).ToString(); + var ampContent = await context.TemplateEngine.RenderAsync(emailProperties.AmpHtml.GetTemplateRegistration(context.CultureInfo, true), context); + AddStringContent(form, EmailField.AmpHtml, ampContent, false); + } + + private static async Task GetNotifyUrl(string messageId, ExtendedEmailChannelProperties emailProperties, IEmail email, IDispatchCommunicationContext context) + { + string? url; + var urlResolver = emailProperties.NotifyUrlResolver ?? email.DeliveryReportCallbackUrlResolver; + if (urlResolver != null) + url = await urlResolver(context).ConfigureAwait(false); + else + { + url = emailProperties.NotifyUrl ?? email.DeliveryReportCallbackUrl; + if (string.IsNullOrWhiteSpace(url)) + return null; + } + return new Uri(url).AddPipelineContext(messageId, context.PipelineName, context.ChannelId, context.ChannelProviderId).ToString(); } private static void AddStringContent(MultipartFormDataContent form, string key, string? value, bool optional = true) diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryReport.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryReport.cs new file mode 100644 index 0000000..0fb46d3 --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryReport.cs @@ -0,0 +1,35 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using Transmitly.Delivery; + +namespace Transmitly.ChannelProvider.Infobip.Email +{ + sealed record EmailDeliveryReport : DeliveryReport + { + public EmailDeliveryReport(DeliveryReport original) : base(original) + { + } + + public EmailDeliveryReport(string EventName, string? ChannelId, string? ChannelProviderId, string? PipelineName, + string? ResourceId, DispatchStatus DispatchStatus, object? ChannelCommunication, IContentModel? ContentModel, Exception? Exception) + : base(EventName, ChannelId, ChannelProviderId, PipelineName, ResourceId, DispatchStatus, ChannelCommunication, ContentModel, Exception) + { + var infobipException = this.Infobip().Voice.Error; + if (infobipException != null && Exception == null) + base.Exception = new InfobipException(infobipException); + } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryStatusReportAdaptor.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryStatusReportAdaptor.cs new file mode 100644 index 0000000..f8aed06 --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryStatusReportAdaptor.cs @@ -0,0 +1,68 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Transmitly.Delivery; + +namespace Transmitly.ChannelProvider.Infobip.Email +{ + sealed class EmailDeliveryStatusReportAdaptor : IChannelProviderDeliveryReportRequestAdaptor + { + public Task?> AdaptAsync(IRequestAdaptorContext adaptorContext) + { + + if (!ShouldAdapt(adaptorContext)) + return Task.FromResult?>(null); + + var statuses = JsonSerializer.Deserialize(adaptorContext.Content!); + + if (statuses?.Results == null) + return Task.FromResult?>(null); + + var ret = new List(statuses.Results.Count); + foreach (var emailReport in statuses.Results) + { + var report = new EmailDeliveryReport( + DeliveryReport.Event.StatusChanged(), + Id.Channel.Email(), + Id.ChannelProvider.Infobip(), + adaptorContext.PipelineName, + emailReport.MessageId, + Util.ToDispatchStatus(emailReport.Status?.GroupId), + null, + null, + null + ).ApplyExtendedProperties(emailReport); + + ret.Add(report); + } + + return Task.FromResult?>(ret); + } + + private static bool ShouldAdapt(IRequestAdaptorContext adaptorContext) + { + if (string.IsNullOrWhiteSpace(adaptorContext.Content)) + return false; + return + (adaptorContext.GetValue(DeliveryUtil.ChannelIdKey)?.Equals(Id.Channel.Email(), StringComparison.InvariantCultureIgnoreCase) ?? false) && + (adaptorContext.GetValue(DeliveryUtil.ChannelProviderIdKey)?.Equals(Id.ChannelProvider.Infobip(), StringComparison.InvariantCultureIgnoreCase) ?? false); + + + } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailField.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailField.cs index 95b5056..ec09ffb 100644 --- a/src/Transmitly.ChannelProvider.Infobip/Email/EmailField.cs +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailField.cs @@ -28,6 +28,15 @@ internal static class EmailField public const string NotifyUrl = "notifyUrl"; public const string Track = "track"; public const string EntityId = "entityId"; - public const string ApplicationId = "applciationId"; + public const string ApplicationId = "applicationId"; + public const string AmpHtml = "ampHtml"; + public const string TrackClicks = "trackClicks"; + public const string trackOpens = "trackOpens"; + public const string TrackingUrl = "trackingUrl"; + public const string BulkId = "bulkId"; + public const string MessageId = "messageId"; + public const string ReplyTo = "replyTo"; + public const string preserveRecipients = "preserveRecipients"; + public const string sendAt = "sendAt"; } } \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailPrice.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailPrice.cs new file mode 100644 index 0000000..5793645 --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailPrice.cs @@ -0,0 +1,25 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Text.Json.Serialization; +namespace Transmitly.ChannelProvider.Infobip.Email +{ + public sealed class EmailPrice + { + [JsonPropertyName("pricePerMessage")] + public double? PricePerMessage { get; set; } + [JsonPropertyName("currency")] + public string? Currency { get; set; } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReport.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReport.cs new file mode 100644 index 0000000..b9f683e --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReport.cs @@ -0,0 +1,57 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Text.Json.Serialization; + +namespace Transmitly.ChannelProvider.Infobip.Email +{ + sealed class EmailStatusReport + { + [JsonPropertyName("bulkId")] + public string? BulkId { get; set; } + + [JsonPropertyName("messageId")] + public string? MessageId { get; set; } + + [JsonPropertyName("to")] + public string? To { get; set; } + + [JsonPropertyName("sentAt")] + [JsonConverter(typeof(InfobipDateTimeOffsetConverter))] + public DateTimeOffset? SentAt { get; set; } + + [JsonPropertyName("doneAt")] + [JsonConverter(typeof(InfobipDateTimeOffsetConverter))] + public DateTimeOffset? DoneAt { get; set; } + + [JsonPropertyName("smsCount")] + public int? SmsCount { get; set; } + + [JsonPropertyName("callbackData")] + public string? CallbackData { get; set; } + + [JsonPropertyName("price")] + public EmailPrice? Price { get; set; } + + [JsonPropertyName("status")] + public CallbackStatus? Status { get; set; } + + [JsonPropertyName("error")] + public ErrorStatus? Error { get; set; } + + [JsonPropertyName("browserLink")] + public string? BrowserLink { get; set; } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReports.cs b/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReports.cs new file mode 100644 index 0000000..f7609a8 --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReports.cs @@ -0,0 +1,24 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using System.Text.Json.Serialization; +namespace Transmitly.ChannelProvider.Infobip.Email +{ + sealed class EmailStatusReports + { + [JsonPropertyName("results")] + public List? Results { get; set; } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailChannelProperties.cs b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailChannelProperties.cs index 1adeeed..c770c54 100644 --- a/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailChannelProperties.cs +++ b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailChannelProperties.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Threading.Tasks; +using System; using Transmitly.Template.Configuration; namespace Transmitly.ChannelProvider.Infobip.Email @@ -28,7 +30,7 @@ internal ExtendedEmailChannelProperties(IExtendedProperties properties) AmpHtml = new ContentTemplateConfiguration(); } - internal ExtendedEmailChannelProperties(IEmailChannel channel):this(Guard.AgainstNull(channel).ExtendedProperties) + internal ExtendedEmailChannelProperties(IEmailChannel channel) : this(Guard.AgainstNull(channel).ExtendedProperties) { } @@ -99,5 +101,32 @@ public IContentTemplateConfiguration AmpHtml get => _extendedProperties.GetValue(ProviderKey, nameof(NotifyUrl)); set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(NotifyUrl), value); } + + /// + /// The resolver to get the URL on your callback server on which the Delivery report will be sent. + /// + public Func>? NotifyUrlResolver + { + get => _extendedProperties.GetValue>>(ProviderKey, nameof(NotifyUrlResolver)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(NotifyUrlResolver), value); + } + + /// + /// Required for application use in a send request for outbound traffic. Returned in notification events. + /// + public string? ApplicationId + { + get => _extendedProperties.GetValue(ProviderKey, nameof(ApplicationId)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(ApplicationId), value); + } + + /// + /// Required for entity use in a send request for outbound traffic. Returned in notification events. + /// + public string? EntityId + { + get => _extendedProperties.GetValue(ProviderKey, nameof(EntityId)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(EntityId), value); + } } } \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailDeliveryReportProperties.cs b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailDeliveryReportProperties.cs new file mode 100644 index 0000000..c39c1f2 --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedEmailDeliveryReportProperties.cs @@ -0,0 +1,141 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using Transmitly.Delivery; + +namespace Transmitly.ChannelProvider.Infobip.Email +{ + public sealed class ExtendedEmailDeliveryReportProperties + { + private readonly IExtendedProperties _extendedProperties; + private const string ProviderKey = Constant.SmsPropertiesKey; + internal ExtendedEmailDeliveryReportProperties(DeliveryReport deliveryReport) + { + _extendedProperties = Guard.AgainstNull(deliveryReport).ExtendedProperties; + } + + internal ExtendedEmailDeliveryReportProperties(IExtendedProperties properties) + { + _extendedProperties = Guard.AgainstNull(properties); + } + + internal void Apply(EmailStatusReport report) + { + BulkId = report.BulkId; + MessageId = report.MessageId; + To = report.To; + SentAt = report.SentAt; + DoneAt = report.DoneAt; + SmsCount = report.SmsCount; + CallbackData = report.CallbackData; + Price = report.Price; + Status = report.Status; + Error = report.Error; + } + + /// + /// Unique ID assigned to the request if messaging multiple recipients + /// or sending multiple messages via a single API request. + /// + public string? BulkId + { + get => _extendedProperties.GetValue(ProviderKey, nameof(BulkId)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(BulkId), value); + } + + /// + /// Unique message ID. + /// + public string? MessageId + { + get => _extendedProperties.GetValue(ProviderKey, nameof(MessageId)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(MessageId), value); + } + + /// + /// Message destination address. + /// + public string? To + { + get => _extendedProperties.GetValue(ProviderKey, nameof(To)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(To), value); + } + + /// + /// Date and time when the message was scheduled to be sent. + /// Has the following format: yyyy-MM-dd'T'HH:mm:ss.SSSZ. + /// + public DateTimeOffset? SentAt + { + get => _extendedProperties.GetValue(ProviderKey, nameof(SentAt)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(SentAt), value); + } + + /// + /// Date and time when the Infobip services finished processing the message + /// (i.e., delivered to the destination, delivered to the destination network, etc.). + /// Has the following format: yyyy-MM-dd'T'HH:mm:ss.SSSZ. + /// + public DateTimeOffset? DoneAt + { + get => _extendedProperties.GetValue(ProviderKey, nameof(DoneAt)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(DoneAt), value); + } + + /// + /// The number of emails sent. + /// + public int? SmsCount + { + get => _extendedProperties.GetValue(ProviderKey, nameof(SmsCount)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(SmsCount), value); + } + + /// + /// Custom data sent over to the notifyUrl. + /// + public string? CallbackData + { + get => _extendedProperties.GetValue(ProviderKey, nameof(CallbackData)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(CallbackData), value); + } + + /// + /// Sent Email price. + /// + public EmailPrice? Price + { + get => _extendedProperties.GetValue(ProviderKey, nameof(Price)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(Price), value); + } + /// + /// Indicates the status of the message and how to recover from an error should there be any. + /// + public CallbackStatus? Status + { + get => _extendedProperties.GetValue(ProviderKey, nameof(Status)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(Status), value); + } + + /// + /// Indicates whether an error occurred during the query execution. + /// + public ErrorStatus? Error + { + get => _extendedProperties.GetValue(ProviderKey, nameof(Error)); + set => _extendedProperties.AddOrUpdate(ProviderKey, nameof(Error), value); + } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedVoiceDeliveryReportExtension.cs b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedVoiceDeliveryReportExtension.cs new file mode 100644 index 0000000..2cb72bd --- /dev/null +++ b/src/Transmitly.ChannelProvider.Infobip/Email/ExtendedVoiceDeliveryReportExtension.cs @@ -0,0 +1,34 @@ +// Copyright (c) Code Impressions, LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Transmitly.ChannelProvider.Infobip.Email +{ + internal static class ExtendedEmailDeliveryReportExtension + { + public static EmailDeliveryReport ApplyExtendedProperties(this EmailDeliveryReport voiceDeliveryReport, EmailStatusReport report) + { + _ = new ExtendedEmailDeliveryReportProperties(voiceDeliveryReport) + { + BulkId = report.BulkId, + MessageId = report.MessageId, + To = report.To, + CallbackData = report.CallbackData, + Price = report.Price, + Status = report.Status, + Error = report.Error + }; + return voiceDeliveryReport; + } + } +} \ No newline at end of file diff --git a/src/Transmitly.ChannelProvider.Infobip/InfobipChannelProviderExtensions.cs b/src/Transmitly.ChannelProvider.Infobip/InfobipChannelProviderExtensions.cs index 137cbcd..340b9f8 100644 --- a/src/Transmitly.ChannelProvider.Infobip/InfobipChannelProviderExtensions.cs +++ b/src/Transmitly.ChannelProvider.Infobip/InfobipChannelProviderExtensions.cs @@ -91,6 +91,7 @@ public static CommunicationsClientBuilder AddInfobipSupport(this CommunicationsC communicationsClientBuilder.AddChannelProvider(Id.ChannelProvider.Infobip(providerId), optionObj, Id.Channel.Voice()); communicationsClientBuilder.ChannelProvider.AddDeliveryReportRequestAdaptor(); communicationsClientBuilder.ChannelProvider.AddDeliveryReportRequestAdaptor(); + communicationsClientBuilder.ChannelProvider.AddDeliveryReportRequestAdaptor(); return communicationsClientBuilder; } }