namespace DocuMed.Infrastructure.Services;


public class SmsService : ISmsService
{
    private readonly IRestApiWrapper _restApiWrapper;
    private readonly ILogger<SmsService> _logger;
    private readonly SiteSettings _siteSettings;
    public SmsService(IRestApiWrapper restApiWrapper,
        IOptionsSnapshot<SiteSettings> optionsSnapshot,
        ILogger<SmsService> logger)
    {
        _restApiWrapper = restApiWrapper;
        _logger = logger;
        _siteSettings = optionsSnapshot.Value;
    }
    public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword)
    {
        var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword, null, null, null, "forgetPassword");

        if (rest.Return?.status != 200)
            throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
    }

    public async Task SendVerifyCodeAsync(string phoneNumber, string verifyCode)
    {

        var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, verifyCode, null, null, null, "login");

        if (rest.Return?.status != 200)
            throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
    }

}