package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.StoreApi;
import com.example.petstoremobile.dtos.DropdownDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.StoreDTO;
import com.example.petstoremobile.utils.Resource;

import java.util.List;

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

@Singleton
public class StoreRepository extends BaseRepository {
    private final StoreApi storeApi;

    @Inject
    public StoreRepository(StoreApi storeApi) {
        super("StoreRepository");
        this.storeApi = storeApi;
    }

    /**
     * Retrieves a paginated list of all stores from the API.
     */
    public LiveData<Resource<PageResponse<StoreDTO>>> getAllStores(int page, int size) {
        return executeCall(storeApi.getAllStores(page, size));
    }

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

    /**
     * Retrieves a list of employees for a specific store from the dropdowns API.
     */
    public LiveData<Resource<List<DropdownDTO>>> getStoreEmployees(Long storeId) {
        return executeCall(storeApi.getStoreEmployees(storeId));
    }
}
