diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Data.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Data.cs
index 0b72bdb..5fa3d75 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Data.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Data.cs
@@ -3,30 +3,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
+
///
///
///
[ExcludeFromCodeCoverage]
public class Data
{
- ///
- /// Gets or sets the count.
- ///
- ///
- /// The count.
- ///
- [JsonProperty("count")]
+
public Int32 Count { get; set; }
- ///
- /// Gets or sets the email details.
- ///
- ///
- /// The email details.
- ///
- [JsonProperty("emails")]
public List EmailDetails { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/EmailDetails.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/EmailDetails.cs
index c5a8f45..0ce1a2d 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/EmailDetails.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/EmailDetails.cs
@@ -2,66 +2,20 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
- ///
- ///
- ///
[ExcludeFromCodeCoverage]
public class EmailDetails
{
- ///
- /// Gets or sets the subject.
- ///
- ///
- /// The subject.
- ///
- [JsonProperty("subject")]
public String Subject { get; set; }
- ///
- /// Gets or sets the delivered at.
- ///
- ///
- /// The delivered at.
- ///
- [JsonProperty("delivered_at")]
public DateTime DeliveredAt { get; set; }
- ///
- /// Gets or sets the email status date.
- ///
- ///
- /// The email status date.
- ///
- [JsonProperty("email_ts")]
public DateTime EmailStatusDate { get; set; }
- ///
- /// Gets or sets the process status.
- ///
- ///
- /// The process status.
- ///
- [JsonProperty("process_status")]
public String ProcessStatus { get; set; }
- ///
- /// Gets or sets the email identifier.
- ///
- ///
- /// The email identifier.
- ///
- [JsonProperty("email_id")]
public String EmailId { get; set; }
- ///
- /// Gets or sets the status.
- ///
- ///
- /// The status.
- ///
- [JsonProperty("status")]
public String Status { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoAttachment.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoAttachment.cs
index 95ca1a5..9a6a7f7 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoAttachment.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoAttachment.cs
@@ -2,23 +2,14 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
-
+
[ExcludeFromCodeCoverage]
public class Smtp2GoAttachment
{
- #region Properties
-
- [JsonProperty("fileblob")]
public String FileBlob { get; set; }
- [JsonProperty("filename")]
public String FileName { get; set; }
- [JsonProperty("mimetype")]
public String MimeType { get; set; }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchRequest.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchRequest.cs
index c00d60d..31a01e6 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchRequest.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchRequest.cs
@@ -3,48 +3,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
- ///
- ///
- ///
+
[ExcludeFromCodeCoverage]
public class Smtp2GoEmailSearchRequest
{
- ///
- /// Gets or sets the email identifier.
- ///
- ///
- /// The email identifier.
- ///
- [JsonProperty("email_id")]
public List EmailId { get; set; }
- ///
- /// Gets or sets the API key.
- ///
- ///
- /// The API key.
- ///
- [JsonProperty("api_key")]
public String ApiKey { get; set; }
- ///
- /// Gets or sets the start date.
- ///
- ///
- /// The start date.
- ///
- [JsonProperty("start_date")]
public String StartDate { get; set; }
- ///
- /// Gets or sets the end date.
- ///
- ///
- /// The end date.
- ///
- [JsonProperty("end_date")]
public String EndDate { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchResponse.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchResponse.cs
index 81763a7..0019271 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchResponse.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoEmailSearchResponse.cs
@@ -2,34 +2,12 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
- ///
- ///
- ///
+
[ExcludeFromCodeCoverage]
public class Smtp2GoEmailSearchResponse
{
- #region Properties
-
- ///
- /// Gets or sets the data.
- ///
- ///
- /// The data.
- ///
- [JsonProperty("data")]
public Data Data { get; set; }
- ///
- /// Gets or sets the request identifier.
- ///
- ///
- /// The request identifier.
- ///
- [JsonProperty("request_id")]
public String RequestId { get; set; }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
index 3048ef0..4811d63 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
@@ -1,16 +1,15 @@
-namespace MessagingService.BusinessLogic.Services.EmailServices.Smtp2Go
+using Shared.Serialisation;
+
+namespace MessagingService.BusinessLogic.Services.EmailServices.Smtp2Go
{
using Models;
- using Newtonsoft.Json;
using Service.Services.Email.Smtp2Go;
- using Shared.General;
using Shared.Logger;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
- using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -73,7 +72,7 @@ public async Task SendEmail(Guid messageId,
attachments.ForEach(a => apiRequest.Attachments.Add(new Smtp2GoAttachment { FileBlob = a.FileData, FileName = a.Filename, MimeType = this.ConvertFileType(a.FileType) }));
}
- String requestSerialised = JsonConvert.SerializeObject(apiRequest, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None });
+ String requestSerialised = StringSerialiser.Serialise(apiRequest, new SerialiserOptions(SerialiserPropertyFormat.SnakeCase, WriteIndented:true));
Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}");
@@ -86,12 +85,11 @@ public async Task SendEmail(Guid messageId,
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Smtp2GoSendEmailResponse apiResponse = httpResponse.IsSuccessStatusCode switch {
- true => JsonConvert.DeserializeObject(await httpResponse.Content.ReadAsStringAsync(cancellationToken)),
+ true => StringSerialiser.Deserialise(await httpResponse.Content.ReadAsStringAsync(cancellationToken)),
_ => new Smtp2GoSendEmailResponse { Data = new Smtp2GoSendEmailResponseData { Error = httpResponse.StatusCode.ToString(), ErrorCode = ((Int32)httpResponse.StatusCode).ToString() } }
};
- Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {JsonConvert.SerializeObject(apiResponse)}");
-
+ Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {StringSerialiser.Serialise(apiResponse)}");
// Translate the Response
return new EmailServiceProxyResponse {
ApiCallSuccessful = httpResponse.IsSuccessStatusCode && String.IsNullOrEmpty(apiResponse.Data.ErrorCode),
@@ -119,7 +117,7 @@ public async Task GetMessageStatus(String providerReferen
ApiKey = Configuration.APIKey, EmailId = new List { providerReference }, StartDate = startDate.ToString("yyyy-MM-dd"), EndDate = endDate.ToString("yyyy-MM-dd"),
};
- String requestSerialised = JsonConvert.SerializeObject(apiRequest, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None });
+ String requestSerialised = StringSerialiser.Serialise(apiRequest, new SerialiserOptions(SerialiserPropertyFormat.SnakeCase, WriteIndented: true));
Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}");
@@ -131,9 +129,9 @@ public async Task GetMessageStatus(String providerReferen
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
- Smtp2GoEmailSearchResponse apiResponse = JsonConvert.DeserializeObject(await httpResponse.Content.ReadAsStringAsync(cancellationToken));
+ Smtp2GoEmailSearchResponse apiResponse = StringSerialiser.Deserialise(await httpResponse.Content.ReadAsStringAsync(cancellationToken));
- Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {JsonConvert.SerializeObject(apiResponse)}");
+ Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {StringSerialiser.Serialise(apiResponse)}");
// Translate the Response
return new MessageStatusResponse { ApiStatusCode = httpResponse.StatusCode, MessageStatus = this.TranslateMessageStatus(apiResponse.Data.EmailDetails.Single().Status), ProviderStatusDescription = apiResponse.Data.EmailDetails.Single().Status, Timestamp = apiResponse.Data.EmailDetails.Single().EmailStatusDate };
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailRequest.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailRequest.cs
index 0687ede..f4e4e35 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailRequest.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailRequest.cs
@@ -1,5 +1,4 @@
using System;
-using Newtonsoft.Json;
namespace MessagingService.Service.Services.Email.Smtp2Go
{
@@ -9,95 +8,24 @@ namespace MessagingService.Service.Services.Email.Smtp2Go
[ExcludeFromCodeCoverage]
public class Smtp2GoSendEmailRequest
{
- ///
- /// Gets or sets the API key.
- ///
- ///
- /// The API key.
- ///
- [JsonProperty("api_key")]
public String ApiKey { get; set; }
- ///
- /// Gets or sets a value indicating whether [test mode].
- ///
- ///
- /// true if [test mode]; otherwise, false.
- ///
- [JsonProperty("test")]
public Boolean TestMode { get; set; }
- ///
- /// Gets or sets the sender.
- ///
- ///
- /// The sender.
- ///
- [JsonProperty("sender")]
public String Sender { get; set; }
- ///
- /// Gets or sets to.
- ///
- ///
- /// To.
- ///
- [JsonProperty("to")]
public String[] To { get; set; }
- ///
- /// Gets or sets the cc.
- ///
- ///
- /// The cc.
- ///
- [JsonProperty("cc")]
public String[] CC { get; set; }
- ///
- /// Gets or sets the BCC.
- ///
- ///
- /// The BCC.
- ///
- [JsonProperty("bcc")]
public String[] BCC { get; set; }
- ///
- /// Gets or sets the subject.
- ///
- ///
- /// The subject.
- ///
- [JsonProperty("subject")]
public String Subject { get; set; }
- ///
- /// Gets or sets the HTML body.
- ///
- ///
- /// The HTML body.
- ///
- [JsonProperty("html_body")]
public String HTMLBody { get; set; }
- ///
- /// Gets or sets the text body.
- ///
- ///
- /// The text body.
- ///
- [JsonProperty("text_body")]
public String TextBody { get; set; }
- ///
- /// Gets or sets the attachments.
- ///
- ///
- /// The attachments.
- ///
- [JsonProperty("attachments")]
public List Attachments { get; set; }
-
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponse.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponse.cs
index e54fa5d..80a5d8f 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponse.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponse.cs
@@ -1,5 +1,4 @@
using System;
-using Newtonsoft.Json;
namespace MessagingService.Service.Services.Email.Smtp2Go
{
@@ -8,22 +7,8 @@ namespace MessagingService.Service.Services.Email.Smtp2Go
[ExcludeFromCodeCoverage]
public class Smtp2GoSendEmailResponse
{
- ///
- /// Gets or sets the request identifier.
- ///
- ///
- /// The request identifier.
- ///
- [JsonProperty("request_id")]
public String RequestId { get; set; }
- ///
- /// Gets or sets the data.
- ///
- ///
- /// The data.
- ///
- [JsonProperty("data")]
public Smtp2GoSendEmailResponseData Data { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponseData.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponseData.cs
index 90b0c51..d577a81 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponseData.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoSendEmailResponseData.cs
@@ -1,5 +1,4 @@
using System;
-using Newtonsoft.Json;
namespace MessagingService.Service.Services.Email.Smtp2Go
{
@@ -8,58 +7,16 @@ namespace MessagingService.Service.Services.Email.Smtp2Go
[ExcludeFromCodeCoverage]
public class Smtp2GoSendEmailResponseData
{
- ///
- /// Gets or sets the failed.
- ///
- ///
- /// The failed.
- ///
- [JsonProperty("failed")]
public Int32 Failed { get; set; }
- ///
- /// Gets or sets the failures.
- ///
- ///
- /// The failures.
- ///
- [JsonProperty("failures")]
public String[] Failures { get; set; }
- ///
- /// Gets or sets the email identifier.
- ///
- ///
- /// The email identifier.
- ///
- [JsonProperty("email_id")]
public String EmailId { get; set; }
- ///
- /// Gets or sets the succeesful.
- ///
- ///
- /// The succeesful.
- ///
- [JsonProperty("succeeded")]
public Int32 Succeesful { get; set; }
- ///
- /// Gets or sets the error.
- ///
- ///
- /// The error.
- ///
- [JsonProperty("error")]
public String Error { get; set; }
- ///
- /// Gets or sets the error code.
- ///
- ///
- /// The error code.
- ///
- [JsonProperty("error_code")]
public String ErrorCode { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksFailureReason.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksFailureReason.cs
index 8d3e7a9..c0375c4 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksFailureReason.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksFailureReason.cs
@@ -2,39 +2,14 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
- ///
- ///
- ///
+
[ExcludeFromCodeCoverage]
public class TheSMSWorksFailureReason
{
- ///
- /// Gets or sets the code.
- ///
- ///
- /// The code.
- ///
- [JsonProperty("code")]
public Int32 Code { get; set; }
- ///
- /// Gets or sets the details.
- ///
- ///
- /// The details.
- ///
- [JsonProperty("details")]
public String Details { get; set; }
- ///
- /// Gets or sets a value indicating whether this is permanent.
- ///
- ///
- /// true if permanent; otherwise, false.
- ///
- [JsonProperty("permanent")]
public Boolean Permanent { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksGetMessageResponse.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksGetMessageResponse.cs
index 87e340f..05ce890 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksGetMessageResponse.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSMSWorksGetMessageResponse.cs
@@ -2,156 +2,39 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
- ///
- ///
- ///
[ExcludeFromCodeCoverage]
public class TheSMSWorksGetMessageResponse
{
- ///
- /// Gets or sets the batch identifier.
- ///
- ///
- /// The batch identifier.
- ///
- [JsonProperty("batchid")]
public String BatchId { get; set; }
- ///
- /// Gets or sets the content.
- ///
- ///
- /// The content.
- ///
- [JsonProperty("content")]
public String Content { get; set; }
- ///
- /// Gets or sets the created.
- ///
- ///
- /// The created.
- ///
- [JsonProperty("created")]
public String Created { get; set; }
- ///
- /// Gets or sets the customerid.
- ///
- ///
- /// The customerid.
- ///
- [JsonProperty("customerid")]
public String Customerid { get; set; }
- ///
- /// Gets or sets the deliveryreporturl.
- ///
- ///
- /// The deliveryreporturl.
- ///
- [JsonProperty("deliveryreporturl")]
public String Deliveryreporturl { get; set; }
- ///
- /// Gets or sets the destination.
- ///
- ///
- /// The destination.
- ///
- [JsonProperty("destination")]
public String Destination { get; set; }
- ///
- /// Gets or sets the failurereason.
- ///
- ///
- /// The failurereason.
- ///
- [JsonProperty("failurereason")]
public TheSMSWorksFailureReason Failurereason { get; set; }
- ///
- /// Gets or sets the identifier.
- ///
- ///
- /// The identifier.
- ///
- [JsonProperty("id")]
public String Id { get; set; }
- ///
- /// Gets or sets the identifier.
- ///
- ///
- /// The identifier.
- ///
- [JsonProperty("identifier")]
public String Identifier { get; set; }
- ///
- /// Gets or sets the keyword.
- ///
- ///
- /// The keyword.
- ///
- [JsonProperty("keyword")]
public String Keyword { get; set; }
- ///
- /// Gets or sets the messageid.
- ///
- ///
- /// The messageid.
- ///
- [JsonProperty("messageid")]
public String Messageid { get; set; }
- ///
- /// Gets or sets the modified.
- ///
- ///
- /// The modified.
- ///
- [JsonProperty("modified")]
public String Modified { get; set; }
- ///
- /// Gets or sets the schedule.
- ///
- ///
- /// The schedule.
- ///
- [JsonProperty("schedule")]
public String Schedule { get; set; }
- ///
- /// Gets or sets the status.
- ///
- ///
- /// The status.
- ///
- [JsonProperty("status")]
public String Status { get; set; }
-
- ///
- /// Gets or sets the sender.
- ///
- ///
- /// The sender.
- ///
- [JsonProperty("sender")]
public String Sender { get; set; }
- ///
- /// Gets or sets the tag.
- ///
- ///
- /// The tag.
- ///
- [JsonProperty("tag")]
public String Tag { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModel.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModel.cs
index 346ff45..cb3768d 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModel.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModel.cs
@@ -2,27 +2,12 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
[ExcludeFromCodeCoverage]
public class TheSmsWorksExtendedErrorModel
{
- ///
- /// Gets or sets the message.
- ///
- ///
- /// The message.
- ///
- [JsonProperty("message")]
public String Message { get; set; }
- ///
- /// Gets or sets the errors.
- ///
- ///
- /// The errors.
- ///
- [JsonProperty("errors")]
public TheSmsWorksExtendedErrorModelError[] Errors { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelError.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelError.cs
index dc52657..b65f59d 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelError.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelError.cs
@@ -2,63 +2,20 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
[ExcludeFromCodeCoverage]
public class TheSmsWorksExtendedErrorModelError
{
- ///
- /// Gets or sets the code.
- ///
- ///
- /// The code.
- ///
- [JsonProperty("code")]
public String Code { get; set; }
- ///
- /// Gets or sets the field errors.
- ///
- ///
- /// The field errors.
- ///
- [JsonProperty("errors")]
public TheSmsWorksExtendedErrorModelFieldError[] FieldErrors { get; set; }
- ///
- /// Gets or sets the in.
- ///
- ///
- /// The in.
- ///
- [JsonProperty("in")]
public String In { get; set; }
- ///
- /// Gets or sets the message.
- ///
- ///
- /// The message.
- ///
- [JsonProperty("message")]
public String Message { get; set; }
- ///
- /// Gets or sets the name.
- ///
- ///
- /// The name.
- ///
- [JsonProperty("name")]
public String Name { get; set; }
- ///
- /// Gets or sets the path.
- ///
- ///
- /// The path.
- ///
- [JsonProperty("path")]
public String[] Path { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelFieldError.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelFieldError.cs
index 1ea2eb5..a9e675e 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelFieldError.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksExtendedErrorModelFieldError.cs
@@ -2,48 +2,18 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
+
[ExcludeFromCodeCoverage]
public class TheSmsWorksExtendedErrorModelFieldError
{
- [JsonProperty("code")]
public String Code { get; set; }
- ///
- /// Gets or sets the parameters.
- ///
- ///
- /// The parameters.
- ///
- [JsonProperty("params")]
public String[] Params { get; set; }
- ///
- /// Gets or sets the message.
- ///
- ///
- /// The message.
- ///
- [JsonProperty("message")]
public String Message { get; set; }
- ///
- /// Gets or sets the path.
- ///
- ///
- /// The path.
- ///
- [JsonProperty("path")]
public String[] Path { get; set; }
- ///
- /// Gets or sets the description.
- ///
- ///
- /// The description.
- ///
- [JsonProperty("description")]
public String Description { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
index be2dbe8..e2b379b 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
@@ -1,7 +1,7 @@
using System;
-using System.Collections.Generic;
using System.Security.Authentication;
using System.Text;
+using Shared.Serialisation;
namespace MessagingService.BusinessLogic.Services.SMSServices.TheSMSWorks
{
@@ -10,11 +10,8 @@ namespace MessagingService.BusinessLogic.Services.SMSServices.TheSMSWorks
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
- using Newtonsoft.Json;
- using Requests;
using Shared.Exceptions;
using Shared.Extensions;
- using Shared.General;
public record SmsWorksConfig {
public String BaseAddress { get; set; }
@@ -53,14 +50,14 @@ public async Task SendSMS(Guid messageId,
// Create the Auth Request
TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = Configuration.CustomerId, Key = Configuration.Key, Secret = Configuration.Secret };
- String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
+ String apiTokenRequestSerialised = StringSerialiser.Serialise(apiTokenRequest).ToLower();
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
// First do the authentication
HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{Configuration.BaseAddress}auth/token", content, cancellationToken);
if (apiTokenHttpResponse.IsSuccessStatusCode) {
- TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync(cancellationToken));
+ TheSmsWorksTokenResponse apiTokenResponse = StringSerialiser.Deserialise(await apiTokenHttpResponse.Content.ReadAsStringAsync(cancellationToken));
// Now do the actual send
TheSmsWorksSendSMSRequest apiSendSmsRequest = new() {
@@ -72,7 +69,7 @@ public async Task SendSMS(Guid messageId,
Ttl = 0
};
- String apiSendSMSMessageRequestSerialised = JsonConvert.SerializeObject(apiSendSmsRequest).ToLower();
+ String apiSendSMSMessageRequestSerialised = StringSerialiser.Serialise(apiSendSmsRequest).ToLower();
content = new StringContent(apiSendSMSMessageRequestSerialised, Encoding.UTF8, "application/json");
this.HttpClient.DefaultRequestHeaders.Add("Authorization", apiTokenResponse.Token);
@@ -80,7 +77,7 @@ public async Task SendSMS(Guid messageId,
if (apiSendSMSMessageHttpResponse.IsSuccessStatusCode) {
// Message has been sent
- TheSmsWorksSendSMSResponse apiTheSmsWorksSendSmsResponse = JsonConvert.DeserializeObject(await apiSendSMSMessageHttpResponse.Content.ReadAsStringAsync(cancellationToken));
+ TheSmsWorksSendSMSResponse apiTheSmsWorksSendSmsResponse = StringSerialiser.Deserialise(await apiSendSMSMessageHttpResponse.Content.ReadAsStringAsync(cancellationToken));
response = new SMSServiceProxyResponse { ApiCallSuccessful = true, SMSIdentifier = apiTheSmsWorksSendSmsResponse.MessageId, };
}
@@ -102,21 +99,21 @@ public async Task GetMessageStatus(String providerReferen
// Create the Auth Request
TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = Configuration.CustomerId, Key = Configuration.Key, Secret = Configuration.Secret };
- String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
+ String apiTokenRequestSerialised = StringSerialiser.Serialise(apiTokenRequest).ToLower();
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
// First do the authentication
HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{Configuration.BaseAddress}auth/token", content, cancellationToken);
if (apiTokenHttpResponse.IsSuccessStatusCode) {
- TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync(cancellationToken));
+ TheSmsWorksTokenResponse apiTokenResponse = StringSerialiser.Deserialise(await apiTokenHttpResponse.Content.ReadAsStringAsync(cancellationToken));
this.HttpClient.DefaultRequestHeaders.Add("Authorization", apiTokenResponse.Token);
HttpResponseMessage apiGetSMSMessageHttpResponse = await this.HttpClient.GetAsync($"{Configuration.BaseAddress}messages/{providerReference}", cancellationToken);
if (apiGetSMSMessageHttpResponse.IsSuccessStatusCode) {
// Message has been sent
- TheSMSWorksGetMessageResponse apiSmsWorksGetMessageResponse = JsonConvert.DeserializeObject(await apiGetSMSMessageHttpResponse.Content.ReadAsStringAsync(cancellationToken));
+ TheSMSWorksGetMessageResponse apiSmsWorksGetMessageResponse = StringSerialiser.Deserialise(await apiGetSMSMessageHttpResponse.Content.ReadAsStringAsync(cancellationToken));
response = new MessageStatusResponse { ApiStatusCode = apiGetSMSMessageHttpResponse.StatusCode, MessageStatus = this.TranslateMessageStatus(apiSmsWorksGetMessageResponse.Status), ProviderStatusDescription = apiSmsWorksGetMessageResponse.Status, Timestamp = DateTime.Parse(apiSmsWorksGetMessageResponse.Modified) };
}
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSRequest.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSRequest.cs
index 5064558..a1895f0 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSRequest.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSRequest.cs
@@ -2,63 +2,20 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
[ExcludeFromCodeCoverage]
public class TheSmsWorksSendSMSRequest
{
- ///
- /// Gets or sets the sender.
- ///
- ///
- /// The sender.
- ///
- [JsonProperty("sender")]
public String Sender { get; set; }
- ///
- /// Gets or sets the destination.
- ///
- ///
- /// The destination.
- ///
- [JsonProperty("destination")]
public String Destination { get; set; }
- ///
- /// Gets or sets the content.
- ///
- ///
- /// The content.
- ///
- [JsonProperty("content")]
public String Content { get; set; }
- ///
- /// Gets or sets the schedule.
- ///
- ///
- /// The schedule.
- ///
- [JsonProperty("schedule")]
public String Schedule { get; set; }
- ///
- /// Gets or sets the tag.
- ///
- ///
- /// The tag.
- ///
- [JsonProperty("tag")]
public String Tag { get; set; }
- ///
- /// Gets or sets the TTL.
- ///
- ///
- /// The TTL.
- ///
- [JsonProperty("ttl")]
public Int32 Ttl { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSResponse.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSResponse.cs
index 81d1ea6..7d67882 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSResponse.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksSendSMSResponse.cs
@@ -2,36 +2,14 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
+
[ExcludeFromCodeCoverage]
public class TheSmsWorksSendSMSResponse
{
- ///
- /// Gets or sets the message identifier.
- ///
- ///
- /// The message identifier.
- ///
- [JsonProperty("messageid")]
public String MessageId { get; set; }
- ///
- /// Gets or sets the status.
- ///
- ///
- /// The status.
- ///
- [JsonProperty("status")]
public String Status { get; set; }
- ///
- /// Gets or sets the credits.
- ///
- ///
- /// The credits.
- ///
- [JsonProperty("credits")]
public Int32 Credits { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksTokenRequest.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksTokenRequest.cs
index 28ac393..52fb94e 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksTokenRequest.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksTokenRequest.cs
@@ -2,36 +2,14 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Newtonsoft.Json;
-
+
[ExcludeFromCodeCoverage]
public class TheSmsWorksTokenRequest
{
- ///
- /// Gets or sets the customer identifier.
- ///
- ///
- /// The customer identifier.
- ///
- [JsonProperty("customerid")]
public String CustomerId { get; set; }
- ///
- /// Gets or sets the key.
- ///
- ///
- /// The key.
- ///
- [JsonProperty("key")]
public String Key { get; set; }
- ///
- /// Gets or sets the secret.
- ///
- ///
- /// The secret.
- ///
- [JsonProperty("secret")]
public String Secret { get; set; }
}
}
\ No newline at end of file
diff --git a/MessagingService.Client/MessagingService.Client.csproj b/MessagingService.Client/MessagingService.Client.csproj
index ba49f2d..c5ab6c1 100644
--- a/MessagingService.Client/MessagingService.Client.csproj
+++ b/MessagingService.Client/MessagingService.Client.csproj
@@ -6,9 +6,8 @@
-
-
-
+
+
diff --git a/MessagingService.Client/MessagingServiceClient.cs b/MessagingService.Client/MessagingServiceClient.cs
index 62c29f0..16b469a 100644
--- a/MessagingService.Client/MessagingServiceClient.cs
+++ b/MessagingService.Client/MessagingServiceClient.cs
@@ -4,13 +4,10 @@ namespace MessagingService.Client
{
using System;
using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ClientProxyBase;
using DataTransferObjects;
- using Newtonsoft.Json;
using SimpleResults;
public class MessagingServiceClient : ClientProxyBase, IMessagingServiceClient
@@ -26,7 +23,9 @@ public class MessagingServiceClient : ClientProxyBase, IMessagingServiceClient
#region Constructors
public MessagingServiceClient(Func baseAddressResolver,
- HttpClient httpClient) : base(httpClient)
+ HttpClient httpClient,
+ Func