tsk-7: Schedule message (#8)
Closes #7 Reviewed-on: phoenix/textsender#8
This commit was merged in pull request #8.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { API_BASE_URL } from '../constants/api';
|
||||
|
||||
export const scheduleApi = {
|
||||
scheduleMessage: async (reqBody, authBearerToken) => {
|
||||
console.log('Scheduling message');
|
||||
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
||||
prepareMessage: async (reqBody, authBearerToken) => {
|
||||
console.log('Preparing Scheduled message');
|
||||
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/api/v1/schedule/message/status/update`,
|
||||
{
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authBearerToken,
|
||||
},
|
||||
body: JSON.stringify(reqBody),
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Error updating status of scheduled message');
|
||||
} else {
|
||||
return response.json();
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user