package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.CustomerApi;
import com.example.petstoremobile.dtos.CustomerDTO;
import com.example.petstoremobile.dtos.DropdownDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.utils.Resource;

import java.util.List;

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

@Singleton
public class CustomerRepository extends BaseRepository {
    private final CustomerApi customerApi;

    @Inject
    public CustomerRepository(CustomerApi customerApi) {
        super("CustomerRepository");
        this.customerApi = customerApi;
    }

    /**
     * Retrieves a paginated list of all customers from the API.
     */
    public LiveData<Resource<PageResponse<CustomerDTO>>> getAllCustomers(int page, int size) {
        return executeCall(customerApi.getAllCustomers(page, size));
    }

    /**
     * Retrieves a specific customer by their ID.
     */
    public LiveData<Resource<CustomerDTO>> getCustomerById(Long id) {
        return executeCall(customerApi.getCustomerById(id));
    }

    /**
     * Retrieves a list of customer dropdowns from the API.
     */
    public LiveData<Resource<List<DropdownDTO>>> getCustomerDropdowns() {
        return executeCall(customerApi.getCustomerDropdowns());
    }
}