36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
|
|
import { apiClient } from './client';
|
||
|
|
import type {
|
||
|
|
SimulationTemplate,
|
||
|
|
SimulationTemplateCreateInput,
|
||
|
|
SimulationTemplatePatchInput,
|
||
|
|
} from './types';
|
||
|
|
|
||
|
|
export async function listTemplates(): Promise<SimulationTemplate[]> {
|
||
|
|
const { data } = await apiClient.get<SimulationTemplate[]>('/simulation-templates');
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getTemplate(id: number): Promise<SimulationTemplate> {
|
||
|
|
const { data } = await apiClient.get<SimulationTemplate>(`/simulation-templates/${id}`);
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function createTemplate(
|
||
|
|
input: SimulationTemplateCreateInput,
|
||
|
|
): Promise<SimulationTemplate> {
|
||
|
|
const { data } = await apiClient.post<SimulationTemplate>('/simulation-templates', input);
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updateTemplate(
|
||
|
|
id: number,
|
||
|
|
patch: SimulationTemplatePatchInput,
|
||
|
|
): Promise<SimulationTemplate> {
|
||
|
|
const { data } = await apiClient.patch<SimulationTemplate>(`/simulation-templates/${id}`, patch);
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function deleteTemplate(id: number): Promise<void> {
|
||
|
|
await apiClient.delete(`/simulation-templates/${id}`);
|
||
|
|
}
|