feat(GtxMessagingService): SendSmsCodeAsync mit Basisfunktionalität als Schnittstellenimplementierung hinzugefügt

This commit is contained in:
Developer 02
2024-11-29 11:13:59 +01:00
parent b11f32bd3c
commit 0c81a86610
2 changed files with 15 additions and 4 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}
}