refactor(GtxMessagingService): Optionen für generische und dynamische Antworttypen zur SendSmsAsync-Methode hinzugefügt.

This commit is contained in:
Developer 02
2024-11-25 14:13:34 +01:00
parent d3104500d4
commit da06daf776
2 changed files with 9 additions and 4 deletions

View File

@@ -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>());
}
}
}