From 68ab695ad903d086eba1f7383addf71b2cf919b4 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Thu, 2 May 2024 21:55:53 +0530 Subject: [PATCH] fix: identify batching final --- .../v2/destinations/emarsys/procWorkflow.yaml | 2 +- .../v2/destinations/emarsys/rtWorkflow.yaml | 6 +- src/cdk/v2/destinations/emarsys/utils.js | 33 +- src/cdk/v2/destinations/emarsys/utils.test.js | 64 ++- src/constants/destinationCanonicalNames.js | 2 +- src/v0/destinations/emarsys/deleteUsers.js | 82 ++++ .../destinations/emarsys/router/data.ts | 390 ++++++++---------- 7 files changed, 315 insertions(+), 264 deletions(-) create mode 100644 src/v0/destinations/emarsys/deleteUsers.js diff --git a/src/cdk/v2/destinations/emarsys/procWorkflow.yaml b/src/cdk/v2/destinations/emarsys/procWorkflow.yaml index e8c0a693de..d8a84959b3 100644 --- a/src/cdk/v2/destinations/emarsys/procWorkflow.yaml +++ b/src/cdk/v2/destinations/emarsys/procWorkflow.yaml @@ -55,7 +55,7 @@ steps: ref: https://dev.emarsys.com/docs/core-api-reference/fl0xx6rwfbwqb-trigger-an-external-event condition: $.outputs.messageType === {{$.EventType.TRACK}} template: | - const integrationObject = $.getIntegrationsObj(message, 'emersys'); + const integrationObject = $.getIntegrationsObj(^.message, 'emersys'); const emersysIdentifierId = integrationObject?.customIdentifierId || ^.destination.Config.emersysCustomIdentifier || $.EMAIL_FIELD_ID; const payload = { key_id: emersysIdentifierId , diff --git a/src/cdk/v2/destinations/emarsys/rtWorkflow.yaml b/src/cdk/v2/destinations/emarsys/rtWorkflow.yaml index 84e31d54a2..36df10bb43 100644 --- a/src/cdk/v2/destinations/emarsys/rtWorkflow.yaml +++ b/src/cdk/v2/destinations/emarsys/rtWorkflow.yaml @@ -30,10 +30,10 @@ steps: - name: batchSuccessfulEvents description: Batches the successfulEvents - debug: true template: | - $.batchResponseBuilder($.outputs.successfulEvents); + $.context.batchedPayload = $.batchResponseBuilder($.outputs.successfulEvents); + console.log("batchedPayload",JSON.stringify($.context.batchedPayload)); - name: finalPayload template: | - [...$.outputs.failedEvents, ...$.outputs.batchSuccessfulEvents] + [...$.outputs.failedEvents, ...$.context.batchedPayload] diff --git a/src/cdk/v2/destinations/emarsys/utils.js b/src/cdk/v2/destinations/emarsys/utils.js index 49ea541213..9d7faff01b 100644 --- a/src/cdk/v2/destinations/emarsys/utils.js +++ b/src/cdk/v2/destinations/emarsys/utils.js @@ -48,13 +48,13 @@ const buildHeader = (destConfig) => { }; }; -const buildIdentifyPayload = (message, destination) => { +const buildIdentifyPayload = (message, destConfig) => { let destinationPayload; const { fieldMapping, emersysCustomIdentifier, discardEmptyProperties, defaultContactList } = - destination.Config; + destConfig; const payload = {}; - const integrationObject = getIntegrationsObj(message, 'emersys'); + const integrationObject = getIntegrationsObj(message, 'emarsys'); const finalContactList = integrationObject?.contactListId || defaultContactList; if (!isDefinedAndNotNullAndNotEmpty(finalContactList)) { @@ -65,9 +65,10 @@ const buildIdentifyPayload = (message, destination) => { if (fieldMapping) { fieldMapping.forEach((trait) => { const { rudderProperty, emersysProperty } = trait; - const value = - getValueFromMessage(message.traits, rudderProperty) || - getValueFromMessage(message.context.traits, rudderProperty); + const value = getValueFromMessage(message, [ + `traits.${rudderProperty}`, + `context.traits.${rudderProperty}`, + ]); if (value) { payload[emersysProperty] = value; } @@ -99,7 +100,6 @@ const buildIdentifyPayload = (message, destination) => { 'Either configured custom contact identifier value or default identifier email value is missing', ); } - return { eventType: message.type, destinationPayload }; }; @@ -248,17 +248,16 @@ const createIdentifyBatches = (events) => { const groupedIdentifyPayload = lodash.groupBy( events, (item) => - `${item.message.body.JSON.destinationPayload.key_id}-${item.message.body.JSON.destinationPayload.contact_list_id}`, + `${item.message[0].body.JSON.destinationPayload.key_id}-${item.message[0].body.JSON.destinationPayload.contact_list_id}`, ); - return lodash.flatMap(groupedIdentifyPayload, (group) => { - const firstItem = group[0].message.body.JSON.destinationPayload; + const firstItem = group[0].message[0].body.JSON.destinationPayload; // eslint-disable-next-line @typescript-eslint/naming-convention const { key_id, contact_list_id } = firstItem; const allContacts = lodash.flatMap( group, - (item) => item.message.body.JSON.destinationPayload.contacts, + (item) => item.message[0].body.JSON.destinationPayload.contacts, ); const initialChunks = lodash.chunk(allContacts, MAX_BATCH_SIZE); const finalChunks = lodash.flatMap(initialChunks, ensureSizeConstraints); @@ -306,9 +305,10 @@ const createTrackBatches = (events) => ({ metadata: events[0].metadata, }); const formatIdentifyPayloadsWithEndpoint = (combinedPayloads, endpointUrl = '') => - combinedPayloads.map((payload) => ({ + combinedPayloads.map((singleCombinedPayload) => ({ endpoint: endpointUrl, - payload, + payload: singleCombinedPayload.payload, + metadata: singleCombinedPayload.metadata, })); const buildBatchedRequest = (batches, method, constants, batchedStatus = true) => @@ -349,12 +349,12 @@ const batchResponseBuilder = (successfulEvents) => { const typedEventGroups = lodash.groupBy( successfulEvents, - (event) => event.message.body.JSON.eventType, + (event) => event.message[0].body.JSON.eventType, ); Object.keys(typedEventGroups).forEach((eachEventGroup) => { switch (eachEventGroup) { case EventType.IDENTIFY: - batchesOfIdentifyEvents = createIdentifyBatches(eachEventGroup); + batchesOfIdentifyEvents = createIdentifyBatches(typedEventGroups[eachEventGroup]); groupedSuccessfulPayload.identify.batches = formatIdentifyPayloadsWithEndpoint( batchesOfIdentifyEvents, 'https://api.emarsys.net/api/v2/contact/?create_if_not_exists=1', @@ -371,6 +371,7 @@ const batchResponseBuilder = (successfulEvents) => { } return groupedSuccessfulPayload; }); + console.log('groupedSuccessfulPayload', JSON.stringify(groupedSuccessfulPayload)); // Process each identify batch if (groupedSuccessfulPayload.identify) { const identifyBatches = buildBatchedRequest( @@ -400,7 +401,7 @@ const batchResponseBuilder = (successfulEvents) => { ); finaloutput.push(...trackBatches); } - + console.log('FINAL', JSON.stringify(finaloutput)); return finaloutput; }; diff --git a/src/cdk/v2/destinations/emarsys/utils.test.js b/src/cdk/v2/destinations/emarsys/utils.test.js index d9ce90097e..15147d9cdd 100644 --- a/src/cdk/v2/destinations/emarsys/utils.test.js +++ b/src/cdk/v2/destinations/emarsys/utils.test.js @@ -66,15 +66,13 @@ describe('buildIdentifyPayload', () => { }, }; const destination = { - Config: { - fieldMapping: [ - { rudderProperty: 'firstName', emersysProperty: '1' }, - { rudderProperty: 'lastName', emersysProperty: '2' }, - { rudderProperty: 'email', emersysProperty: '3' }, - { rudderProperty: 'optin', emersysProperty: '31' }, - ], - defaultContactList: 'dummyContactList', - }, + fieldMapping: [ + { rudderProperty: 'firstName', emersysProperty: '1' }, + { rudderProperty: 'lastName', emersysProperty: '2' }, + { rudderProperty: 'email', emersysProperty: '3' }, + { rudderProperty: 'optin', emersysProperty: '31' }, + ], + defaultContactList: 'dummyContactList', }; const expectedPayload = { contact_list_id: 'dummyContactList', @@ -106,15 +104,13 @@ describe('buildIdentifyPayload', () => { }, }; const destination = { - Config: { - fieldMapping: [ - { rudderProperty: 'firstName', emersysProperty: '1' }, - { rudderProperty: 'lastName', emersysProperty: '2' }, - { rudderProperty: 'email', emersysProperty: '3' }, - { rudderProperty: 'optin', emersysProperty: '31' }, - ], - defaultContactList: 'dummyList', - }, + fieldMapping: [ + { rudderProperty: 'firstName', emersysProperty: '1' }, + { rudderProperty: 'lastName', emersysProperty: '2' }, + { rudderProperty: 'email', emersysProperty: '3' }, + { rudderProperty: 'optin', emersysProperty: '31' }, + ], + defaultContactList: 'dummyList', }; expect(() => { buildIdentifyPayload(message, destination); @@ -132,14 +128,12 @@ describe('buildIdentifyPayload', () => { }, }; const destination = { - Config: { - fieldMapping: [ - { rudderProperty: 'firstName', emersysProperty: '1' }, - { rudderProperty: 'lastName', emersysProperty: '2' }, - { rudderProperty: 'email', emersysProperty: '3' }, - { rudderProperty: 'optin', emersysProperty: '31' }, - ], - }, + fieldMapping: [ + { rudderProperty: 'firstName', emersysProperty: '1' }, + { rudderProperty: 'lastName', emersysProperty: '2' }, + { rudderProperty: 'email', emersysProperty: '3' }, + { rudderProperty: 'optin', emersysProperty: '31' }, + ], }; expect(() => { buildIdentifyPayload(message, destination); @@ -158,22 +152,20 @@ describe('buildIdentifyPayload', () => { optin: 1, }, integrations: { - EMERSYS: { + EMARSYS: { customIdentifierId: 1, contactListId: 'objectListId', }, }, }; const destination = { - Config: { - fieldMapping: [ - { rudderProperty: 'firstName', emersysProperty: '1' }, - { rudderProperty: 'lastName', emersysProperty: '2' }, - { rudderProperty: 'email', emersysProperty: '3' }, - { rudderProperty: 'optin', emersysProperty: '31' }, - ], - defaultContactList: 'dummyContactList', - }, + fieldMapping: [ + { rudderProperty: 'firstName', emersysProperty: '1' }, + { rudderProperty: 'lastName', emersysProperty: '2' }, + { rudderProperty: 'email', emersysProperty: '3' }, + { rudderProperty: 'optin', emersysProperty: '31' }, + ], + defaultContactList: 'dummyContactList', }; const expectedPayload = { contact_list_id: 'objectListId', diff --git a/src/constants/destinationCanonicalNames.js b/src/constants/destinationCanonicalNames.js index b620146230..19136eab59 100644 --- a/src/constants/destinationCanonicalNames.js +++ b/src/constants/destinationCanonicalNames.js @@ -166,7 +166,7 @@ const DestCanonicalNames = { ], koala: ['Koala', 'koala', 'KOALA'], bloomreach: ['Bloomreach', 'bloomreach', 'BLOOMREACH'], - emersys: ['EMARSYS', 'Emarsys', 'emarsys'], + emarsys: ['EMARSYS', 'Emarsys', 'emarsys'], }; module.exports = { DestHandlerMap, DestCanonicalNames }; diff --git a/src/v0/destinations/emarsys/deleteUsers.js b/src/v0/destinations/emarsys/deleteUsers.js new file mode 100644 index 0000000000..01044adcd1 --- /dev/null +++ b/src/v0/destinations/emarsys/deleteUsers.js @@ -0,0 +1,82 @@ +const { NetworkError, ConfigurationError } = require('@rudderstack/integrations-lib'); +const { httpPOST } = require('../../../adapters/network'); +const { + processAxiosResponse, + getDynamicErrorType, +} = require('../../../adapters/utils/networkUtils'); +const { isHttpStatusSuccess } = require('../../util'); +const { executeCommonValidations } = require('../../util/regulation-api'); +const tags = require('../../util/tags'); +const { getUserIdBatches } = require('../../util/deleteUserUtils'); +const { JSON_MIME_TYPE } = require('../../util/constant'); + +/** + * This function will help to delete the users one by one from the userAttributes array. + * @param {*} userAttributes Array of objects with userId, email and phone + * @param {*} config Destination.Config provided in dashboard + * @returns + */ +const userDeletionHandler = async (userAttributes, config) => { + const { apiKey } = config; + + if (!apiKey) { + throw new ConfigurationError('Api Key is required for user deletion'); + } + + const endpoint = 'https://api.sprig.com/v2/purge/visitors'; + const headers = { + Accept: JSON_MIME_TYPE, + 'Content-Type': JSON_MIME_TYPE, + Authorization: `API-Key ${apiKey}`, + }; + /** + * userIdBatches = [[u1,u2,u3,...batchSize],[u1,u2,u3,...batchSize]...] + * Ref doc : https://docs.sprig.com/reference/post-v2-purge-visitors-1 + */ + const userIdBatches = getUserIdBatches(userAttributes, 100); + // Note: we will only get 400 status code when no user deletion is present for given userIds so we will not throw error in that case + // eslint-disable-next-line no-restricted-syntax + for (const curBatch of userIdBatches) { + // eslint-disable-next-line no-await-in-loop + const deletionResponse = await httpPOST( + endpoint, + { + userIds: curBatch, + }, + { + headers, + }, + { + destType: 'sprig', + feature: 'deleteUsers', + endpointPath: '/purge/visitors', + requestMethod: 'POST', + module: 'deletion', + }, + ); + const handledDelResponse = processAxiosResponse(deletionResponse); + if (!isHttpStatusSuccess(handledDelResponse.status) && handledDelResponse.status !== 400) { + throw new NetworkError( + 'User deletion request failed', + handledDelResponse.status, + { + [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(handledDelResponse.status), + [tags.TAG_NAMES.STATUS]: handledDelResponse.status, + }, + handledDelResponse, + ); + } + } + + return { + statusCode: 200, + status: 'successful', + }; +}; +const processDeleteUsers = async (event) => { + const { userAttributes, config } = event; + executeCommonValidations(userAttributes); + const resp = await userDeletionHandler(userAttributes, config); + return resp; +}; +module.exports = { processDeleteUsers }; diff --git a/test/integrations/destinations/emarsys/router/data.ts b/test/integrations/destinations/emarsys/router/data.ts index fe6e594738..32f5782474 100644 --- a/test/integrations/destinations/emarsys/router/data.ts +++ b/test/integrations/destinations/emarsys/router/data.ts @@ -12,8 +12,16 @@ const config = { ], fieldMapping: [ { - from: 'Email', - to: '3', + rudderProperty: 'email', + emersysProperty: '3', + }, + { + rudderProperty: 'firstName', + emersysProperty: '1', + }, + { + rudderProperty: 'lastName', + emersysProperty: '2', }, ], oneTrustCookieCategories: [ @@ -57,41 +65,25 @@ export const data = [ input: [ { message: { - type: 'identify', - sentAt: '2020-08-14T05: 30: 30.118Z', channel: 'web', context: { - source: 'test', - userAgent: 'chrome', traits: { - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - email: 'abc@gmail.com', - phone: '+1234589947', - gender: 'non-binary', - db: '19950715', - lastname: 'Rudderlabs', - firstName: 'Test', - address: { - city: 'Kolkata', - state: 'WB', - zip: '700114', - country: 'IN', - }, - }, - device: { - advertisingId: 'abc123', - }, - library: { - name: 'rudder-sdk-ruby-sync', - version: '1.0.6', + email: 'testone@gmail.com', + firstName: 'test', + lastName: 'one', }, }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2024-02-10T12:16:07.251Z', - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + type: 'identify', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', integrations: { All: true, }, + sentAt: '2019-10-14T09:03:22.563Z', }, metadata: { sourceType: '', @@ -106,41 +98,25 @@ export const data = [ }, { message: { - type: 'identify', - sentAt: '2020-08-14T05: 30: 30.118Z', channel: 'web', context: { - source: 'test', - userAgent: 'chrome', traits: { - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - email: 'abc@gmail.com', - phone: '+1234589947', - gender: 'non-binary', - db: '19950715', - lastname: 'Rudderlabs', - firstName: 'Test', - address: { - city: 'Kolkata', - state: 'WB', - zip: '700114', - country: 'IN', - }, - }, - device: { - advertisingId: 'abc123', - }, - library: { - name: 'rudder-sdk-ruby-sync', - version: '1.0.6', + email: 'testtwo@gmail.com', + firstName: 'test', + lastName: 'one', }, }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2024-02-10T12:16:07.251Z', - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + type: 'identify', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', integrations: { All: true, }, + sentAt: '2019-10-14T09:03:22.563Z', }, metadata: { sourceType: '', @@ -155,46 +131,72 @@ export const data = [ }, { message: { - type: 'identify', - sentAt: '2020-08-14T05: 30: 30.118Z', channel: 'web', context: { - source: 'test', - userAgent: 'chrome', traits: { - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - phone: '+1234589947', - gender: 'non-binary', - db: '19950715', - lastname: 'Rudderlabs', - firstName: 'Test', - address: { - city: 'Kolkata', - state: 'WB', - zip: '700114', - country: 'IN', - }, + email: 'testtwo@gmail.com', + firstName: 'test', + lastName: 'one', }, - device: { - advertisingId: 'abc123', + }, + type: 'identify', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', + integrations: { + All: true, + EMARSYS: { + contactListId: 'dummy2', + customIdentifierId: '1', }, - library: { - name: 'rudder-sdk-ruby-sync', - version: '1.0.6', + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + metadata: { + sourceType: '', + destinationType: '', + namespace: '', + jobId: 3, + secret: { + accessToken: 'dummyToken', + }, + }, + destination: commonDestination, + }, + { + message: { + channel: 'web', + context: { + traits: { + email: 'testtwo@gmail.com', + firstName: 'test', + lastName: 'one', }, }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2024-02-10T12:16:07.251Z', - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + type: 'identify', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', integrations: { All: true, + EMARSYS: { + contactListId: 'dummy2', + customIdentifierId: '2', + }, }, + sentAt: '2019-10-14T09:03:22.563Z', }, metadata: { sourceType: '', destinationType: '', namespace: '', - jobId: 3, + jobId: 4, secret: { accessToken: 'dummyToken', }, @@ -215,138 +217,41 @@ export const data = [ { metadata: [ { - sourceType: '', destinationType: '', + jobId: 1, namespace: '', - jobId: 3, secret: { accessToken: 'dummyToken', }, + sourceType: '', }, - ], - destination: { - ID: '12335', - Name: 'sample-destination', - DestinationDefinition: { - ID: '123', - Name: 'emarsys', - DisplayName: 'emarsys', - Config: { - cdkV2Enabled: true, + { + destinationType: '', + jobId: 2, + namespace: '', + secret: { + accessToken: 'dummyToken', }, + sourceType: '', }, - WorkspaceID: '123', - Transformations: [], - Config: config, - Enabled: true, - }, - batched: false, - statusCode: 400, - error: - '[emarsys] no matching user id found. Please provide at least one of the following: email, emersysFirstPartyAdsTrackingUUID, acxiomId, oracleMoatId', - statTags: { - destType: 'emarsys', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'router', - implementation: 'cdkV2', - module: 'destination', - }, - }, - { + ], batchedRequest: { body: { JSON: { - elements: [ - { - conversionHappenedAt: 1707567367251, - eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - conversionValue: { - currencyCode: 'USD', - amount: '50', - }, - user: { - userIds: [ - { - idType: 'SHA256_EMAIL', - idValue: - '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - }, - ], - userInfo: { - firstName: 'Test', - lastName: 'Rudderlabs', - }, - }, - conversion: 'urn:lla:llaPartnerConversion:1234567', - }, - { - conversionHappenedAt: 1707567367251, - eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - conversionValue: { - currencyCode: 'USD', - amount: '50', - }, - user: { - userIds: [ - { - idType: 'SHA256_EMAIL', - idValue: - '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - }, - ], - userInfo: { - firstName: 'Test', - lastName: 'Rudderlabs', - }, - }, - conversion: 'urn:lla:llaPartnerConversion:34567', - }, + key_id: '3', + contacts: [ { - conversionHappenedAt: 1707567367251, - eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - conversionValue: { - currencyCode: 'USD', - amount: '50', - }, - user: { - userIds: [ - { - idType: 'SHA256_EMAIL', - idValue: - '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - }, - ], - userInfo: { - firstName: 'Test', - lastName: 'Rudderlabs', - }, - }, - conversion: 'urn:lla:llaPartnerConversion:1234567', + '3': 'testone@gmail.com', + '1': 'test', + '2': 'one', }, { - conversionHappenedAt: 1707567367251, - eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - conversionValue: { - currencyCode: 'USD', - amount: '50', - }, - user: { - userIds: [ - { - idType: 'SHA256_EMAIL', - idValue: - '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - }, - ], - userInfo: { - firstName: 'Test', - lastName: 'Rudderlabs', - }, - }, - conversion: 'urn:lla:llaPartnerConversion:34567', + '3': 'testtwo@gmail.com', + '1': 'test', + '2': 'one', }, ], + contact_list_id: 'dummy', }, JSON_ARRAY: {}, XML: {}, @@ -354,38 +259,109 @@ export const data = [ }, version: '1', type: 'REST', - method: 'POST', - endpoint: 'https://api.emarsys.com/rest/conversionEvents', + method: 'PUT', + endpoint: 'https://api.emarsys.net/api/v2/contact/?create_if_not_exists=1', headers: { 'Content-Type': 'application/json', - 'X-RestLi-Method': 'BATCH_CREATE', - 'X-Restli-Protocol-Version': '2.0.0', - 'emarsys-Version': '202402', - Authorization: 'Bearer dummyToken', + Accept: 'application/json', + 'X-WSSE': + 'UsernameToken Username="dummy", PasswordDigest="OWM2ODlmYjZiMDA0YTQwZjc1NjkyOWFiZTA1MTQ0ZmUwOGYyYWQ2NA==", Nonce="8c02af01eb527f450340bb82ebd40dde", Created="2024-05-02T15:41:20.529Z"', }, params: {}, files: {}, }, + batched: true, + statusCode: 200, + destination: commonDestination, + }, + { metadata: [ { - sourceType: '', destinationType: '', + jobId: 3, namespace: '', - jobId: 1, secret: { accessToken: 'dummyToken', }, + sourceType: '', }, + ], + batchedRequest: { + body: { + JSON: { + key_id: '1', + contacts: [ + { + '3': 'testtwo@gmail.com', + '1': 'test', + '2': 'one', + }, + ], + contact_list_id: 'dummy2', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'PUT', + endpoint: 'https://api.emarsys.net/api/v2/contact/?create_if_not_exists=1', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + 'X-WSSE': + 'UsernameToken Username="dummy", PasswordDigest="OWM2ODlmYjZiMDA0YTQwZjc1NjkyOWFiZTA1MTQ0ZmUwOGYyYWQ2NA==", Nonce="8c02af01eb527f450340bb82ebd40dde", Created="2024-05-02T15:41:20.529Z"', + }, + params: {}, + files: {}, + }, + batched: true, + statusCode: 200, + destination: commonDestination, + }, + { + metadata: [ { - sourceType: '', destinationType: '', + jobId: 4, namespace: '', - jobId: 2, secret: { accessToken: 'dummyToken', }, + sourceType: '', }, ], + batchedRequest: { + body: { + JSON: { + key_id: '2', + contacts: [ + { + '3': 'testtwo@gmail.com', + '1': 'test', + '2': 'one', + }, + ], + contact_list_id: 'dummy2', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'PUT', + endpoint: 'https://api.emarsys.net/api/v2/contact/?create_if_not_exists=1', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + 'X-WSSE': + 'UsernameToken Username="dummy", PasswordDigest="OWM2ODlmYjZiMDA0YTQwZjc1NjkyOWFiZTA1MTQ0ZmUwOGYyYWQ2NA==", Nonce="8c02af01eb527f450340bb82ebd40dde", Created="2024-05-02T15:41:20.529Z"', + }, + params: {}, + files: {}, + }, batched: true, statusCode: 200, destination: commonDestination,