Spaces:
Sleeping
Sleeping
| import apiClient from './client' | |
| import { NotebookResponse, CreateNotebookRequest, UpdateNotebookRequest } from '@/lib/types/api' | |
| export const notebooksApi = { | |
| list: async (params?: { archived?: boolean; order_by?: string }) => { | |
| const response = await apiClient.get<NotebookResponse[]>('/notebooks', { params }) | |
| return response.data | |
| }, | |
| get: async (id: string) => { | |
| const response = await apiClient.get<NotebookResponse>(`/notebooks/${id}`) | |
| return response.data | |
| }, | |
| create: async (data: CreateNotebookRequest) => { | |
| const response = await apiClient.post<NotebookResponse>('/notebooks', data) | |
| return response.data | |
| }, | |
| update: async (id: string, data: UpdateNotebookRequest) => { | |
| const response = await apiClient.put<NotebookResponse>(`/notebooks/${id}`, data) | |
| return response.data | |
| }, | |
| delete: async (id: string) => { | |
| await apiClient.delete(`/notebooks/${id}`) | |
| }, | |
| addSource: async (notebookId: string, sourceId: string) => { | |
| const response = await apiClient.post(`/notebooks/${notebookId}/sources/${sourceId}`) | |
| return response.data | |
| }, | |
| removeSource: async (notebookId: string, sourceId: string) => { | |
| const response = await apiClient.delete(`/notebooks/${notebookId}/sources/${sourceId}`) | |
| return response.data | |
| } | |
| } |