-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62c86b6
commit cbc07b9
Showing
11 changed files
with
460 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/Transmitly.ChannelProvider.Infobip/Email/EmailDeliveryStatusReportAdaptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IReadOnlyCollection<DeliveryReport>?> AdaptAsync(IRequestAdaptorContext adaptorContext) | ||
{ | ||
|
||
if (!ShouldAdapt(adaptorContext)) | ||
return Task.FromResult<IReadOnlyCollection<DeliveryReport>?>(null); | ||
|
||
var statuses = JsonSerializer.Deserialize<EmailStatusReports>(adaptorContext.Content!); | ||
|
||
if (statuses?.Results == null) | ||
return Task.FromResult<IReadOnlyCollection<DeliveryReport>?>(null); | ||
|
||
var ret = new List<DeliveryReport>(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<IReadOnlyCollection<DeliveryReport>?>(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); | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Transmitly.ChannelProvider.Infobip/Email/EmailPrice.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Transmitly.ChannelProvider.Infobip/Email/EmailStatusReports.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<EmailStatusReport>? Results { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.