using CMSMicroservice.Protobuf.Protos.PaymentTransaction;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;

namespace CMSMicroservice.WebApi.Services;

public class PaymentTransactionService : PaymentTransactionContract.PaymentTransactionContractBase
{
    private readonly IDispatchRequestToCQRS _dispatch;

    public PaymentTransactionService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;

    public override Task<GetAllPaymentTransactionByFilterResponse> GetAllPaymentTransactionByFilter(
        GetAllPaymentTransactionByFilterRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetAllPaymentTransactionByFilterRequest, GetAllPaymentTransactionByFilterQuery, GetAllPaymentTransactionByFilterResponse>(request, context);

    public override Task<GetPaymentTransactionSummaryResponse> GetPaymentTransactionSummary(
        GetPaymentTransactionSummaryRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetPaymentTransactionSummaryRequest, GetPaymentTransactionSummaryQuery, GetPaymentTransactionSummaryResponse>(request, context);
}
