package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.SaleApi;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.SaleDTO;
import com.example.petstoremobile.utils.Resource;

import javax.inject.Inject;
import javax.inject.Singleton;

@Singleton
public class SaleRepository extends BaseRepository {
    private final SaleApi saleApi;

    @Inject
    public SaleRepository(SaleApi saleApi) {
        super("SaleRepository");
        this.saleApi = saleApi;
    }

    public LiveData<Resource<PageResponse<SaleDTO>>> getAllSales(int page, int size, String query, String paymentMethod, Long storeId, Boolean isRefund, Long customerId, String sortBy) {
        return executeCall(saleApi.getAllSales(page, size, query, paymentMethod, storeId, isRefund, customerId, sortBy));
    }

    public LiveData<Resource<SaleDTO>> getSaleById(Long id) {
        return executeCall(saleApi.getSaleById(id));
    }

    public LiveData<Resource<SaleDTO>> createSale(SaleDTO sale) {
        return executeCall(saleApi.createSale(sale));
    }
}
