Files
Shortumation/webapp/src/apiService/automations.ts
T
2021-12-30 12:37:30 -05:00

40 lines
950 B
TypeScript

import { AutomationData } from "types/automations";
import { API } from "./base";
import { ListData, ListParams } from "./types";
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
export const makeAutomationAPI = (api: API) => ({
async list({ offset, limit }: ListParams) {
const data = await api.makeCall<ListData<AutomationData>, ListParams>({
path: AUTOMTAION_LIST,
data: {
offset, limit,
}
});
console.log({ list: data });
return data;
},
async update({index, auto}: {index: number, auto: AutomationData}) {
return await api.makeCall({
path: AUTOMTAION_ROOT,
data: {
index,
data: auto
},
})
},
async remove({index}: {index: number}) {
return await api.makeCall({
method: "DELETE",
path: AUTOMTAION_ROOT,
data: {
index,
}
})
}
});
export type AutomationAPI = ReturnType<typeof makeAutomationAPI>;