From 44d6c0589ca84087a66aa894b8dc3e5061c7a8cd Mon Sep 17 00:00:00 2001 From: Vikas Venkatraman Date: Mon, 17 Jun 2024 08:17:38 +0530 Subject: [PATCH] chore: addressed all comments --- .../fb_custom_audience/recordTransform.js | 53 +- .../recordTransform.js | 57 +- .../transform.js | 2 +- .../util.test.js | 203 ++++++ src/v0/util/recordUtils.js | 55 ++ .../processor/data.ts | 98 +-- .../router/audience.ts | 129 ++++ .../router/data.ts | 680 ++++-------------- .../router/record.ts | 158 ++++ 9 files changed, 769 insertions(+), 666 deletions(-) create mode 100644 src/v0/destinations/google_adwords_remarketing_lists/util.test.js create mode 100644 src/v0/util/recordUtils.js create mode 100644 test/integrations/destinations/google_adwords_remarketing_lists/router/audience.ts create mode 100644 test/integrations/destinations/google_adwords_remarketing_lists/router/record.ts diff --git a/src/v0/destinations/fb_custom_audience/recordTransform.js b/src/v0/destinations/fb_custom_audience/recordTransform.js index 0f7b65c0bf..62d4bd568b 100644 --- a/src/v0/destinations/fb_custom_audience/recordTransform.js +++ b/src/v0/destinations/fb_custom_audience/recordTransform.js @@ -1,11 +1,7 @@ /* eslint-disable no-const-assign */ const lodash = require('lodash'); const get = require('get-value'); -const { - InstrumentationError, - ConfigurationError, - getErrorRespEvents, -} = require('@rudderstack/integrations-lib'); +const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib'); const { schemaFields } = require('./config'); const { MappedToDestinationKey } = require('../../../constants'); const stats = require('../../../util/stats'); @@ -15,8 +11,8 @@ const { checkSubsetOfArray, returnArrayOfSubarrays, getSuccessRespEvents, - generateErrorObject, } = require('../../util'); +const { getErrorResponse, createFinalResponse } = require('../../util/recordUtils'); const { ensureApplicableFormat, getUpdatedDataElement, @@ -26,19 +22,6 @@ const { getDataSource, } = require('./util'); -function getErrorMetaData(inputs, acceptedOperations) { - const metadata = []; - // eslint-disable-next-line no-restricted-syntax - for (const key in inputs) { - if (!acceptedOperations.includes(key)) { - inputs[key].forEach((input) => { - metadata.push(input.metadata); - }); - } - } - return metadata; -} - const processRecordEventArray = ( recordChunksArray, userSchema, @@ -177,8 +160,6 @@ async function processRecordInputs(groupedRecordInputs) { record.message.action?.toLowerCase(), ); - const finalResponse = []; - let insertResponse; let deleteResponse; let updateResponse; @@ -238,32 +219,14 @@ async function processRecordInputs(groupedRecordInputs) { ); } - const eventTypes = ['update', 'insert', 'delete']; - const errorMetaData = []; - const errorMetaDataObject = getErrorMetaData(groupedRecordsByAction, eventTypes); - if (errorMetaDataObject.length > 0) { - errorMetaData.push(errorMetaDataObject); - } + const errorResponse = getErrorResponse(groupedRecordsByAction); - const error = new InstrumentationError('Invalid action type in record event'); - const errorObj = generateErrorObject(error); - const errorResponseList = errorMetaData.map((metadata) => - getErrorRespEvents(metadata, errorObj.status, errorObj.message, errorObj.statTags), + const finalResponse = createFinalResponse( + deleteResponse, + insertResponse, + updateResponse, + errorResponse, ); - - if (deleteResponse && deleteResponse.batchedRequest.length > 0) { - finalResponse.push(deleteResponse); - } - if (insertResponse && insertResponse.batchedRequest.length > 0) { - finalResponse.push(insertResponse); - } - if (updateResponse && updateResponse.batchedRequest.length > 0) { - finalResponse.push(updateResponse); - } - if (errorResponseList.length > 0) { - finalResponse.push(...errorResponseList); - } - if (finalResponse.length === 0) { throw new InstrumentationError( 'Missing valid parameters, unable to generate transformed payload', diff --git a/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js b/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js index ea1a8dbe48..18e7f96821 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js @@ -1,32 +1,18 @@ /* eslint-disable no-const-assign */ const lodash = require('lodash'); -const { InstrumentationError, getErrorRespEvents } = require('@rudderstack/integrations-lib'); +const { InstrumentationError } = require('@rudderstack/integrations-lib'); const { getValueFromMessage, getAccessToken, constructPayload, returnArrayOfSubarrays, getSuccessRespEvents, - generateErrorObject, } = require('../../util'); const { populateConsentFromConfig } = require('../../util/googleUtils'); const { populateIdentifiers, responseBuilder } = require('./util'); - +const { getErrorResponse, createFinalResponse } = require('../../util/recordUtils'); const { offlineDataJobsMapping, consentConfigMap } = require('./config'); -function getErrorMetaData(inputs, acceptedOperations) { - const metadata = []; - // eslint-disable-next-line no-restricted-syntax - for (const key in inputs) { - if (!acceptedOperations.includes(key)) { - inputs[key].forEach((input) => { - metadata.push(input.metadata); - }); - } - } - return metadata; -} - const processRecordEventArray = ( records, message, @@ -92,16 +78,14 @@ const processRecordEventArray = ( }; async function processRecordInputs(groupedRecordInputs) { - const { destination, message, metadata } = groupedRecordInputs[0]; - const accessToken = getAccessToken(metadata, 'access_token'); + const { destination, message, metadata } = groupedRecordInputs[0]; + const accessToken = getAccessToken(metadata, 'accessToken'); const developerToken = getValueFromMessage(metadata, 'secret.developer_token'); const groupedRecordsByAction = lodash.groupBy(groupedRecordInputs, (record) => record.message.action?.toLowerCase(), ); - const finalResponse = []; - let insertResponse; let deleteResponse; let updateResponse; @@ -139,30 +123,17 @@ async function processRecordInputs(groupedRecordInputs) { ); } - const eventTypes = ['update', 'insert', 'delete']; - const errorMetaData = []; - const errorMetaDataObject = getErrorMetaData(groupedRecordsByAction, eventTypes); - if (errorMetaDataObject.length > 0) { - errorMetaData.push(errorMetaDataObject); - } - - const error = new InstrumentationError('Invalid action type in record event'); - const errorObj = generateErrorObject(error); - const errorResponseList = errorMetaData.map((data) => - getErrorRespEvents(data, errorObj.status, errorObj.message, errorObj.statTags), + const errorResponse = getErrorResponse(groupedRecordsByAction); + const finalResponse = createFinalResponse( + deleteResponse, + insertResponse, + updateResponse, + errorResponse, ); - - if (deleteResponse && deleteResponse.batchedRequest.length > 0) { - finalResponse.push(deleteResponse); - } - if (insertResponse && insertResponse.batchedRequest.length > 0) { - finalResponse.push(insertResponse); - } - if (updateResponse && updateResponse.batchedRequest.length > 0) { - finalResponse.push(updateResponse); - } - if (errorResponseList.length > 0) { - finalResponse.push(...errorResponseList); + if (finalResponse.length === 0) { + throw new InstrumentationError( + 'Missing valid parameters, unable to generate transformed payload', + ); } return finalResponse; diff --git a/src/v0/destinations/google_adwords_remarketing_lists/transform.js b/src/v0/destinations/google_adwords_remarketing_lists/transform.js index 3deb9be775..d879a39c63 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/transform.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/transform.js @@ -108,7 +108,7 @@ const processEvent = async (metadata, message, destination) => { ); } - const accessToken = getAccessToken(metadata, 'access_token'); + const accessToken = getAccessToken(metadata, 'accessToken'); const developerToken = getValueFromMessage(metadata, 'secret.developer_token'); Object.values(createdPayload).forEach((data) => { diff --git a/src/v0/destinations/google_adwords_remarketing_lists/util.test.js b/src/v0/destinations/google_adwords_remarketing_lists/util.test.js new file mode 100644 index 0000000000..e9fe90c317 --- /dev/null +++ b/src/v0/destinations/google_adwords_remarketing_lists/util.test.js @@ -0,0 +1,203 @@ +const { populateIdentifiers, responseBuilder } = require('./util'); + +const accessToken = 'abcd1234'; +const developerToken = 'ijkl9101'; +const body = { + operations: [ + { + create: { + userIdentifiers: [ + { + hashedEmail: 'd3142c8f9c9129484daf28df80cc5c955791efed5e69afabb603bc8cb9ffd419', + }, + { + hashedPhoneNumber: '8846dcb6ab2d73a0e67dbd569fa17cec2d9d391e5b05d1dd42919bc21ae82c45', + }, + { + addressInfo: { + hashedFirstName: '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + hashedLastName: 'dcf000c2386fb76d22cefc0d118a8511bb75999019cd373df52044bccd1bd251', + countryCode: 'US', + postalCode: '1245', + }, + }, + ], + }, + }, + ], +}; +const baseDestination = { + Config: { + rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', + listId: '7090784486', + customerId: '7693729833', + loginCustomerId: '', + subAccount: false, + userSchema: ['email', 'phone', 'addressInfo'], + isHashRequired: true, + typeOfList: 'General', + }, +}; +const consentBlock = { + adPersonalization: 'UNSPECIFIED', + adUserData: 'UNSPECIFIED', +}; +const message = { + action: 'insert', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'd3142c8f9c9129484daf28df80cc5c955791efed5e69afabb603bc8cb9ffd419', + phone: '8846dcb6ab2d73a0e67dbd569fa17cec2d9d391e5b05d1dd42919bc21ae82c45', + firstName: '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + lastName: 'dcf000c2386fb76d22cefc0d118a8511bb75999019cd373df52044bccd1bd251', + country: 'US', + postalCode: '1245', + }, + type: 'record', +}; +const expectedResponse = { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', + headers: { + Authorization: 'Bearer abcd1234', + 'Content-Type': 'application/json', + 'developer-token': 'ijkl9101', + }, + params: { + listId: '7090784486', + customerId: '7693729833', + consent: { + adPersonalization: 'UNSPECIFIED', + adUserData: 'UNSPECIFIED', + }, + }, + body: { + JSON: { + operations: [ + { + create: { + userIdentifiers: [ + { + hashedEmail: 'd3142c8f9c9129484daf28df80cc5c955791efed5e69afabb603bc8cb9ffd419', + }, + { + hashedPhoneNumber: + '8846dcb6ab2d73a0e67dbd569fa17cec2d9d391e5b05d1dd42919bc21ae82c45', + }, + { + addressInfo: { + hashedFirstName: + '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + hashedLastName: + 'dcf000c2386fb76d22cefc0d118a8511bb75999019cd373df52044bccd1bd251', + countryCode: 'US', + postalCode: '1245', + }, + }, + ], + }, + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, +}; +const attributeArray = [ + { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, +]; + +const hashedArray = [ + { + hashedEmail: 'd3142c8f9c9129484daf28df80cc5c955791efed5e69afabb603bc8cb9ffd419', + }, + { + hashedPhoneNumber: '8846dcb6ab2d73a0e67dbd569fa17cec2d9d391e5b05d1dd42919bc21ae82c45', + }, + { + addressInfo: { + hashedFirstName: '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + hashedLastName: 'dcf000c2386fb76d22cefc0d118a8511bb75999019cd373df52044bccd1bd251', + countryCode: 'US', + postalCode: '1245', + }, + }, +]; + +describe('GARL utils test', () => { + describe('responseBuilder function tests', () => { + it('Should return correct response for given payload', () => { + const response = responseBuilder( + accessToken, + developerToken, + body, + baseDestination, + message, + consentBlock, + ); + expect(response).toEqual(expectedResponse); + }); + + it('Should throw error if subaccount is true and loginCustomerId is not defined', () => { + try { + const destination2 = Object.create(baseDestination); + destination2.Config.subAccount = true; + destination2.Config.loginCustomerId = ''; + const response = responseBuilder( + accessToken, + developerToken, + body, + destination2, + message, + consentBlock, + ); + expect(response).toEqual(); + } catch (error) { + expect(error.message).toEqual(`loginCustomerId is required as subAccount is true.`); + } + }); + + it('Should throw error if operationAudienceId is not defined', () => { + try { + const destination1 = Object.create(baseDestination); + destination1.Config.listId = ''; + const response = responseBuilder( + accessToken, + developerToken, + body, + destination1, + message, + consentBlock, + ); + expect(response).toEqual(); + } catch (error) { + expect(error.message).toEqual(`List ID is a mandatory field`); + } + }); + }); + + describe('populateIdentifiers function tests', () => { + it('Should hash and return identifiers for a given list of attributes', () => { + const identifier = populateIdentifiers(attributeArray, baseDestination); + expect(identifier).toEqual(hashedArray); + }); + }); +}); diff --git a/src/v0/util/recordUtils.js b/src/v0/util/recordUtils.js new file mode 100644 index 0000000000..a3dd65ef33 --- /dev/null +++ b/src/v0/util/recordUtils.js @@ -0,0 +1,55 @@ +const { InstrumentationError, getErrorRespEvents } = require('@rudderstack/integrations-lib'); +const { generateErrorObject } = require('./index'); + +const eventTypes = ['update', 'insert', 'delete']; + +function getErrorMetaData(inputs, acceptedOperations) { + const metadata = []; + // eslint-disable-next-line no-restricted-syntax + for (const key in inputs) { + if (!acceptedOperations.includes(key)) { + inputs[key].forEach((input) => { + metadata.push(input.metadata); + }); + } + } + return metadata; +} + +function getErrorResponse(groupedRecordsByAction) { + const errorMetaData = []; + const errorMetaDataObject = getErrorMetaData(groupedRecordsByAction, eventTypes); + if (errorMetaDataObject.length > 0) { + errorMetaData.push(errorMetaDataObject); + } + + const error = new InstrumentationError('Invalid action type in record event'); + const errorObj = generateErrorObject(error); + const errorResponseList = errorMetaData.map((data) => + getErrorRespEvents(data, errorObj.status, errorObj.message, errorObj.statTags), + ); + + return errorResponseList; +} + +function createFinalResponse(deleteResponse, insertResponse, updateResponse, errorResponseList) { + const finalResponse = []; + if (deleteResponse && deleteResponse.batchedRequest.length > 0) { + finalResponse.push(deleteResponse); + } + if (insertResponse && insertResponse.batchedRequest.length > 0) { + finalResponse.push(insertResponse); + } + if (updateResponse && updateResponse.batchedRequest.length > 0) { + finalResponse.push(updateResponse); + } + if (errorResponseList.length > 0) { + finalResponse.push(...errorResponseList); + } + return finalResponse; +} + +module.exports = { + getErrorResponse, + createFinalResponse, +}; diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/processor/data.ts b/test/integrations/destinations/google_adwords_remarketing_lists/processor/data.ts index 83eae90aea..639e28403c 100644 --- a/test/integrations/destinations/google_adwords_remarketing_lists/processor/data.ts +++ b/test/integrations/destinations/google_adwords_remarketing_lists/processor/data.ts @@ -11,7 +11,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -120,7 +120,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -143,7 +143,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -239,7 +239,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -262,7 +262,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -358,7 +358,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -381,7 +381,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -456,7 +456,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -489,7 +489,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -546,7 +546,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -579,7 +579,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -635,7 +635,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -667,7 +667,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -711,7 +711,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -743,7 +743,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -807,7 +807,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -839,7 +839,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -2712,7 +2712,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -2735,7 +2735,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -2887,7 +2887,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -2967,7 +2967,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -2990,7 +2990,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -5400,7 +5400,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6700,7 +6700,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6723,7 +6723,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6857,7 +6857,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6880,7 +6880,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6944,7 +6944,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -6977,7 +6977,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -9387,7 +9387,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -10687,7 +10687,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -10710,7 +10710,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -10862,7 +10862,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -10942,7 +10942,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -10965,7 +10965,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11115,7 +11115,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11190,7 +11190,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11213,7 +11213,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11316,7 +11316,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11419,7 +11419,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11523,7 +11523,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11546,7 +11546,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11661,7 +11661,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11684,7 +11684,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11799,7 +11799,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11822,7 +11822,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11942,7 +11942,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -11965,7 +11965,7 @@ export const data = [ { metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, @@ -12082,7 +12082,7 @@ export const data = [ }, metadata: { secret: { - access_token: 'dummy-access', + accessToken: 'dummy-access', refresh_token: 'dummy-refresh', developer_token: 'dummy-dev-token', }, diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/router/audience.ts b/test/integrations/destinations/google_adwords_remarketing_lists/router/audience.ts new file mode 100644 index 0000000000..233f160ad3 --- /dev/null +++ b/test/integrations/destinations/google_adwords_remarketing_lists/router/audience.ts @@ -0,0 +1,129 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', + listId: '7090784486', + customerId: '7693729833', + loginCustomerId: '', + subAccount: false, + userSchema: ['email', 'phone', 'addressInfo'], + isHashRequired: true, + typeOfList: 'General', + }, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Config: {}, + }, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, +}; + +export const rETLAudienceRouterRequest: RouterTransformationRequest = { + input: [ + { + metadata: generateMetadata(1), + destination: destination, + message: { + userId: 'user 1', + anonymousId: 'anon-id-new', + event: 'event1', + type: 'audiencelist', + properties: { + listData: { + add: [ + { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + ], + }, + enablePartialFailure: true, + }, + context: { ip: '14.5.67.21', library: { name: 'http' } }, + timestamp: '2020-02-02T00:23:09.544Z', + }, + }, + { + metadata: generateMetadata(3), + destination: destination, + message: { + userId: 'user 1', + anonymousId: 'anon-id-new', + event: 'event1', + type: 'audiencelist', + properties: { + listData: { + remove: [ + { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + ], + }, + enablePartialFailure: true, + }, + context: { ip: '14.5.67.21', library: { name: 'http' } }, + timestamp: '2020-02-02T00:23:09.544Z', + }, + }, + { + metadata: generateMetadata(4), + destination: destination, + message: { + userId: 'user 1', + anonymousId: 'anon-id-new', + event: 'event1', + type: 'audiencelist', + properties: { + listData: { + remove: [ + { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + ], + add: [ + { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + ], + }, + enablePartialFailure: true, + }, + context: { ip: '14.5.67.21', library: { name: 'http' } }, + timestamp: '2020-02-02T00:23:09.544Z', + }, + }, + ], + destType: 'google_adwords_remarketing_lists', +}; + +module.exports = { + rETLAudienceRouterRequest, +}; diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/router/data.ts b/test/integrations/destinations/google_adwords_remarketing_lists/router/data.ts index f603d82c5e..35da4daff5 100644 --- a/test/integrations/destinations/google_adwords_remarketing_lists/router/data.ts +++ b/test/integrations/destinations/google_adwords_remarketing_lists/router/data.ts @@ -1,3 +1,6 @@ +import { rETLAudienceRouterRequest } from './audience'; +import { rETLRecordRouterRequest } from './record'; + export const data = [ { name: 'google_adwords_remarketing_lists', @@ -7,206 +10,7 @@ export const data = [ version: 'v0', input: { request: { - body: { - input: [ - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 1, - userId: 'u1', - }, - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - add: [ - { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - ], - }, - enablePartialFailure: true, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - }, - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 2, - userId: 'u1', - }, - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'userID', - }, - }, - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - add: [ - { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - thirdPartyUserId: 'useri1234', - }, - ], - }, - enablePartialFailure: true, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - }, - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 3, - userId: 'u1', - }, - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - remove: [ - { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - ], - }, - enablePartialFailure: true, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - }, - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 4, - userId: 'u1', - }, - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - remove: [ - { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - ], - add: [ - { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - ], - }, - enablePartialFailure: true, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - }, - ], - destType: 'google_adwords_remarketing_lists', - }, + body: rETLAudienceRouterRequest, method: 'POST', }, }, @@ -224,9 +28,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -272,13 +75,16 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', jobId: 1, - userId: 'u1', }, ], batched: false, @@ -294,64 +100,19 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, - }, - }, - { - batchedRequest: [ - { - version: '1', - type: 'REST', - method: 'POST', - endpoint: - 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', - headers: { - Authorization: 'Bearer abcd1234', - 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', - }, - params: { - listId: '7090784486', - customerId: '7693729833', - consent: { adPersonalization: 'UNSPECIFIED', adUserData: 'UNSPECIFIED' }, - }, - body: { - JSON: { - enablePartialFailure: true, - operations: [ - { create: { userIdentifiers: [{ thirdPartyUserId: 'useri1234' }] } }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - }, - ], - metadata: [ - { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 2, - userId: 'u1', - }, - ], - batched: false, - statusCode: 200, - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'userID', + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, { @@ -363,9 +124,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -411,13 +171,16 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', jobId: 3, - userId: 'u1', }, ], batched: false, @@ -433,6 +196,19 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, { @@ -444,9 +220,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -496,9 +271,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -544,13 +318,16 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', jobId: 4, - userId: 'u1', }, ], batched: false, @@ -566,6 +343,19 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, ], @@ -581,226 +371,7 @@ export const data = [ version: 'v0', input: { request: { - body: { - input: [ - { - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - action: 'insert', - context: { - ip: '14.5.67.21', - library: { - name: 'http', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - type: 'record', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 1, - userId: 'u1', - }, - }, - { - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - action: 'update', - context: { - ip: '14.5.67.21', - library: { - name: 'http', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - type: 'record', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 2, - userId: 'u2', - }, - }, - { - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - action: 'delete', - context: { - ip: '14.5.67.21', - library: { - name: 'http', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - type: 'record', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 3, - userId: 'u3', - }, - }, - { - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - action: 'lol', - context: { - ip: '14.5.67.21', - library: { - name: 'http', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - type: 'record', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 4, - userId: 'u4', - }, - }, - { - destination: { - Config: { - rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', - listId: '7090784486', - customerId: '7693729833', - loginCustomerId: '', - subAccount: false, - userSchema: ['email', 'phone', 'addressInfo'], - isHashRequired: true, - typeOfList: 'General', - }, - }, - message: { - action: 'insert', - context: { - ip: '14.5.67.21', - library: { - name: 'http', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - email: 'test@abc.com', - phone: '@09876543210', - firstName: 'test', - lastName: 'rudderlabs', - country: 'US', - postalCode: '1245', - }, - type: 'record', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', - }, - jobId: 5, - userId: 'u5', - }, - }, - ], - destType: 'google_adwords_remarketing_lists', - }, + body: rETLRecordRouterRequest, method: 'POST', }, }, @@ -818,9 +389,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -868,13 +438,16 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, - jobId: 3, - userId: 'u3', + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', + jobId: 1, }, ], batched: true, @@ -890,6 +463,19 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, { @@ -901,9 +487,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -969,22 +554,28 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, - jobId: 1, - userId: 'u1', + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', + jobId: 2, }, { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 3, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, - jobId: 5, - userId: 'u5', + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: true, @@ -1000,6 +591,19 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, { @@ -1011,9 +615,8 @@ export const data = [ endpoint: 'https://googleads.googleapis.com/v16/customers/7693729833/offlineUserDataJobs', headers: { - Authorization: 'Bearer abcd1234', + Authorization: 'Bearer default-accessToken', 'Content-Type': 'application/json', - 'developer-token': 'ijkl9101', }, params: { listId: '7090784486', @@ -1061,13 +664,16 @@ export const data = [ ], metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, - jobId: 2, - userId: 'u2', + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', + jobId: 4, }, ], batched: true, @@ -1083,18 +689,34 @@ export const data = [ isHashRequired: true, typeOfList: 'General', }, + DestinationDefinition: { + Config: {}, + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + }, + Enabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + IsConnectionEnabled: true, + IsProcessorEnabled: true, + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Transformations: [], + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', }, }, { metadata: [ { + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl9101', + accessToken: 'default-accessToken', }, - jobId: 4, - userId: 'u4', + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', + jobId: 5, }, ], batched: false, @@ -1103,10 +725,12 @@ export const data = [ statTags: { errorCategory: 'dataValidation', errorType: 'instrumentation', + destinationId: 'default-destinationId', destType: 'GOOGLE_ADWORDS_REMARKETING_LISTS', module: 'destination', implementation: 'native', feature: 'router', + workspaceId: 'default-workspaceId', }, }, ], diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/router/record.ts b/test/integrations/destinations/google_adwords_remarketing_lists/router/record.ts new file mode 100644 index 0000000000..743213bcc1 --- /dev/null +++ b/test/integrations/destinations/google_adwords_remarketing_lists/router/record.ts @@ -0,0 +1,158 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + rudderAccountId: '258Yea7usSKNpbkIaesL9oJ9iYw', + listId: '7090784486', + customerId: '7693729833', + loginCustomerId: '', + subAccount: false, + userSchema: ['email', 'phone', 'addressInfo'], + isHashRequired: true, + typeOfList: 'General', + }, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + DisplayName: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + Config: {}, + }, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, +}; + +export const rETLRecordRouterRequest: RouterTransformationRequest = { + input: [ + { + destination: destination, + message: { + action: 'insert', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + type: 'record', + }, + metadata: generateMetadata(2), + }, + { + destination: destination, + message: { + action: 'update', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + type: 'record', + }, + metadata: generateMetadata(4), + }, + { + destination: destination, + message: { + action: 'delete', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + type: 'record', + }, + metadata: generateMetadata(1), + }, + { + destination: destination, + message: { + action: 'lol', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + type: 'record', + }, + metadata: generateMetadata(5), + }, + { + destination: destination, + message: { + action: 'insert', + context: { + ip: '14.5.67.21', + library: { + name: 'http', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + email: 'test@abc.com', + phone: '@09876543210', + firstName: 'test', + lastName: 'rudderlabs', + country: 'US', + postalCode: '1245', + }, + type: 'record', + }, + metadata: generateMetadata(3), + }, + ], + destType: 'google_adwords_remarketing_lists', +}; + +module.exports = { + rETLRecordRouterRequest, +};