From 0c02ad8a518ba4979d12e916727e36de67fbe2e5 Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 29 Jun 2026 15:47:27 -0400 Subject: [PATCH] Adding code to create scheduled message --- src/api/scheduleApi.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/api/scheduleApi.js diff --git a/src/api/scheduleApi.js b/src/api/scheduleApi.js new file mode 100644 index 0000000..76927c2 --- /dev/null +++ b/src/api/scheduleApi.js @@ -0,0 +1,35 @@ +import { API_BASE_URL } from '../constants/api'; + +export const scheduleApi = { + scheduleMessage: async (s, authBearerToken) => { + console.log('Scheduling message'); + const reqBody = { + scheduled: s.scheduedTime.toISOString(), + status: s.status, + user_id: s.userId, + }; + + console.log(`Request body: ${reqBody}`); + const response = await fetch(`${API_BASE_URL}/api/v1/schedule/message`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: authBearerToken, + }, + body: JSON.stringify(reqBody) + }); + + if (!response.ok) { + throw new Error('Error scheduling message'); + } else { + return response.json(); + } + } +}; + +/* + * "scheduled": "{{scheduling_time}}", + "status": "{{status_pending}}", + "user_id": "{{user_id}}" +*/