package com.example.petstoremobile.repositories;

import androidx.lifecycle.LiveData;

import com.example.petstoremobile.api.EmployeeApi;
import com.example.petstoremobile.dtos.EmployeeDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.utils.Resource;

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

@Singleton
public class EmployeeRepository extends BaseRepository {
    private final EmployeeApi employeeApi;

    @Inject
    public EmployeeRepository(EmployeeApi employeeApi) {
        super("EmployeeRepository");
        this.employeeApi = employeeApi;
    }

    public LiveData<Resource<PageResponse<EmployeeDTO>>> getAllEmployees(int page, int size) {
        return executeCall(employeeApi.getAllEmployees(page, size));
    }

    public LiveData<Resource<EmployeeDTO>> getEmployeeById(Long id) {
        return executeCall(employeeApi.getEmployeeById(id));
    }

    public LiveData<Resource<EmployeeDTO>> createEmployee(EmployeeDTO dto) {
        return executeCall(employeeApi.createEmployee(dto));
    }

    public LiveData<Resource<EmployeeDTO>> updateEmployee(Long id, EmployeeDTO dto) {
        return executeCall(employeeApi.updateEmployee(id, dto));
    }

    public LiveData<Resource<Void>> deleteEmployee(Long id) {
        return executeCall(employeeApi.deleteEmployee(id));
    }
}
