2021-05-10 07:31:00 +00:00
|
|
|
import endPoints from 'widget/api/endPoints';
|
|
|
|
import { API } from 'widget/helpers/axios';
|
|
|
|
|
|
|
|
const getCampaigns = async websiteToken => {
|
|
|
|
const urlData = endPoints.getCampaigns(websiteToken);
|
|
|
|
const result = await API.get(urlData.url, { params: urlData.params });
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
const triggerCampaign = async ({ campaignId }) => {
|
|
|
|
const { websiteToken } = window.chatwootWebChannel;
|
2021-05-17 16:08:35 +00:00
|
|
|
const urlData = endPoints.triggerCampaign({ websiteToken, campaignId });
|
2021-05-10 07:31:00 +00:00
|
|
|
|
|
|
|
await API.post(
|
|
|
|
urlData.url,
|
|
|
|
{ ...urlData.data },
|
|
|
|
{
|
|
|
|
params: urlData.params,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { getCampaigns, triggerCampaign };
|