using Indotalent.ConfigBackEnd.Interfaces;
using Indotalent.ConfigFrontEnd.Common;
using Indotalent.Features.Purchase.PaymentDisburseReport.Cqrs;
using Indotalent.Infrastructure.Authentication.Identity;
using Indotalent.Shared.Models;
using Microsoft.AspNetCore.Components;
using MudBlazor;
using RestSharp;

namespace Indotalent.Features.Purchase.PaymentDisburseReport;

public class PaymentDisburseReportService : BaseService
{
    private readonly RestClient _client;

    public PaymentDisburseReportService(
            IHttpClientFactory clientFactory,
            NavigationManager nav,
            ISnackbar snackbar,
            ICurrentUserService currentUserService,
            TokenProvider tokenProvider)
            : base(clientFactory, nav, snackbar, currentUserService, tokenProvider)
    {
        _client = new RestClient(nav.BaseUri);
    }

    public async Task<ApiResponse<List<GetPaymentDisburseReportListDto>>?> GetPaymentDisburseReportListAsync()
    {
        var request = new RestRequest("api/payment-disburse-report", Method.Get);
        return await ExecuteWithResponseAsync<List<GetPaymentDisburseReportListDto>>(_client, request);
    }
}