From 8c02b8ccb2101147ac84b4555e7fd07235ebf9fc Mon Sep 17 00:00:00 2001 From: Sankeerth Date: Tue, 28 Nov 2023 15:06:00 +0530 Subject: [PATCH] fix: unhandled error code in facebook_custom_audience (#2853) --- src/v0/util/facebookUtils/networkHandler.js | 3 + .../fb_custom_audience/dataDelivery/data.ts | 1120 ++++++++--------- .../fb_custom_audience/network.ts | 909 ++++++------- 3 files changed, 1008 insertions(+), 1024 deletions(-) diff --git a/src/v0/util/facebookUtils/networkHandler.js b/src/v0/util/facebookUtils/networkHandler.js index 9589d17255..e0d69fa5c8 100644 --- a/src/v0/util/facebookUtils/networkHandler.js +++ b/src/v0/util/facebookUtils/networkHandler.js @@ -195,6 +195,9 @@ const errorDetailsMap = { .setMessage('There have been too many calls to this ad-account.') .build(), }, + 200: { + default: new ErrorDetailsExtractorBuilder().setStatus(403).setMessageField('message').build(), + }, }; const getErrorDetailsFromErrorMap = (error) => { diff --git a/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts b/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts index ddb081ba87..d2220e16da 100644 --- a/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts +++ b/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts @@ -1,617 +1,573 @@ export const data = [ - { - name: 'fb_custom_audience', - description: 'successfully adding users to audience', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "successResponse" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + { + name: 'fb_custom_audience', + description: 'successfully adding users to audience', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'successResponse', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 200, - body: { - output: { - status: 200, - message: 'Request Processed Successfully', - destinationResponse: { - audience_id: 'aud1', - invalid_entry_samples: {}, - num_invalid_entries: 0, - num_received: 4, - session_id: '123' - } - } - } + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 200, + message: 'Request Processed Successfully', + destinationResponse: { + audience_id: 'aud1', + invalid_entry_samples: {}, + num_invalid_entries: 0, + num_received: 4, + session_id: '123', }, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'user addition failed due to missing permission', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "permissionMissingError" - }, - params: { - access_token: 'BCD', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: 'user addition failed due to missing permission', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'permissionMissingError', + }, + params: { + access_token: 'BCD', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + ['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN'], + ], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 400, - body: { - output: { - destinationResponse: { - error: { - code: 294, - message: "Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist", - type: "GraphMethodException", - }, - status: 400, - - }, - message: "Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "aborted", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 400, - }, - }, + }, + }, + output: { + response: { + status: 400, + body: { + output: { + destinationResponse: { + error: { + code: 294, + message: + 'Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist', + type: 'GraphMethodException', + }, + status: 400, + }, + message: + 'Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', }, + status: 400, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'user addition failed due to unavailable audience error', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "audienceUnavailableError" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: 'user addition failed due to unavailable audience error', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'audienceUnavailableError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 400, - body: { - output: { - destinationResponse: { - error: { - code: 1487301, - message: "Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account", - type: "GraphMethodException", - }, - status: 400, - - }, - message: "Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "aborted", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 400, - }, - }, + }, + }, + output: { + response: { + status: 400, + body: { + output: { + destinationResponse: { + error: { + code: 1487301, + message: + 'Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account', + type: 'GraphMethodException', + }, + status: 400, + }, + message: + 'Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', }, + status: 400, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'user addition failed because the custom audience has been deleted', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "audienceDeletedError" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: 'user addition failed because the custom audience has been deleted', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'audienceDeletedError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 400, - body: { - output: { - destinationResponse: { - error: { - code: 1487366, - message: "Custom Audience Has Been Deleted", - type: "GraphMethodException", - }, - status: 400, - - }, - message: "Custom Audience Has Been Deleted", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "aborted", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 400, - }, - }, + }, + }, + output: { + response: { + status: 400, + body: { + output: { + destinationResponse: { + error: { + code: 1487366, + message: 'Custom Audience Has Been Deleted', + type: 'GraphMethodException', + }, + status: 400, }, + message: 'Custom Audience Has Been Deleted', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', + }, + status: 400, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'Failed to update the custom audience for unknown reason', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "failedToUpdateAudienceError" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: 'Failed to update the custom audience for unknown reason', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'failedToUpdateAudienceError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 400, - body: { - output: { - destinationResponse: { - error: { - code: 2650, - message: "Failed to update the custom audience", - type: "GraphMethodException", - }, - status: 400, - - }, - message: "Failed to update the custom audience", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "aborted", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 400, - }, - }, + }, + }, + output: { + response: { + status: 400, + body: { + output: { + destinationResponse: { + error: { + code: 2650, + message: 'Failed to update the custom audience', + type: 'GraphMethodException', + }, + status: 400, + }, + message: 'Failed to update the custom audience', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', }, + status: 400, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'Failed to update the custom audience as excessive number of parameters were passed in the request', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "parameterExceededError" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: + 'Failed to update the custom audience as excessive number of parameters were passed in the request', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'parameterExceededError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 400, - body: { - output: { - destinationResponse: { - error: { - code: 105, - message: "The number of parameters exceeded the maximum for this operation", - type: "GraphMethodException", - }, - status: 400, - - }, - message: "The number of parameters exceeded the maximum for this operation", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "aborted", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 400, - }, - }, + }, + }, + output: { + response: { + status: 400, + body: { + output: { + destinationResponse: { + error: { + code: 105, + message: 'The number of parameters exceeded the maximum for this operation', + type: 'GraphMethodException', + }, + status: 400, + }, + message: 'The number of parameters exceeded the maximum for this operation', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', }, + status: 400, + }, }, + }, }, - { - name: 'fb_custom_audience', - description: 'user update request is throttled due to too many calls to the ad account', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - "test-dest-response-key": "tooManyCallsError" - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - } + }, + { + name: 'fb_custom_audience', + description: 'user update request is throttled due to too many calls to the ad account', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'tooManyCallsError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - output: { - response: { - status: 429, - body: { - output: { - destinationResponse: { - error: { - code: 80003, - message: "There have been too many calls to this ad-account.", - type: "GraphMethodException", - }, - status: 429, - - }, - message: "There have been too many calls to this ad-account.", - statTags: { - destType: "FB_CUSTOM_AUDIENCE", - destinationId: "Non-determininable", - errorCategory: "network", - errorType: "throttled", - feature: "dataDelivery", - implementation: "native", - module: "destination", - workspaceId: "Non-determininable", - }, - "status": 429, - }, - }, + }, + }, + output: { + response: { + status: 429, + body: { + output: { + destinationResponse: { + error: { + code: 80003, + message: 'There have been too many calls to this ad-account.', + type: 'GraphMethodException', + }, + status: 429, + }, + message: 'There have been too many calls to this ad-account.', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'throttled', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', + }, + status: 429, + }, + }, + }, + }, + }, + { + name: 'fb_custom_audience', + description: 'user having permission issue while updating audience', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'code200PermissionError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], }, + }, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - } -] \ No newline at end of file + }, + }, + output: { + response: { + status: 403, + body: { + output: { + destinationResponse: { + error: { + code: 200, + fbtrace_id: 'AFfWqjY-_y2Q92DsyJ4DQ6f', + message: '(#200) The current user can not update audience 23861283180290489', + type: 'OAuthException', + }, + status: 403, + }, + message: '(#200) The current user can not update audience 23861283180290489', + statTags: { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'Non-determininable', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'Non-determininable', + }, + status: 403, + }, + }, + }, + }, + }, +]; diff --git a/test/integrations/destinations/fb_custom_audience/network.ts b/test/integrations/destinations/fb_custom_audience/network.ts index 2c19a6fe0d..7dd904fdd9 100644 --- a/test/integrations/destinations/fb_custom_audience/network.ts +++ b/test/integrations/destinations/fb_custom_audience/network.ts @@ -1,456 +1,481 @@ export const networkCallsData = [ - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'successResponse' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'successResponse', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], }, - httpRes: { - "data": { - "audience_id": "aud1", - "session_id": "123", - "num_received": 4, - "num_invalid_entries": 0, - "invalid_entry_samples": {} - }, - "status": 200 - } + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'permissionMissingError' - }, - params: { - access_token: 'BCD', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + httpRes: { + data: { + audience_id: 'aud1', + session_id: '123', + num_received: 4, + num_invalid_entries: 0, + invalid_entry_samples: {}, + }, + status: 200, + }, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'permissionMissingError', + }, + params: { + access_token: 'BCD', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBM', 'DOBD', 'DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], + }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + httpRes: { + data: { + error: { + code: 294, + message: + 'Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist', + type: 'GraphMethodException', + }, + }, + status: 400, + }, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'audienceUnavailableError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], + }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + httpRes: { + data: { + error: { + code: 1487301, + message: + 'Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account', + type: 'GraphMethodException', + }, + }, + status: 400, + }, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'audienceDeletedError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], }, - httpRes: { - data: { - error: { - code: 294, - message: "Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist", - type: "GraphMethodException", - } - }, - "status": 400 - } + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'audienceUnavailableError' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + httpRes: { + data: { + error: { + code: 1487366, + message: 'Custom Audience Has Been Deleted', + type: 'GraphMethodException', }, - httpRes: { - data: { - error: { - code: 1487301, - message: "Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account", - type: "GraphMethodException", - } - }, - "status": 400 - } + }, + status: 400, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'audienceDeletedError' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'failedToUpdateAudienceError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], }, - httpRes: { - data: { - error: { - code: 1487366, - message: "Custom Audience Has Been Deleted", - type: "GraphMethodException", - } - }, - "status": 400 - } + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'failedToUpdateAudienceError' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + httpRes: { + data: { + error: { + code: 2650, + message: 'Failed to update the custom audience', + type: 'GraphMethodException', }, - httpRes: { - data: { - error: { - code: 2650, - message: "Failed to update the custom audience", - type: "GraphMethodException", - } - }, - "status": 400 - } + }, + status: 400, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'parameterExceededError' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'parameterExceededError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], }, - httpRes: { - data: { - error: { - code: 105, - message: "The number of parameters exceeded the maximum for this operation", - type: "GraphMethodException", - } - }, - "status": 400 - } + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, }, - { - httpReq: { - version: '1', - type: 'REST', - method: 'DELETE', - endpoint: 'https://graph.facebook.com/v17.0/aud1/users', - headers: { - 'test-dest-response-key': 'tooManyCallsError' - }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, - userId: '', - body: { - JSON: {}, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, + httpRes: { + data: { + error: { + code: 105, + message: 'The number of parameters exceeded the maximum for this operation', + type: 'GraphMethodException', }, - httpRes: { - data: { - error: { - code: 80003, - message: "There have been too many calls to this ad-account.", - type: "GraphMethodException", - } - }, - "status": 429 - } - } -]; \ No newline at end of file + }, + status: 400, + }, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'tooManyCallsError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], + }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + httpRes: { + data: { + error: { + code: 80003, + message: 'There have been too many calls to this ad-account.', + type: 'GraphMethodException', + }, + }, + status: 429, + }, + }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: 'https://graph.facebook.com/v17.0/aud1/users', + headers: { + 'test-dest-response-key': 'code200PermissionError', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], + }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + httpRes: { + data: { + error: { + code: 200, + fbtrace_id: 'AFfWqjY-_y2Q92DsyJ4DQ6f', + message: '(#200) The current user can not update audience 23861283180290489', + type: 'OAuthException', + }, + }, + status: 403, + }, + }, +];