Skip to content

Commit 27bec02

Browse files
committed
Add Campaigns bulkDelete API integration
1 parent 8f14fe6 commit 27bec02

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/endpoints/Campaigns/Client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ProgressPromise } from '@prezly/progress-promise';
22

33
import type { DeferredJobsApiClient } from '../../api';
44
import { routing } from '../../routing';
5-
import type { Campaign } from '../../types';
5+
import type { BulkDeletePayload, Campaign } from '../../types';
66
import { Query, SortOrder } from '../../types';
77
import { toIso8601 } from '../../utils';
88

@@ -56,6 +56,15 @@ export function createClient(api: DeferredJobsApiClient) {
5656
return api.delete(`${routing.campaignsUrl}/${id}`);
5757
}
5858

59+
async function bulkDelete(
60+
payload: BulkDeletePayload,
61+
): ProgressPromise<{ records_deleted_number: number }> {
62+
const { search, query } = payload;
63+
return api.delete(routing.campaignsUrl, {
64+
payload: { search, query },
65+
});
66+
}
67+
5968
async function test(id: Campaign['id'], emails: string[]): Promise<void> {
6069
return api.post(`${routing.campaignsUrl}/${id}/test`, {
6170
payload: { emails },
@@ -109,5 +118,6 @@ export function createClient(api: DeferredJobsApiClient) {
109118
create,
110119
update,
111120
delete: doDelete,
121+
bulkDelete,
112122
};
113123
}

0 commit comments

Comments
 (0)