import { http } from "../../../services/http.service";
import { CreateReportContract } from "../contracts/CreateReportContract";
import { ReportContract } from "../contracts/ReportContract";
import { ReportWithDataContract } from "../contracts/ReportWithDataContract";

const getList = async () => {
	return await http.get<ReportContract[]>("/api/reports");
};

const get = async (id: string) => {
	return await http.get<ReportWithDataContract>(`/api/reports/${id}`);
};

const create = async (request: CreateReportContract) => {
	return await http.post<ReportContract>("/api/reports", request);
};

const remove = async (id: string) => {
	return await http.remove(`/api/reports/${id}`);
};

const clear = async () => {
	return await http.remove("/api/reports");
};

export const reportApi = { getList, get, create, remove, clear };
