package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.AdoptionApi;
import com.example.petstoremobile.dtos.AdoptionDTO;
import com.example.petstoremobile.dtos.BulkDeleteRequest;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.utils.Resource;

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

@Singleton
public class AdoptionRepository extends BaseRepository {
    private final AdoptionApi adoptionApi;

    @Inject
    public AdoptionRepository(AdoptionApi adoptionApi) {
        super("AdoptionRepository");
        this.adoptionApi = adoptionApi;
    }

    /**
     * Retrieves a paginated list of all adoptions from the API.
     */
    public LiveData<Resource<PageResponse<AdoptionDTO>>> getAllAdoptions(int page, int size, String query, String status, Long storeId, String date, Long employeeId, String sort) {
        return executeCall(adoptionApi.getAllAdoptions(page, size, query, status, storeId, date, employeeId, sort));
    }

    /**
     * Retrieves a specific adoption record by its ID from the API.
     */
    public LiveData<Resource<AdoptionDTO>> getAdoptionById(Long id) {
        return executeCall(adoptionApi.getAdoptionById(id));
    }

    /**
     * Sends a request to the API to create a new adoption record.
     */
    public LiveData<Resource<AdoptionDTO>> createAdoption(AdoptionDTO adoption) {
        return executeCall(adoptionApi.createAdoption(adoption));
    }

    /**
     * Sends a request to the API to update an existing adoption record by ID.
     */
    public LiveData<Resource<AdoptionDTO>> updateAdoption(Long id, AdoptionDTO adoption) {
        return executeCall(adoptionApi.updateAdoption(id, adoption));
    }

    /**
     * Sends a request to the API to delete a specific adoption record.
     */
    public LiveData<Resource<Void>> deleteAdoption(Long id) {
        return executeCall(adoptionApi.deleteAdoption(id));
    }

    /**
     * Sends a request to the API to delete multiple adoption records.
     */
    public LiveData<Resource<Void>> bulkDeleteAdoptions(BulkDeleteRequest request) {
        return executeCall(adoptionApi.bulkDeleteAdoptions(request));
    }
}
