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 Task<SmsResponse> SendSmsAsync(string recipient, string message);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
_smsParams = smsParamsOptions.Value;
|
||||
_mapper = mapper;
|
||||
ServiceProvider = GetType().Name.Replace("Service", string.Empty);
|
||||
_codeGen = codeGenerator;
|
||||
}
|
||||
|
||||
public async Task<SmsResponse> SendSmsAsync(string recipient, string message)
|
||||
@@ -36,6 +41,10 @@ namespace EnvelopeGenerator.Application.Services
|
||||
.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