From ea1c6ead44917d03a806ab9a622c078f6c984878 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Thu, 30 Mar 2023 11:08:29 +0100 Subject: [PATCH] Fix failed Email Proxy call and record error better --- .../Services/MessagingDomainServiceTests.cs | 64 +++++++ .../EmailServiceProxyResponse.cs | 32 +--- .../IntegrationTestEmailServiceProxy.cs | 2 +- .../EmailServices/Smtp2Go/Smtp2GoProxy.cs | 17 +- .../Services/MessagingDomainService.cs | 9 +- .../EmailAggregateTests.cs | 14 ++ .../DomainEvents.cs | 44 +++++ .../EmailMessageBouncedEvent.cs | 55 ------ .../EmailMessageDeliveredEvent.cs | 55 ------ .../EmailMessageFailedEvent.cs | 47 ----- .../EmailMessageMarkedAsSpamEvent.cs | 55 ------ .../EmailMessageRejectedEvent.cs | 55 ------ .../RequestResentToEmailProviderEvent.cs | 20 --- .../RequestSentToEmailProviderEvent.cs | 95 ---------- .../ResponseReceivedFromProvider.cs | 55 ------ .../EmailAggregate.cs | 164 +++--------------- .../DomainEvents.cs | 28 +++ .../RequestSentToSMSProviderEvent.cs | 66 ------- .../ResponseReceivedFromSMSProvider.cs | 44 ----- .../SMSMessageDeliveredEvent.cs | 55 ------ .../SMSMessageExpiredEvent.cs | 55 ------ .../SMSMessageRejectedEvent.cs | 55 ------ .../SMSMessageUndeliveredEvent.cs | 55 ------ MessagingService.Testing/TestData.cs | 22 ++- MessagingService/appsettings.json | 2 +- 25 files changed, 215 insertions(+), 950 deletions(-) create mode 100644 MessagingService.EmailMessage.DomainEvents/DomainEvents.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/EmailMessageBouncedEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/EmailMessageDeliveredEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/EmailMessageFailedEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/EmailMessageMarkedAsSpamEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/EmailMessageRejectedEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/RequestResentToEmailProviderEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/RequestSentToEmailProviderEvent.cs delete mode 100644 MessagingService.EmailMessage.DomainEvents/ResponseReceivedFromProvider.cs create mode 100644 MessagingService.SMSMessage.DomainEvents/DomainEvents.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/RequestSentToSMSProviderEvent.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/ResponseReceivedFromSMSProvider.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/SMSMessageDeliveredEvent.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/SMSMessageExpiredEvent.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/SMSMessageRejectedEvent.cs delete mode 100644 MessagingService.SMSMessage.DomainEvents/SMSMessageUndeliveredEvent.cs diff --git a/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs b/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs index 32abf7a..8f15cb4 100644 --- a/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs +++ b/MessagingService.BusinessLogic.Tests/Services/MessagingDomainServiceTests.cs @@ -52,6 +52,70 @@ await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, CancellationToken.None); } + [Fact] + public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APICallFailed_MessageFailed() + { + Mock> emailAggregateRepository = new Mock>(); + emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); + Mock> smsAggregateRepository = new Mock>(); + Mock emailServiceProxy = new Mock(); + emailServiceProxy + .Setup(e => e.SendEmail(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny())).ReturnsAsync(TestData.FailedAPICallEmailServiceProxyResponse); + Mock smsServiceProxy = new Mock(); + + MessagingDomainService messagingDomainService = + new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + + await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, + TestData.MessageId, + TestData.FromAddress, + TestData.ToAddresses, + TestData.Subject, + TestData.Body, + TestData.IsHtmlTrue, + TestData.EmailAttachmentModels, + CancellationToken.None); + } + + [Fact] + public async Task MessagingDomainService_SendEmailMessage_EmailSentFailed_APIResponseError_MessageFailed() + { + Mock> emailAggregateRepository = new Mock>(); + emailAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetEmptyEmailAggregate()); + Mock> smsAggregateRepository = new Mock>(); + Mock emailServiceProxy = new Mock(); + emailServiceProxy + .Setup(e => e.SendEmail(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny())).ReturnsAsync(TestData.FailedEmailServiceProxyResponse); + Mock smsServiceProxy = new Mock(); + + MessagingDomainService messagingDomainService = + new MessagingDomainService(emailAggregateRepository.Object, smsAggregateRepository.Object, emailServiceProxy.Object, smsServiceProxy.Object); + + await messagingDomainService.SendEmailMessage(TestData.ConnectionIdentifier, + TestData.MessageId, + TestData.FromAddress, + TestData.ToAddresses, + TestData.Subject, + TestData.Body, + TestData.IsHtmlTrue, + TestData.EmailAttachmentModels, + CancellationToken.None); + } + [Fact] public async Task MessagingDomainService_ResendEmailMessage_MessageSent() { diff --git a/MessagingService.BusinessLogic/Services/EmailServices/EmailServiceProxyResponse.cs b/MessagingService.BusinessLogic/Services/EmailServices/EmailServiceProxyResponse.cs index 69240d2..af64fe3 100644 --- a/MessagingService.BusinessLogic/Services/EmailServices/EmailServiceProxyResponse.cs +++ b/MessagingService.BusinessLogic/Services/EmailServices/EmailServiceProxyResponse.cs @@ -10,44 +10,14 @@ [ExcludeFromCodeCoverage] public class EmailServiceProxyResponse { - /// - /// Gets or sets the API status code. - /// - /// - /// The API status code. - /// - public HttpStatusCode ApiStatusCode { get; set; } + public Boolean ApiCallSuccessful { get; set; } - /// - /// Gets or sets the request identifier. - /// - /// - /// The request identifier. - /// public String RequestIdentifier { get; set; } - /// - /// Gets or sets the email identifier. - /// - /// - /// The email identifier. - /// public String EmailIdentifier { get; set; } - /// - /// Gets or sets the error code. - /// - /// - /// The error code. - /// public String ErrorCode { get; set; } - /// - /// Gets or sets the error. - /// - /// - /// The error. - /// public String Error { get; set; } } } \ No newline at end of file diff --git a/MessagingService.BusinessLogic/Services/EmailServices/IntegrationTest/IntegrationTestEmailServiceProxy.cs b/MessagingService.BusinessLogic/Services/EmailServices/IntegrationTest/IntegrationTestEmailServiceProxy.cs index 79bddfd..f6d8f41 100644 --- a/MessagingService.BusinessLogic/Services/EmailServices/IntegrationTest/IntegrationTestEmailServiceProxy.cs +++ b/MessagingService.BusinessLogic/Services/EmailServices/IntegrationTest/IntegrationTestEmailServiceProxy.cs @@ -62,7 +62,7 @@ public async Task SendEmail(Guid messageId, { RequestIdentifier = "requestid", EmailIdentifier = "emailid", - ApiStatusCode = HttpStatusCode.OK, + ApiCallSuccessful = true, Error = string.Empty, ErrorCode = string.Empty }; diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs index f79bfec..44c778c 100644 --- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs +++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs @@ -102,20 +102,31 @@ public async Task SendEmail(Guid messageId, StringContent content = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); - String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}/email/send"; + String requestUri = $"{ConfigurationReader.GetValue("SMTP2GoBaseAddress")}email/send"; HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri); requestMessage.Content = content; HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken); - Smtp2GoSendEmailResponse apiResponse = JsonConvert.DeserializeObject(await httpResponse.Content.ReadAsStringAsync()); + Smtp2GoSendEmailResponse apiResponse = new Smtp2GoSendEmailResponse(){ + Data = new Smtp2GoSendEmailResponseData() + }; + if (httpResponse.IsSuccessStatusCode){ + apiResponse = JsonConvert.DeserializeObject(await httpResponse.Content.ReadAsStringAsync()); + } + else{ + apiResponse = new Smtp2GoSendEmailResponse(); + apiResponse.Data = new Smtp2GoSendEmailResponseData(); + apiResponse.Data.Error = httpResponse.StatusCode.ToString(); + apiResponse.Data.ErrorCode = ((Int32)httpResponse.StatusCode).ToString(); + } Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {JsonConvert.SerializeObject(apiResponse)}"); // Translate the Response response = new EmailServiceProxyResponse { - ApiStatusCode = httpResponse.StatusCode, + ApiCallSuccessful = httpResponse.IsSuccessStatusCode && String.IsNullOrEmpty(apiResponse.Data.ErrorCode), EmailIdentifier = apiResponse.Data.EmailId, Error = apiResponse.Data.Error, ErrorCode = apiResponse.Data.ErrorCode, diff --git a/MessagingService.BusinessLogic/Services/MessagingDomainService.cs b/MessagingService.BusinessLogic/Services/MessagingDomainService.cs index ed3c79e..1721fd2 100644 --- a/MessagingService.BusinessLogic/Services/MessagingDomainService.cs +++ b/MessagingService.BusinessLogic/Services/MessagingDomainService.cs @@ -71,8 +71,13 @@ public async Task SendEmailMessage(Guid connectionIdentifier, EmailServiceProxyResponse emailResponse = await this.EmailServiceProxy.SendEmail(messageId, fromAddress, toAddresses, subject, body, isHtml, attachments, cancellationToken); - // response message from provider (record event) - emailAggregate.ReceiveResponseFromProvider(emailResponse.RequestIdentifier, emailResponse.EmailIdentifier); + if (emailResponse.ApiCallSuccessful){ + // response message from provider (record event) + emailAggregate.ReceiveResponseFromProvider(emailResponse.RequestIdentifier, emailResponse.EmailIdentifier); + } + else{ + emailAggregate.ReceiveBadResponseFromProvider(emailResponse.Error,emailResponse.ErrorCode); + } // Save Changes to persistance await this.EmailAggregateRepository.SaveChanges(emailAggregate, cancellationToken); diff --git a/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs b/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs index 64b1f5c..5f7709f 100644 --- a/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs +++ b/MessagingService.EmailAggregate.Tests/EmailAggregateTests.cs @@ -65,6 +65,20 @@ public void EmailAggregate_ReceiveResponseFromProvider_ResponseReceived() { messageStatus.ShouldBe(MessageStatus.Sent); } + [Fact] + public void EmailAggregate_ReceiveBadResponseFromProvider_ResponseReceived() + { + EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId); + + emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue, TestData.EmailAttachmentModels); + emailAggregate.ReceiveBadResponseFromProvider(TestData.EmailError, TestData.EmailErrorCode); + + emailAggregate.Error.ShouldBe(TestData.EmailError); + emailAggregate.ErrorCode.ShouldBe(TestData.EmailErrorCode); + MessageStatus messageStatus = emailAggregate.GetDeliveryStatus(); + messageStatus.ShouldBe(MessageStatus.Failed); + } + [Fact] public void EmailAggregate_MarkMessageAsDelivered_MessageMarkedAsDelivered() { EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId); diff --git a/MessagingService.EmailMessage.DomainEvents/DomainEvents.cs b/MessagingService.EmailMessage.DomainEvents/DomainEvents.cs new file mode 100644 index 0000000..2b7a38d --- /dev/null +++ b/MessagingService.EmailMessage.DomainEvents/DomainEvents.cs @@ -0,0 +1,44 @@ +namespace MessagingService.EmailMessage.DomainEvents; + +using System; +using System.Collections.Generic; +using Shared.DomainDrivenDesign.EventSourcing; + +public record ResponseReceivedFromEmailProviderEvent(Guid MessageId, + String ProviderRequestReference, + String ProviderEmailReference) : DomainEvent(MessageId, Guid.NewGuid()); + +public record BadResponseReceivedFromEmailProviderEvent(Guid MessageId, + String ErrorCode, + String Error) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailMessageBouncedEvent(Guid MessageId, + String ProviderStatus, + DateTime BouncedDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailMessageDeliveredEvent(Guid MessageId, + String ProviderStatus, + DateTime DeliveredDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailMessageFailedEvent(Guid MessageId, + String ProviderStatus, + DateTime FailedDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailMessageMarkedAsSpamEvent(Guid MessageId, + String ProviderStatus, + DateTime SpamDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailMessageRejectedEvent(Guid MessageId, + String ProviderStatus, + DateTime RejectedDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record RequestResentToEmailProviderEvent(Guid MessageId) : DomainEvent(MessageId, Guid.NewGuid()); + +public record EmailAttachmentRequestSentToProviderEvent(Guid MessageId, String Filename, String FileData, Int32 FileType) : DomainEvent(MessageId, Guid.NewGuid()); + +public record RequestSentToEmailProviderEvent(Guid MessageId, + String FromAddress, + List ToAddresses, + String Subject, + String Body, + Boolean IsHtml) : DomainEvent(MessageId, Guid.NewGuid()); \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/EmailMessageBouncedEvent.cs b/MessagingService.EmailMessage.DomainEvents/EmailMessageBouncedEvent.cs deleted file mode 100644 index 9b9205e..0000000 --- a/MessagingService.EmailMessage.DomainEvents/EmailMessageBouncedEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailMessageBouncedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the . - /// - /// The aggregate identifier. - /// The provider status. - /// The bounced date time. - public EmailMessageBouncedEvent(Guid aggregateId, - String providerStatus, - DateTime bouncedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.BouncedDateTime = bouncedDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets the bounced date time. - /// - /// - /// The bounced date time. - /// - public DateTime BouncedDateTime { get; init; } - - /// - /// Gets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/EmailMessageDeliveredEvent.cs b/MessagingService.EmailMessage.DomainEvents/EmailMessageDeliveredEvent.cs deleted file mode 100644 index 9a1aa3b..0000000 --- a/MessagingService.EmailMessage.DomainEvents/EmailMessageDeliveredEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailMessageDeliveredEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the . - /// - /// The aggregate identifier. - /// The provider status. - /// The delivered date time. - public EmailMessageDeliveredEvent(Guid aggregateId, - String providerStatus, - DateTime deliveredDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.DeliveredDateTime = deliveredDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets the delivered date time. - /// - /// - /// The delivered date time. - /// - public DateTime DeliveredDateTime { get; init; } - - /// - /// Gets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/EmailMessageFailedEvent.cs b/MessagingService.EmailMessage.DomainEvents/EmailMessageFailedEvent.cs deleted file mode 100644 index 458d8ff..0000000 --- a/MessagingService.EmailMessage.DomainEvents/EmailMessageFailedEvent.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailMessageFailedEvent : DomainEvent - { - /// - /// Initializes a new instance of the . - /// - /// The aggregate identifier. - /// The provider status. - /// The failed date time. - public EmailMessageFailedEvent(Guid aggregateId, - String providerStatus, - DateTime failedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.FailedDateTime = failedDateTime; - } - - /// - /// Gets the failed date time. - /// - /// - /// The failed date time. - /// - public DateTime FailedDateTime { get; init; } - - /// - /// Gets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/EmailMessageMarkedAsSpamEvent.cs b/MessagingService.EmailMessage.DomainEvents/EmailMessageMarkedAsSpamEvent.cs deleted file mode 100644 index d6673b8..0000000 --- a/MessagingService.EmailMessage.DomainEvents/EmailMessageMarkedAsSpamEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailMessageMarkedAsSpamEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The spam date time. - public EmailMessageMarkedAsSpamEvent(Guid aggregateId, - String providerStatus, - DateTime spamDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.SpamDateTime = spamDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - /// - /// Gets or sets the spam date time. - /// - /// - /// The spam date time. - /// - public DateTime SpamDateTime { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/EmailMessageRejectedEvent.cs b/MessagingService.EmailMessage.DomainEvents/EmailMessageRejectedEvent.cs deleted file mode 100644 index fc65b85..0000000 --- a/MessagingService.EmailMessage.DomainEvents/EmailMessageRejectedEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailMessageRejectedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The rejected date time. - public EmailMessageRejectedEvent(Guid aggregateId, - String providerStatus, - DateTime rejectedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.RejectedDateTime = rejectedDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - /// - /// Gets or sets the rejected date time. - /// - /// - /// The rejected date time. - /// - public DateTime RejectedDateTime { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/RequestResentToEmailProviderEvent.cs b/MessagingService.EmailMessage.DomainEvents/RequestResentToEmailProviderEvent.cs deleted file mode 100644 index 4080872..0000000 --- a/MessagingService.EmailMessage.DomainEvents/RequestResentToEmailProviderEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents; - -using System; -using Shared.DomainDrivenDesign.EventSourcing; - -public record RequestResentToEmailProviderEvent : DomainEvent -{ - public RequestResentToEmailProviderEvent(Guid aggregateId) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - } - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/RequestSentToEmailProviderEvent.cs b/MessagingService.EmailMessage.DomainEvents/RequestSentToEmailProviderEvent.cs deleted file mode 100644 index 4cc3f84..0000000 --- a/MessagingService.EmailMessage.DomainEvents/RequestSentToEmailProviderEvent.cs +++ /dev/null @@ -1,95 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using System.Collections.Generic; - using Shared.DomainDrivenDesign.EventSourcing; - - public record EmailAttachmentRequestSentToProviderEvent : DomainEvent{ - public EmailAttachmentRequestSentToProviderEvent(Guid aggregateId,String fileName, String fileData, Int32 fileType) : base(aggregateId, Guid.NewGuid()){ - this.MessageId = aggregateId; - this.FileData=fileData; - this.FileType = fileType; - this.Filename = fileName; - } - public String FileData { get; init; } - public String Filename { get; init; } - public Int32 FileType { get; init; } - public Guid MessageId { get; init; } - } - - public record RequestSentToEmailProviderEvent : DomainEvent - { - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// From address. - /// To addresses. - /// The subject. - /// The body. - /// if set to true [is HTML]. - public RequestSentToEmailProviderEvent(Guid aggregateId, - String fromAddress, - List toAddresses, - String subject, - String body, - Boolean isHtml) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.FromAddress = fromAddress; - this.ToAddresses = toAddresses; - this.Subject = subject; - this.Body = body; - this.IsHtml = isHtml; - } - - /// - /// Gets or sets the body. - /// - /// - /// The body. - /// - public String Body { get; init; } - /// - /// Gets or sets from address. - /// - /// - /// From address. - /// - public String FromAddress { get; init; } - - - /// - /// Gets or sets a value indicating whether this instance is HTML. - /// - /// - /// true if this instance is HTML; otherwise, false. - /// - public Boolean IsHtml { get; init; } - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - - /// - /// Gets or sets the subject. - /// - /// - /// The subject. - /// - public String Subject { get; init; } - - - /// - /// Converts to addresses. - /// - /// - /// To addresses. - /// - public List ToAddresses { get; init; } - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessage.DomainEvents/ResponseReceivedFromProvider.cs b/MessagingService.EmailMessage.DomainEvents/ResponseReceivedFromProvider.cs deleted file mode 100644 index 2ba2493..0000000 --- a/MessagingService.EmailMessage.DomainEvents/ResponseReceivedFromProvider.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.EmailMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record ResponseReceivedFromEmailProviderEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider request reference. - /// The provider email reference. - public ResponseReceivedFromEmailProviderEvent(Guid aggregateId, - String providerRequestReference, - String providerEmailReference) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderRequestReference = providerRequestReference; - this.ProviderEmailReference = providerEmailReference; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider email reference. - /// - /// - /// The provider email reference. - /// - public String ProviderEmailReference { get; init; } - - /// - /// Gets or sets the provider request reference. - /// - /// - /// The provider request reference. - /// - public String ProviderRequestReference { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.EmailMessageAggregate/EmailAggregate.cs b/MessagingService.EmailMessageAggregate/EmailAggregate.cs index ac6a7fa..e10ff8c 100644 --- a/MessagingService.EmailMessageAggregate/EmailAggregate.cs +++ b/MessagingService.EmailMessageAggregate/EmailAggregate.cs @@ -15,9 +15,6 @@ public class EmailAggregate : Aggregate { #region Fields - /// - /// The recipients - /// private readonly List Recipients; private readonly List Attachments; @@ -37,9 +34,6 @@ public List GetAttachments() #region Constructors - /// - /// Initializes a new instance of the class. - /// [ExcludeFromCodeCoverage] public EmailAggregate() { @@ -50,10 +44,6 @@ public EmailAggregate() }; } - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. private EmailAggregate(Guid aggregateId) { Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); @@ -71,60 +61,22 @@ private EmailAggregate(Guid aggregateId) #region Properties - /// - /// Gets the body. - /// - /// - /// The body. - /// public String Body { get; private set; } - /// - /// Gets from address. - /// - /// - /// From address. - /// public String FromAddress { get; private set; } - /// - /// Gets a value indicating whether this instance is HTML. - /// - /// - /// true if this instance is HTML; otherwise, false. - /// public Boolean IsHtml { get; private set; } - /// - /// Gets the message identifier. - /// - /// - /// The message identifier. - /// public Guid MessageId { get; } - /// - /// Gets the provider email reference. - /// - /// - /// The provider email reference. - /// public String ProviderEmailReference { get; private set; } - /// - /// Gets the provider request reference. - /// - /// - /// The provider request reference. - /// public String ProviderRequestReference { get; private set; } - /// - /// Gets the subject. - /// - /// - /// The subject. - /// + public String Error { get; private set; } + + public String ErrorCode { get; private set; } + public String Subject { get; private set; } public Int32 ResendCount { get; private set; } @@ -135,21 +87,11 @@ private EmailAggregate(Guid aggregateId) #region Methods - /// - /// Creates the specified aggregate identifier. - /// - /// The aggregate identifier. - /// public static EmailAggregate Create(Guid aggregateId) { return new EmailAggregate(aggregateId); } - /// - /// Marks the message as bounced. - /// - /// The provider status. - /// The bounced date time. public void MarkMessageAsBounced(String providerStatus, DateTime bouncedDateTime) { @@ -160,11 +102,6 @@ public void MarkMessageAsBounced(String providerStatus, this.ApplyAndAppend(messageBouncedEvent); } - /// - /// Marks the message as delivered. - /// - /// The provider status. - /// The delivered date time. public void MarkMessageAsDelivered(String providerStatus, DateTime deliveredDateTime) { @@ -175,11 +112,6 @@ public void MarkMessageAsDelivered(String providerStatus, this.ApplyAndAppend(messageDeliveredEvent); } - /// - /// Marks the message as failed. - /// - /// The provider status. - /// The failed date time. public void MarkMessageAsFailed(String providerStatus, DateTime failedDateTime) { @@ -190,11 +122,6 @@ public void MarkMessageAsFailed(String providerStatus, this.ApplyAndAppend(messageFailedEvent); } - /// - /// Marks the message as rejected. - /// - /// The provider status. - /// The rejected date time. public void MarkMessageAsRejected(String providerStatus, DateTime rejectedDateTime) { @@ -205,11 +132,6 @@ public void MarkMessageAsRejected(String providerStatus, this.ApplyAndAppend(messageRejectedEvent); } - /// - /// Marks the message as spam. - /// - /// The provider status. - /// The spam date time. public void MarkMessageAsSpam(String providerStatus, DateTime spamDateTime) { @@ -220,11 +142,6 @@ public void MarkMessageAsSpam(String providerStatus, this.ApplyAndAppend(messageMarkedAsSpamEvent); } - /// - /// Messages the send to recipient failure. - /// - /// The provider request reference. - /// The provider email reference. public void ReceiveResponseFromProvider(String providerRequestReference, String providerEmailReference) { @@ -233,7 +150,15 @@ public void ReceiveResponseFromProvider(String providerRequestReference, this.ApplyAndAppend(responseReceivedFromProviderEvent); } - + + public void ReceiveBadResponseFromProvider(String error, String errorCode) + { + BadResponseReceivedFromEmailProviderEvent badResponseReceivedFromProviderEvent = + new BadResponseReceivedFromEmailProviderEvent(this.AggregateId, errorCode,error); + + this.ApplyAndAppend(badResponseReceivedFromProviderEvent); + } + public void SendRequestToProvider(String fromAddress, List toAddresses, String subject, @@ -273,20 +198,12 @@ public void ResendRequestToProvider() this.ApplyAndAppend(requestResentToEmailProviderEvent); } - /// - /// Gets the metadata. - /// - /// [ExcludeFromCodeCoverage] protected override Object GetMetadata() { return null; } - /// - /// Plays the event. - /// - /// The domain event. public override void PlayEvent(IDomainEvent domainEvent) { this.PlayEvent((dynamic)domainEvent); @@ -300,10 +217,6 @@ private void PlayEvent(Object @event) throw ex; } - /// - /// Checks the message can be set to bounced. - /// - /// Message at status {this.MessageStatus} cannot be set to bounced private void CheckMessageCanBeSetToBounced() { if (this.DeliveryStatusList[this.ResendCount] != MessageStatus.Sent) @@ -312,10 +225,6 @@ private void CheckMessageCanBeSetToBounced() } } - /// - /// Checks the message can be set to delivered. - /// - /// Message at status {this.MessageStatus} cannot be set to delivered private void CheckMessageCanBeSetToDelivered() { if (this.DeliveryStatusList[this.ResendCount] != MessageStatus.Sent) @@ -324,10 +233,6 @@ private void CheckMessageCanBeSetToDelivered() } } - /// - /// Checks the message can be set to failed. - /// - /// Message at status {this.MessageStatus} cannot be set to failed private void CheckMessageCanBeSetToFailed() { if (this.DeliveryStatusList[this.ResendCount] != MessageStatus.Sent) @@ -336,10 +241,6 @@ private void CheckMessageCanBeSetToFailed() } } - /// - /// Checks the message can be set to rejected. - /// - /// Message at status {this.MessageStatus} cannot be set to rejected private void CheckMessageCanBeSetToRejected() { if (this.DeliveryStatusList[this.ResendCount] != MessageStatus.Sent) @@ -348,10 +249,6 @@ private void CheckMessageCanBeSetToRejected() } } - /// - /// Checks the message can be set to spam. - /// - /// Message at status {this.MessageStatus} cannot be set to spam private void CheckMessageCanBeSetToSpam() { if (this.DeliveryStatusList[this.ResendCount] != MessageStatus.Sent) @@ -360,10 +257,6 @@ private void CheckMessageCanBeSetToSpam() } } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(RequestSentToEmailProviderEvent domainEvent) { this.Body = domainEvent.Body; @@ -382,10 +275,6 @@ private void PlayEvent(RequestSentToEmailProviderEvent domainEvent) } } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(ResponseReceivedFromEmailProviderEvent domainEvent) { this.ProviderEmailReference = domainEvent.ProviderEmailReference; @@ -393,6 +282,13 @@ private void PlayEvent(ResponseReceivedFromEmailProviderEvent domainEvent) this.DeliveryStatusList[this.ResendCount] = MessageStatus.Sent; } + private void PlayEvent(BadResponseReceivedFromEmailProviderEvent domainEvent) + { + this.Error = domainEvent.Error; + this.ErrorCode = domainEvent.ErrorCode; + this.DeliveryStatusList[this.ResendCount] = MessageStatus.Failed; + } + private void PlayEvent(EmailAttachmentRequestSentToProviderEvent domainEvent){ this.Attachments.Add(new EmailAttachment{ FileData = domainEvent.FileData, @@ -407,10 +303,6 @@ private void PlayEvent(RequestResentToEmailProviderEvent domainEvent) { this.DeliveryStatusList.Add(MessageStatus.InProgress); } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(EmailMessageDeliveredEvent domainEvent) { this.DeliveryStatusList[this.ResendCount] = MessageStatus.Delivered; @@ -423,37 +315,21 @@ public MessageStatus GetDeliveryStatus(Int32? resendAttempt = null) { return this.DeliveryStatusList[resendAttempt.Value]; } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(EmailMessageFailedEvent domainEvent) { this.DeliveryStatusList[this.ResendCount] = MessageStatus.Failed; } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(EmailMessageRejectedEvent domainEvent) { this.DeliveryStatusList[this.ResendCount] = MessageStatus.Rejected; } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(EmailMessageBouncedEvent domainEvent) { this.DeliveryStatusList[this.ResendCount] = MessageStatus.Bounced; } - /// - /// Plays the event. - /// - /// The domain event. private void PlayEvent(EmailMessageMarkedAsSpamEvent domainEvent) { this.DeliveryStatusList[this.ResendCount] = MessageStatus.Spam; diff --git a/MessagingService.SMSMessage.DomainEvents/DomainEvents.cs b/MessagingService.SMSMessage.DomainEvents/DomainEvents.cs new file mode 100644 index 0000000..e5e775e --- /dev/null +++ b/MessagingService.SMSMessage.DomainEvents/DomainEvents.cs @@ -0,0 +1,28 @@ +namespace MessagingService.SMSMessage.DomainEvents; + +using System; +using Shared.DomainDrivenDesign.EventSourcing; + +public record RequestSentToSMSProviderEvent(Guid MessageId, + String Sender, + String Destination, + String Message) : DomainEvent(MessageId, Guid.NewGuid()); + +public record ResponseReceivedFromSMSProviderEvent(Guid MessageId, + String ProviderSMSReference) : DomainEvent(MessageId, Guid.NewGuid()); + +public record SMSMessageDeliveredEvent(Guid MessageId, + String ProviderStatus, + DateTime DeliveredDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record SMSMessageExpiredEvent(Guid MessageId, + String ProviderStatus, + DateTime ExpiredDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record SMSMessageRejectedEvent(Guid MessageId, + String ProviderStatus, + DateTime RejectedDateTime) : DomainEvent(MessageId, Guid.NewGuid()); + +public record SMSMessageUndeliveredEvent(Guid MessageId, + String ProviderStatus, + DateTime UndeliveredDateTime) : DomainEvent(MessageId, Guid.NewGuid()); \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/RequestSentToSMSProviderEvent.cs b/MessagingService.SMSMessage.DomainEvents/RequestSentToSMSProviderEvent.cs deleted file mode 100644 index 3398e7c..0000000 --- a/MessagingService.SMSMessage.DomainEvents/RequestSentToSMSProviderEvent.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record RequestSentToSMSProviderEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The sender. - /// The destination. - /// The message. - public RequestSentToSMSProviderEvent(Guid aggregateId, - String sender, - String destination, - String message) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.Sender = sender; - this.Destination = destination; - this.Message = message; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the destination. - /// - /// - /// The destination. - /// - public String Destination { get; init; } - - /// - /// Gets or sets the message. - /// - /// - /// The message. - /// - public String Message { get; init; } - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the sender. - /// - /// - /// The sender. - /// - public String Sender { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/ResponseReceivedFromSMSProvider.cs b/MessagingService.SMSMessage.DomainEvents/ResponseReceivedFromSMSProvider.cs deleted file mode 100644 index 915b908..0000000 --- a/MessagingService.SMSMessage.DomainEvents/ResponseReceivedFromSMSProvider.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record ResponseReceivedFromSMSProviderEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider SMS reference. - public ResponseReceivedFromSMSProviderEvent(Guid aggregateId, - String providerSMSReference) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderSMSReference = providerSMSReference; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider SMS reference. - /// - /// - /// The provider SMS reference. - /// - public String ProviderSMSReference { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/SMSMessageDeliveredEvent.cs b/MessagingService.SMSMessage.DomainEvents/SMSMessageDeliveredEvent.cs deleted file mode 100644 index 08f5098..0000000 --- a/MessagingService.SMSMessage.DomainEvents/SMSMessageDeliveredEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SMSMessageDeliveredEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The delivered date time. - public SMSMessageDeliveredEvent(Guid aggregateId, - String providerStatus, - DateTime deliveredDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.DeliveredDateTime = deliveredDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the delivered date time. - /// - /// - /// The delivered date time. - /// - public DateTime DeliveredDateTime { get; init; } - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/SMSMessageExpiredEvent.cs b/MessagingService.SMSMessage.DomainEvents/SMSMessageExpiredEvent.cs deleted file mode 100644 index c59fd32..0000000 --- a/MessagingService.SMSMessage.DomainEvents/SMSMessageExpiredEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SMSMessageExpiredEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The expired date time. - public SMSMessageExpiredEvent(Guid aggregateId, - String providerStatus, - DateTime expiredDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.ExpiredDateTime = expiredDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the expired date time. - /// - /// - /// The expired date time. - /// - public DateTime ExpiredDateTime { get; init; } - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/SMSMessageRejectedEvent.cs b/MessagingService.SMSMessage.DomainEvents/SMSMessageRejectedEvent.cs deleted file mode 100644 index 53edb15..0000000 --- a/MessagingService.SMSMessage.DomainEvents/SMSMessageRejectedEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SMSMessageRejectedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The rejected date time. - public SMSMessageRejectedEvent(Guid aggregateId, - String providerStatus, - DateTime rejectedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.RejectedDateTime = rejectedDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - /// - /// Gets or sets the rejected date time. - /// - /// - /// The rejected date time. - /// - public DateTime RejectedDateTime { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.SMSMessage.DomainEvents/SMSMessageUndeliveredEvent.cs b/MessagingService.SMSMessage.DomainEvents/SMSMessageUndeliveredEvent.cs deleted file mode 100644 index f540ddb..0000000 --- a/MessagingService.SMSMessage.DomainEvents/SMSMessageUndeliveredEvent.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace MessagingService.SMSMessage.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SMSMessageUndeliveredEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The provider status. - /// The undelivered date time. - public SMSMessageUndeliveredEvent(Guid aggregateId, - String providerStatus, - DateTime undeliveredDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.MessageId = aggregateId; - this.ProviderStatus = providerStatus; - this.UndeliveredDateTime = undeliveredDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the message identifier. - /// - /// - /// The message identifier. - /// - public Guid MessageId { get; init; } - - /// - /// Gets or sets the provider status. - /// - /// - /// The provider status. - /// - public String ProviderStatus { get; init; } - - /// - /// Gets or sets the undelivered date time. - /// - /// - /// The undelivered date time. - /// - public DateTime UndeliveredDateTime { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/MessagingService.Testing/TestData.cs b/MessagingService.Testing/TestData.cs index 6e98f48..1f0ba2a 100644 --- a/MessagingService.Testing/TestData.cs +++ b/MessagingService.Testing/TestData.cs @@ -182,10 +182,27 @@ public class TestData new EmailServiceProxyResponse { EmailIdentifier = TestData.EmailIdentifier, - ApiStatusCode = TestData.ApiStatusCodeSuccess, + ApiCallSuccessful = true, RequestIdentifier = TestData.RequestIdentifier }; + public static EmailServiceProxyResponse FailedAPICallEmailServiceProxyResponse => + new EmailServiceProxyResponse + { + Error = "NotFound", + ErrorCode = "404", + ApiCallSuccessful = false, + }; + + public static EmailServiceProxyResponse FailedEmailServiceProxyResponse => + new EmailServiceProxyResponse + { + Error = "NotFound", + ErrorCode = "404", + ApiCallSuccessful = true, + }; + + public static List EmptyEmailAttachments => new List(); public static List EmailAttachments => new List @@ -221,6 +238,9 @@ public class TestData public static Models.FileType ModelFileTypePDF = Models.FileType.PDF; public static Models.FileType ModelFileTypeNone = Models.FileType.None; + public static String EmailErrorCode = "404"; + public static String EmailError = "NotFound"; + public static ResendEmailRequest ResendEmailRequest => ResendEmailRequest.Create(TestData.ConnectionIdentifier, TestData.MessageId); diff --git a/MessagingService/appsettings.json b/MessagingService/appsettings.json index 18b2810..9c40d48 100644 --- a/MessagingService/appsettings.json +++ b/MessagingService/appsettings.json @@ -22,7 +22,7 @@ "EmailProxy": "Smtp2Go", "SMSProxy": "TheSMSWorks", "SMTP2GoBaseAddress": "https://api.smtp2go.com/v3/", - "SMTP2GoAPIKey": "api-4CE2C6BC80D111EAB45BF23C91C88F4E", + "SMTP2GoAPIKey": "api-FC9777E0E53611E6A2F3F23C91BBF4A0", "TheSMSWorksBaseAddress": "https://api.thesmsworks.co.uk/v1/", "TheSMSWorksCustomerId": "5400-d666-5990-402f-aa48-a1fa9f45fd02", "TheSMSWorksKey": "55f1d327-f759-44aa-b535-208bd2c934c8",