using DigitalData.Core.Abstractions.Client; using DigitalData.Core.Client; using EnvelopeGenerator.Application.Configurations.GtxMessaging; using EnvelopeGenerator.Application.Contracts; using Microsoft.Extensions.Options; namespace EnvelopeGenerator.Application.Services { public class GtxMessagingService : IMessagingService { private readonly IHttpClientService _smsClient; private readonly SmsParams _smsParams; public GtxMessagingService(IHttpClientService smsClient, IOptions smsParamsOptions) { _smsClient = smsClient; _smsParams = smsParamsOptions.Value; } public Task SendSmsAsync(string recipient, string message) => SendSmsAsync(recipient: recipient, message: message); public async Task SendSmsAsync(string recipient, string message) { return await _smsClient.FetchAsync(queryParams: new Dictionary() { { _smsParams.RecipientQueryParamName, recipient }, { _smsParams.MessageQueryParamName, message } }).ThenAsync(res => res.Json()); } } }