diff --git a/packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts b/packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts index 7657973129..4b01963a82 100644 --- a/packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts +++ b/packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts @@ -78,7 +78,7 @@ export default class FacebookClient { } } - syncAudience = async (input: { audienceId: string; payload: Payload[] }) => { + syncAudience = async (input: { audienceId: string; payload: Payload[]; deleteUsers?: boolean }) => { const schema = this.generateSchema(input.payload) const data = this.generateData(schema, input.payload) @@ -91,7 +91,7 @@ export default class FacebookClient { try { return await this.request(`${BASE_URL}${input.audienceId}/users`, { - method: 'post', + method: input.deleteUsers === true ? 'delete' : 'post', json: params }) } catch (e) { diff --git a/packages/destination-actions/src/destinations/facebook-custom-audiences/sync/index.ts b/packages/destination-actions/src/destinations/facebook-custom-audiences/sync/index.ts index 7fadf1c0cc..cf1b5c830a 100644 --- a/packages/destination-actions/src/destinations/facebook-custom-audiences/sync/index.ts +++ b/packages/destination-actions/src/destinations/facebook-custom-audiences/sync/index.ts @@ -262,30 +262,24 @@ const action: ActionDefinition = { perform: async (request, { settings, payload, hookOutputs, syncMode }) => { const fbClient = new FacebookClient(request, settings.retlAdAccountId) - if (syncMode === 'add' || syncMode === 'update' || syncMode === 'upsert') { + if (syncMode) { return await fbClient.syncAudience({ audienceId: hookOutputs?.retlOnMappingSave.audienceId, - payload: [payload] + payload: [payload], + deleteUsers: syncMode === 'delete' ? true : false }) } - - if (syncMode === 'delete') { - // TODO DELETE OPERATION - } }, performBatch: async (request, { settings, payload, hookOutputs, syncMode }) => { const fbClient = new FacebookClient(request, settings.retlAdAccountId) - if (syncMode === 'add' || syncMode === 'update' || syncMode === 'upsert') { + if (syncMode) { return await fbClient.syncAudience({ audienceId: hookOutputs?.retlOnMappingSave.audienceId, - payload + payload, + deleteUsers: syncMode === 'delete' ? true : false }) } - - if (syncMode === 'delete') { - // TODO DELETE OPERATION - } } }