package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.PurchaseOrderApi;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.PurchaseOrderDTO;
import com.example.petstoremobile.utils.Resource;

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

@Singleton
public class PurchaseOrderRepository extends BaseRepository {
    private final PurchaseOrderApi purchaseOrderApi;

    @Inject
    public PurchaseOrderRepository(PurchaseOrderApi purchaseOrderApi) {
        super("PurchaseOrderRepository");
        this.purchaseOrderApi = purchaseOrderApi;
    }

    /**
     * Retrieves a paginated list of all purchase orders from the API.
     */
    public LiveData<Resource<PageResponse<PurchaseOrderDTO>>> getAllPurchaseOrders(int page, int size, String query, Long storeId, String sort) {
        return executeCall(purchaseOrderApi.getAllPurchaseOrders(page, size, query, storeId, sort));
    }

    /**
     * Retrieves a specific purchase order by its ID from the API.
     */
    public LiveData<Resource<PurchaseOrderDTO>> getPurchaseOrderById(Long id) {
        return executeCall(purchaseOrderApi.getPurchaseOrderById(id));
    }
}