60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { apiClient } from "@/lib/api-client";
|
|
import { env } from "@/config/env";
|
|
import type { SendCampaignInput, SetupCampaignInput, UpdateCampaignInput } from "./schemas";
|
|
|
|
export const campaignsService = {
|
|
getAll: async (status?: string) => {
|
|
const params = status ? { status } : {};
|
|
const response = await apiClient.get(
|
|
`/${env.endpoints.campaignManagement}/all`,
|
|
{ params }
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
sendSingle: async (data: SendCampaignInput) => {
|
|
const response = await apiClient.post(
|
|
`/${env.endpoints.campaignManagement}/send`,
|
|
data
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
setup: async (data: SetupCampaignInput) => {
|
|
const response = await apiClient.post(
|
|
`/${env.endpoints.campaignManagement}/setup`,
|
|
data
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
update: async (id: string, data: UpdateCampaignInput) => {
|
|
const response = await apiClient.put(
|
|
`/${env.endpoints.campaignManagement}/${id}`,
|
|
data
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
cancel: async (id: string) => {
|
|
const response = await apiClient.delete(
|
|
`/${env.endpoints.campaignManagement}/${id}`
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
getAnalytics: async () => {
|
|
const response = await apiClient.get(
|
|
`/${env.endpoints.campaignManagement}/analytics`
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
getReport: async (id: string) => {
|
|
const response = await apiClient.get(
|
|
`/${env.endpoints.campaignManagement}/report/${id}`
|
|
);
|
|
return response.data;
|
|
},
|
|
};
|