feat(GtxMessagingService): SendSmsCodeAsync mit Basisfunktionalität als Schnittstellenimplementierung hinzugefügt
This commit is contained in:
@@ -4,8 +4,10 @@ namespace EnvelopeGenerator.Application.Contracts
|
|||||||
{
|
{
|
||||||
public interface IMessagingService
|
public interface IMessagingService
|
||||||
{
|
{
|
||||||
public Task<SmsResponse> SendSmsAsync(string recipient, string message);
|
|
||||||
|
|
||||||
string ServiceProvider { get; }
|
string ServiceProvider { get; }
|
||||||
|
|
||||||
|
Task<SmsResponse> SendSmsAsync(string recipient, string message);
|
||||||
|
|
||||||
|
Task<SmsResponse> SendSmsCodeAsync(string recipient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,12 +17,17 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
|
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper)
|
private readonly ICodeGenerator _codeGen;
|
||||||
|
|
||||||
|
public string ServiceProvider { get; }
|
||||||
|
|
||||||
|
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper, ICodeGenerator codeGenerator)
|
||||||
{
|
{
|
||||||
_smsClient = smsClient;
|
_smsClient = smsClient;
|
||||||
_smsParams = smsParamsOptions.Value;
|
_smsParams = smsParamsOptions.Value;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
ServiceProvider = GetType().Name.Replace("Service", string.Empty);
|
ServiceProvider = GetType().Name.Replace("Service", string.Empty);
|
||||||
|
_codeGen = codeGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SmsResponse> SendSmsAsync(string recipient, string message)
|
public async Task<SmsResponse> SendSmsAsync(string recipient, string message)
|
||||||
@@ -36,6 +41,10 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
.ThenAsync(_mapper.Map<SmsResponse>);
|
.ThenAsync(_mapper.Map<SmsResponse>);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ServiceProvider { get; }
|
public async Task<SmsResponse> SendSmsCodeAsync(string recipient)
|
||||||
|
{
|
||||||
|
var code = _codeGen.GenerateCode(5);
|
||||||
|
return await SendSmsAsync(recipient: recipient, message: code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user