feat(GtxMessagingService): Empfänger- und Nachrichteneingaben zur SendSms-Methode über SMS-Parameter hinzugefügt
This commit is contained in:
@@ -7,7 +7,6 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SmsParams : IHttpClientOptions
|
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 required string Uri { get; init; }
|
||||||
|
|
||||||
public string? Path { 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>>? Headers { get; init; }
|
||||||
|
|
||||||
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
|
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
|
||||||
|
|
||||||
|
public string RecipientQueryParamName { get; init; } = "from";
|
||||||
|
|
||||||
|
public string MessageQueryParamName { get; init; } = "text";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using DigitalData.Core.Abstractions.Client;
|
using DigitalData.Core.Abstractions.Client;
|
||||||
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services
|
||||||
{
|
{
|
||||||
@@ -7,14 +8,20 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
{
|
{
|
||||||
private readonly IHttpClientService<SmsParams> _smsClient;
|
private readonly IHttpClientService<SmsParams> _smsClient;
|
||||||
|
|
||||||
public GtxMessagingService(IHttpClientService<SmsParams> smsClient)
|
private readonly SmsParams _smsParams;
|
||||||
|
|
||||||
|
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions)
|
||||||
{
|
{
|
||||||
_smsClient = smsClient;
|
_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 }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user