refactor(GtxMessagingService): Optionen für generische und dynamische Antworttypen zur SendSmsAsync-Methode hinzugefügt.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
{
|
||||
public interface IMessagingService
|
||||
{
|
||||
public Task SendSmsAsync(string recipient, string message);
|
||||
public Task<dynamic?> SendSmsAsync(string recipient, string message);
|
||||
|
||||
public Task<TResponse?> SendSmsAsync<TResponse>(string recipient, string message);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.Abstractions.Client;
|
||||
using DigitalData.Core.Client;
|
||||
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -17,12 +18,14 @@ namespace EnvelopeGenerator.Application.Services
|
||||
_smsParams = smsParamsOptions.Value;
|
||||
}
|
||||
|
||||
public async Task SendSmsAsync(string recipient, string message)
|
||||
public Task<dynamic?> SendSmsAsync(string recipient, string message) => SendSmsAsync<dynamic>(recipient: recipient, message: message);
|
||||
|
||||
public async Task<TResponse?> SendSmsAsync<TResponse>(string recipient, string message)
|
||||
{
|
||||
await _smsClient.FetchAsync(queryParams: new Dictionary<string, object?>() {
|
||||
return await _smsClient.FetchAsync(queryParams: new Dictionary<string, object?>() {
|
||||
{ _smsParams.RecipientQueryParamName, recipient },
|
||||
{ _smsParams.MessageQueryParamName, message }
|
||||
});
|
||||
}).ThenAsync(res => res.Json<TResponse>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user