@@ -11,3 +11,35 @@ export const fetchChats = async () => {
1111 const response = await apiClient . get ( API_CONFIG . ENDPOINTS . CHATS ) ;
1212 return response . data . data ;
1313} ;
14+
15+ /**
16+ * Fetch chat messages for a specific chatroom (cursor-based pagination)
17+ * @param {number } chatroomId - Chatroom ID
18+ * @param {string | null } cursor - Cursor value (timestamp|messageId format)
19+ * @param {number } size - Page size (default: 20)
20+ * @returns {Promise<{chats: Array, before: string | null, next: string | null}> }
21+ * @throws {Error } 401 if not authenticated, 400 if invalid cursor/size
22+ */
23+ export const fetchChatMessages = async ( chatroomId , cursor = null , size = 20 ) => {
24+ const params = { size } ;
25+ if ( cursor ) {
26+ params . after = cursor ;
27+ }
28+
29+ const response = await apiClient . get ( API_CONFIG . ENDPOINTS . CHAT_MESSAGES ( chatroomId ) , {
30+ params,
31+ } ) ;
32+ return response . data . data ;
33+ } ;
34+
35+ /**
36+ * Send a message to a chatroom
37+ * TODO: Implement after POST API spec is provided
38+ * @param {number } chatroomId - Chatroom ID
39+ * @param {object } payload - Message payload (text, files, etc.)
40+ * @returns {Promise<object> } Created message object
41+ */
42+ export const sendChatMessage = async ( chatroomId , payload ) => {
43+ // TODO: Implement after POST /chats/{chatroomId} spec is provided
44+ throw new Error ( 'POST /chats/{chatroomId} API spec not yet provided' ) ;
45+ } ;
0 commit comments