diff --git a/EnvelopeGenerator.Application/Contracts/IMessagingService.cs b/EnvelopeGenerator.Application/Contracts/IMessagingService.cs index 84c26e3d..0fda64cb 100644 --- a/EnvelopeGenerator.Application/Contracts/IMessagingService.cs +++ b/EnvelopeGenerator.Application/Contracts/IMessagingService.cs @@ -4,8 +4,10 @@ namespace EnvelopeGenerator.Application.Contracts { public interface IMessagingService { - public Task SendSmsAsync(string recipient, string message); - string ServiceProvider { get; } + + Task SendSmsAsync(string recipient, string message); + + Task SendSmsCodeAsync(string recipient); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/GTXMessagingService.cs b/EnvelopeGenerator.Application/Services/GTXMessagingService.cs index 68fc78bf..3ced55eb 100644 --- a/EnvelopeGenerator.Application/Services/GTXMessagingService.cs +++ b/EnvelopeGenerator.Application/Services/GTXMessagingService.cs @@ -17,12 +17,17 @@ namespace EnvelopeGenerator.Application.Services private readonly IMapper _mapper; - public GtxMessagingService(IHttpClientService smsClient, IOptions smsParamsOptions, IMapper mapper) + private readonly ICodeGenerator _codeGen; + + public string ServiceProvider { get; } + + public GtxMessagingService(IHttpClientService smsClient, IOptions smsParamsOptions, IMapper mapper, ICodeGenerator codeGenerator) { _smsClient = smsClient; _smsParams = smsParamsOptions.Value; _mapper = mapper; ServiceProvider = GetType().Name.Replace("Service", string.Empty); + _codeGen = codeGenerator; } public async Task SendSmsAsync(string recipient, string message) @@ -36,6 +41,10 @@ namespace EnvelopeGenerator.Application.Services .ThenAsync(_mapper.Map); } - public string ServiceProvider { get; } + public async Task SendSmsCodeAsync(string recipient) + { + var code = _codeGen.GenerateCode(5); + return await SendSmsAsync(recipient: recipient, message: code); + } } } \ No newline at end of file