using CMSMicroservice.Protobuf.Protos.OtpToken;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.OtpTokenCQ.Commands.CreateNewOtpToken;
using CMSMicroservice.Application.OtpTokenCQ.Commands.VerifyOtpToken;
using CMSMicroservice.Application.OtpTokenCQ.Queries.GetAllOtpTokenByFilter;
namespace CMSMicroservice.WebApi.Services;
public class OtpTokenService : OtpTokenContract.OtpTokenContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public OtpTokenService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewOtpTokenResponse> CreateNewOtpToken(CreateNewOtpTokenRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewOtpTokenRequest, CreateNewOtpTokenCommand, CreateNewOtpTokenResponse>(request, context);
    }
    public override async Task<VerifyOtpTokenResponse> VerifyOtpToken(VerifyOtpTokenRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<VerifyOtpTokenRequest, VerifyOtpTokenCommand, VerifyOtpTokenResponse>(request, context);
    }
    public override async Task<GetAllOtpTokenByFilterResponse> GetAllOtpTokenByFilter(GetAllOtpTokenByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllOtpTokenByFilterRequest, GetAllOtpTokenByFilterQuery, GetAllOtpTokenByFilterResponse>(request, context);
    }
}
