-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshoppingListsApi.ts
29 lines (23 loc) · 922 Bytes
/
shoppingListsApi.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { ShoppingListOverview } from '~shoppingLists/types/shoppingListOverview';
import { ShoppingListDetails } from '~shoppingLists/types/shoppingListDetails';
import { axios } from 'src/api/axiosProvider';
class ShoppingListsApi {
async getShoppingLists() {
const { data } = await axios.get<ShoppingListOverview[]>('/shoppingLists/overview');
return data;
}
async getShoppingList(id: string) {
const { data } = await axios.get<ShoppingListDetails>(`/shoppingLists/${id}`);
return data;
}
createShoppingList(payload: Omit<ShoppingListDetails, 'id'>) {
return axios.post('/shoppingLists', payload);
}
updateShoppingList(id: string, payload: Omit<ShoppingListDetails, 'id'>) {
return axios.put(`/shoppingLists/${id}`, payload);
}
deleteShoppingList(id: string) {
return axios.delete(`/shoppingLists/${id}`);
}
}
export const shoppingListsApi = new ShoppingListsApi();