Updated namespaces to align with the new DigitalData.Core structure, replacing `DigitalData.Core.Abstractions` with `DigitalData.Core.Application.Interfaces` and `DigitalData.Core.Client.Interface`. Removed the `IUnique<int>` interface from several DTOs, simplifying their design and altering the handling of entity identification. Updated project files to reflect new dependency versions for improved compatibility and features. Cleaned up using directives to remove obsolete references, enhancing code maintainability.
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Client.Interface;
|
|
using DigitalData.Core.Client;
|
|
using EnvelopeGenerator.Application.Configurations;
|
|
using EnvelopeGenerator.Application.Contracts.Services;
|
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace EnvelopeGenerator.Application.Services;
|
|
|
|
//TODO: move to DigitalData.Core
|
|
public class GTXSmsSender : ISmsSender
|
|
{
|
|
private readonly IHttpClientService<GtxMessagingParams> _smsClient;
|
|
|
|
private readonly GtxMessagingParams _smsParams;
|
|
|
|
private readonly IMapper _mapper;
|
|
|
|
public string ServiceProvider { get; }
|
|
|
|
public GTXSmsSender(IHttpClientService<GtxMessagingParams> smsClient, IOptions<GtxMessagingParams> 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>);
|
|
}
|
|
} |