diff --git a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
index c1badba..f54b2f9 100644
--- a/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
+++ b/MessagingService.BusinessLogic/Services/SMSServices/TheSMSWorks/TheSmsWorksProxy.cs
@@ -25,6 +25,11 @@ public TheSmsWorksProxy(HttpClient httpClient) {
this.HttpClient = httpClient;
}
+ private const String TheSMSWorksBaseAddressKey = "TheSMSWorksBaseAddress";
+ private const String TheSMSWorksCustomerIdKey = "TheSMSWorksCustomerId";
+ private const String TheSMSWorksKeyKey = "TheSMSWorksKey";
+ private const String TheSMSWorksSecretKey = "TheSMSWorksSecret";
+
///
/// Sends the SMS.
///
@@ -42,13 +47,14 @@ public async Task SendSMS(Guid messageId,
SMSServiceProxyResponse response = null;
// Create the Auth Request
- TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
+ TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue(TheSMSWorksCustomerIdKey),
+ Key = ConfigurationReader.GetValue(TheSMSWorksKeyKey), Secret = ConfigurationReader.GetValue(TheSMSWorksSecretKey) };
String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
// First do the authentication
- HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken);
+ HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue(TheSMSWorksBaseAddressKey)}auth/token", content, cancellationToken);
if (apiTokenHttpResponse.IsSuccessStatusCode) {
TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync());
@@ -67,7 +73,7 @@ public async Task SendSMS(Guid messageId,
content = new StringContent(apiSendSMSMessageRequestSerialised, Encoding.UTF8, "application/json");
this.HttpClient.DefaultRequestHeaders.Add("Authorization", apiTokenResponse.Token);
- HttpResponseMessage apiSendSMSMessageHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}message/send", content, cancellationToken);
+ HttpResponseMessage apiSendSMSMessageHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue(TheSMSWorksBaseAddressKey)}message/send", content, cancellationToken);
if (apiSendSMSMessageHttpResponse.IsSuccessStatusCode) {
// Message has been sent
@@ -91,19 +97,22 @@ public async Task GetMessageStatus(String providerReferen
MessageStatusResponse response = new();
// Create the Auth Request
- TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue("TheSMSWorksCustomerId"), Key = ConfigurationReader.GetValue("TheSMSWorksKey"), Secret = ConfigurationReader.GetValue("TheSMSWorksSecret") };
+ TheSmsWorksTokenRequest apiTokenRequest = new() { CustomerId = ConfigurationReader.GetValue(TheSMSWorksCustomerIdKey),
+ Key = ConfigurationReader.GetValue(TheSMSWorksKeyKey),
+ Secret = ConfigurationReader.GetValue(TheSMSWorksSecretKey)
+ };
String apiTokenRequestSerialised = JsonConvert.SerializeObject(apiTokenRequest).ToLower();
StringContent content = new(apiTokenRequestSerialised, Encoding.UTF8, "application/json");
// First do the authentication
- HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}auth/token", content, cancellationToken);
+ HttpResponseMessage apiTokenHttpResponse = await this.HttpClient.PostAsync($"{ConfigurationReader.GetValue(TheSMSWorksBaseAddressKey)}auth/token", content, cancellationToken);
if (apiTokenHttpResponse.IsSuccessStatusCode) {
- TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync());
+ TheSmsWorksTokenResponse apiTokenResponse = JsonConvert.DeserializeObject(await apiTokenHttpResponse.Content.ReadAsStringAsync(cancellationToken));
this.HttpClient.DefaultRequestHeaders.Add("Authorization", apiTokenResponse.Token);
- HttpResponseMessage apiGetSMSMessageHttpResponse = await this.HttpClient.GetAsync($"{ConfigurationReader.GetValue("TheSMSWorksBaseAddress")}messages/{providerReference}", cancellationToken);
+ HttpResponseMessage apiGetSMSMessageHttpResponse = await this.HttpClient.GetAsync($"{ConfigurationReader.GetValue(TheSMSWorksBaseAddressKey)}messages/{providerReference}", cancellationToken);
if (apiGetSMSMessageHttpResponse.IsSuccessStatusCode) {
// Message has been sent
diff --git a/MessagingService/Common/Extensions.cs b/MessagingService/Common/Extensions.cs
index 2e78479..ce9bd93 100644
--- a/MessagingService/Common/Extensions.cs
+++ b/MessagingService/Common/Extensions.cs
@@ -41,6 +41,9 @@ public static class Extensions
case TraceEventType.Verbose:
Logger.LogDebug(logMessage);
break;
+ default:
+ Logger.LogInformation(logMessage);
+ break;
}
};
@@ -62,7 +65,7 @@ public static void PreWarm(this IApplicationBuilder applicationBuilder)
String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString");
- EventStoreClientSettings eventStoreConnectionSettings = EventStoreClientSettings.Create(connectionString);
+
applicationBuilder.ConfigureSubscriptionService(subscriptionWorkersRoot,
connectionString,
eventHandlerResolvers,
diff --git a/MessagingService/Controllers/EmailController.cs b/MessagingService/Controllers/EmailController.cs
index 795bb4e..e129a42 100644
--- a/MessagingService/Controllers/EmailController.cs
+++ b/MessagingService/Controllers/EmailController.cs
@@ -55,7 +55,7 @@ public EmailController(IMediator mediator)
#endregion
#region Methods
-
+
///
/// Sends the email.
///
@@ -105,6 +105,7 @@ public async Task SendEmail([FromBody] SendEmailRequestDTO sendEm
return result.ToActionResultX();
}
+ [ValidateAntiForgeryToken]
[HttpPost]
[Route("resend")]
[SwaggerResponse(202, "Accepted", typeof(SendEmailResponseDTO))]
diff --git a/MessagingService/Controllers/SMSController.cs b/MessagingService/Controllers/SMSController.cs
index 15115fd..5b89539 100644
--- a/MessagingService/Controllers/SMSController.cs
+++ b/MessagingService/Controllers/SMSController.cs
@@ -48,7 +48,7 @@ public SMSController(IMediator mediator)
#endregion
#region Methods
-
+
///
/// Sends the SMS.
///
@@ -83,6 +83,7 @@ public async Task SendSMS([FromBody] SendSMSRequest sendSMSReques
return result.ToActionResultX();
}
+ [ValidateAntiForgeryToken]
[HttpPost]
[Route("resend")]
[SwaggerResponse(202, "Accepted", typeof(SendSMSResponse))]