added api setup

This commit is contained in:
ari committed 2021-12-30 12:37:30 -05:00
1 parent 787716ccba
commit 4a08956e1a
21 files changed
+12292 -12527

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
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>;