From 132acd35cc3d476ed8a1e18e9dc528dac5998ae7 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 25 Nov 2024 13:01:12 +0100 Subject: [PATCH] =?UTF-8?q?feat(GtxMessagingService):=20Empf=C3=A4nger-=20?= =?UTF-8?q?und=20Nachrichteneingaben=20zur=20SendSms-Methode=20=C3=BCber?= =?UTF-8?q?=20SMS-Parameter=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Configurations/GtxMessaging/SmsParams.cs | 5 ++++- .../Services/GTXMessagingService.cs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/EnvelopeGenerator.Application/Configurations/GtxMessaging/SmsParams.cs b/EnvelopeGenerator.Application/Configurations/GtxMessaging/SmsParams.cs index ca7a34d5..a2faf739 100644 --- a/EnvelopeGenerator.Application/Configurations/GtxMessaging/SmsParams.cs +++ b/EnvelopeGenerator.Application/Configurations/GtxMessaging/SmsParams.cs @@ -7,7 +7,6 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging /// 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>? Headers { get; init; } public IEnumerable>? QueryParams { get; init; } + + public string RecipientQueryParamName { get; init; } = "from"; + + public string MessageQueryParamName { get; init; } = "text"; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/GTXMessagingService.cs b/EnvelopeGenerator.Application/Services/GTXMessagingService.cs index 7044140f..81a03545 100644 --- a/EnvelopeGenerator.Application/Services/GTXMessagingService.cs +++ b/EnvelopeGenerator.Application/Services/GTXMessagingService.cs @@ -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 _smsClient; - public GtxMessagingService(IHttpClientService smsClient) + private readonly SmsParams _smsParams; + + public GtxMessagingService(IHttpClientService smsClient, IOptions 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() { + { _smsParams.RecipientQueryParamName, recipient }, + { _smsParams.MessageQueryParamName, message } + }); } } } \ No newline at end of file