feat(inbox): 백엔드 API 연동하여 생각(메모) 영속화 적용
This commit is contained in:
57
src/features/inbox/api/inboxApi.ts
Normal file
57
src/features/inbox/api/inboxApi.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { apiClient } from '@/shared/lib/apiClient';
|
||||
|
||||
export interface InboxThoughtResponse {
|
||||
id: string;
|
||||
text: string;
|
||||
sceneName: string;
|
||||
isCompleted: boolean;
|
||||
capturedAt: string;
|
||||
}
|
||||
|
||||
export interface CreateInboxThoughtRequest {
|
||||
text: string;
|
||||
sceneName: string;
|
||||
}
|
||||
|
||||
export interface UpdateInboxThoughtRequest {
|
||||
isCompleted: boolean;
|
||||
}
|
||||
|
||||
export const inboxApi = {
|
||||
getThoughts: async (): Promise<InboxThoughtResponse[]> => {
|
||||
return apiClient<InboxThoughtResponse[]>('api/v1/inbox/thoughts', {
|
||||
method: 'GET',
|
||||
});
|
||||
},
|
||||
|
||||
addThought: async (payload: CreateInboxThoughtRequest): Promise<InboxThoughtResponse> => {
|
||||
return apiClient<InboxThoughtResponse>('api/v1/inbox/thoughts', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
|
||||
updateThoughtComplete: async (
|
||||
thoughtId: string,
|
||||
payload: UpdateInboxThoughtRequest
|
||||
): Promise<InboxThoughtResponse> => {
|
||||
return apiClient<InboxThoughtResponse>(`api/v1/inbox/thoughts/${thoughtId}/complete`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
|
||||
deleteThought: async (thoughtId: string): Promise<void> => {
|
||||
return apiClient<void>(`api/v1/inbox/thoughts/${thoughtId}`, {
|
||||
method: 'DELETE',
|
||||
expectNoContent: true,
|
||||
});
|
||||
},
|
||||
|
||||
clearThoughts: async (): Promise<void> => {
|
||||
return apiClient<void>('api/v1/inbox/thoughts', {
|
||||
method: 'DELETE',
|
||||
expectNoContent: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user