feat(GtxMessagingService): Empfänger- und Nachrichteneingaben zur SendSms-Methode über SMS-Parameter hinzugefügt

This commit is contained in:
Developer 02
2024-11-25 13:01:12 +01:00
parent ed80839777
commit 132acd35cc
2 changed files with 14 additions and 4 deletions

View File

@@ -7,7 +7,6 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging
/// </summary>
public class SmsParams : IHttpClientOptions
{
//TODO: Add a regex check to init methods to reduce the chance of errors.
public required string Uri { get; init; }
public string? Path { get; init; }
@@ -15,5 +14,9 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
public string RecipientQueryParamName { get; init; } = "from";
public string MessageQueryParamName { get; init; } = "text";
}
}

View File

@@ -1,5 +1,6 @@
using DigitalData.Core.Abstractions.Client;
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.Application.Services
{
@@ -7,14 +8,20 @@ namespace EnvelopeGenerator.Application.Services
{
private readonly IHttpClientService<SmsParams> _smsClient;
public GtxMessagingService(IHttpClientService<SmsParams> smsClient)
private readonly SmsParams _smsParams;
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions)
{
_smsClient = smsClient;
_smsParams = smsParamsOptions.Value;
}
public async Task SendSms()
public async Task SendSms(string recipient, string message)
{
await _smsClient.FetchAsync();
await _smsClient.FetchAsync(queryParams: new Dictionary<string, object?>() {
{ _smsParams.RecipientQueryParamName, recipient },
{ _smsParams.MessageQueryParamName, message }
});
}
}
}