- Unnötige Parameter in SmsParams entfernt. - Code-Sendefunktion von IMessagingService entfernt. - GetTotpExpirationTime Methode im CodeGenerator entfernt.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Abstractions.Client;
|
|
using DigitalData.Core.Client;
|
|
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
|
using EnvelopeGenerator.Application.Contracts;
|
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace EnvelopeGenerator.Application.Services;
|
|
|
|
public class GtxMessagingService : IMessagingService
|
|
{
|
|
private readonly IHttpClientService<SmsParams> _smsClient;
|
|
|
|
private readonly SmsParams _smsParams;
|
|
|
|
private readonly IMapper _mapper;
|
|
|
|
public string ServiceProvider { get; }
|
|
|
|
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper)
|
|
{
|
|
_smsClient = smsClient;
|
|
_smsParams = smsParamsOptions.Value;
|
|
_mapper = mapper;
|
|
ServiceProvider = GetType().Name.Replace("Service", string.Empty);
|
|
}
|
|
|
|
public async Task<SmsResponse> SendSmsAsync(string recipient, string message)
|
|
{
|
|
return await _smsClient.FetchAsync(queryParams: new Dictionary<string, object?>()
|
|
{
|
|
{ _smsParams.RecipientQueryParamName, recipient },
|
|
{ _smsParams.MessageQueryParamName, message }
|
|
})
|
|
.ThenAsync(res => res.Json<GtxMessagingResponse>())
|
|
.ThenAsync(_mapper.Map<SmsResponse>);
|
|
}
|
|
} |