Skip to content

Commit

Permalink
fix: root level batching stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Sep 7, 2024
1 parent ad18883 commit d6577e3
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 94 deletions.
4 changes: 1 addition & 3 deletions src/v0/destinations/x_audience/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const jsonSize = require('json-size');
const { OAuthSecretError } = require('@rudderstack/integrations-lib');
const {
defaultRequestConfig,
defaultPostRequestConfig,
getSuccessRespEvents,
removeUndefinedAndNullAndEmptyValues,
} = require('../../util');
Expand Down Expand Up @@ -34,8 +33,7 @@ const buildResponseWithJSON = (payload, config, metadata) => {
':audience_id',
config.audienceId,
);
response.method = defaultPostRequestConfig.requestMethod;
response.body.JSON = payload;
response.body.JSON_ARRAY = { batch: JSON.stringify(payload) };
// required to be in accordance with oauth package
const request = {
url: response.endpoint,
Expand Down
104 changes: 54 additions & 50 deletions test/integrations/destinations/x_audience/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,43 @@ export const data = [
},
params: {},
body: {
JSON: [
{
operation_type: 'Update',
params: {
effective_at: '2024-05-15T00:00:00Z',
expires_at: '2025-05-15T00:00:00Z',
users: [
{
email: [
'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d',
'27a1b87036e9b0f43235026e7cb1493f1838b6fe41965ea04486d82e499f8401',
],
handle: [
'771c7b0ff2eff313009a81739307c3f7cde375acd7902b11061266a899a375f6',
'7bde3c2d41eab9043df37c9adf4f5f7591c632340d1cabc894e438e881fdd5f6',
],
device_id: [
'85a598fd6c8834f2d4da3d6886bb53d0032021e137307ec91d3f0da78e9bfa5b',
'936444046bea8b5d9de6bcae59b6f196ea4bb59945bc93e84bc9533dbf3e01c0',
],
phone_number: [
'76742d946d9f6d0c844da5648e461896227782ccf1cd0db64573f39dbd92e05f',
'69c3bf36e0476c08a883fd6a995f67fc6d362c865549312fb5170737945fd073',
],
partner_user_id: ['puid1', 'puid2'],
twitter_id: [
'a70d41727df61f21ce0ec81cca51c58f516b6151275d9293d7437bf15fa22e0d',
'e39994d056999d79ff5a35b02cf2af946fc14bd7bd1b799b58619796584af02f',
],
},
],
JSON: {},
JSON_ARRAY: {
batch: JSON.stringify([
{
operation_type: 'Update',
params: {
effective_at: '2024-05-15T00:00:00Z',
expires_at: '2025-05-15T00:00:00Z',
users: [
{
email: [
'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d',
'27a1b87036e9b0f43235026e7cb1493f1838b6fe41965ea04486d82e499f8401',
],
phone_number: [
'76742d946d9f6d0c844da5648e461896227782ccf1cd0db64573f39dbd92e05f',
'69c3bf36e0476c08a883fd6a995f67fc6d362c865549312fb5170737945fd073',
],
handle: [
'771c7b0ff2eff313009a81739307c3f7cde375acd7902b11061266a899a375f6',
'7bde3c2d41eab9043df37c9adf4f5f7591c632340d1cabc894e438e881fdd5f6',
],
device_id: [
'85a598fd6c8834f2d4da3d6886bb53d0032021e137307ec91d3f0da78e9bfa5b',
'936444046bea8b5d9de6bcae59b6f196ea4bb59945bc93e84bc9533dbf3e01c0',
],
twitter_id: [
'a70d41727df61f21ce0ec81cca51c58f516b6151275d9293d7437bf15fa22e0d',
'e39994d056999d79ff5a35b02cf2af946fc14bd7bd1b799b58619796584af02f',
],
partner_user_id: ['puid1', 'puid2'],
},
],
},
},
},
],
JSON_ARRAY: {},
]),
},
XML: {},
FORM: {},
},
Expand Down Expand Up @@ -145,23 +147,25 @@ export const data = [
},
params: {},
body: {
JSON: [
{
operation_type: 'Delete',
params: {
users: [
{
email: ['[email protected]', '[email protected]'],
handle: ['@abc', '@xyz'],
partner_user_id: ['puid1', 'puid2'],
phone_number: ['98765433232', '21323'],
twitter_id: ['tid1', 'tid2'],
},
],
JSON: {},
JSON_ARRAY: {
batch: JSON.stringify([
{
operation_type: 'Delete',
params: {
users: [
{
email: ['[email protected]', '[email protected]'],
phone_number: ['98765433232', '21323'],
handle: ['@abc', '@xyz'],
twitter_id: ['tid1', 'tid2'],
partner_user_id: ['puid1', 'puid2'],
},
],
},
},
},
],
JSON_ARRAY: {},
]),
},
XML: {},
FORM: {},
},
Expand Down
86 changes: 45 additions & 41 deletions test/integrations/destinations/x_audience/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,34 @@ export const data = [
},
params: {},
body: {
JSON: [
{
operation_type: 'Delete',
params: {
users: [
{
email: ['[email protected]'],
},
],
JSON: {},
JSON_ARRAY: {
batch: JSON.stringify([
{
operation_type: 'Delete',
params: {
users: [
{
email: ['[email protected]'],
},
],
},
},
},
{
operation_type: 'Update',
params: {
users: [
{
email: ['[email protected]'],
},
{
email: ['[email protected]'],
},
],
{
operation_type: 'Update',
params: {
users: [
{
email: ['[email protected]'],
},
{
email: ['[email protected]'],
},
],
},
},
},
],
JSON_ARRAY: {},
]),
},
XML: {},
FORM: {},
},
Expand All @@ -164,24 +166,26 @@ export const data = [
},
params: {},
body: {
JSON: [
{
operation_type: 'Update',
params: {
expires_at: 'some date',
effective_at: 'some effective date',
users: [
{
email: ['[email protected]'],
},
{
email: ['[email protected]'],
},
],
JSON: {},
JSON_ARRAY: {
batch: JSON.stringify([
{
operation_type: 'Update',
params: {
effective_at: 'some effective date',
expires_at: 'some date',
users: [
{
email: ['[email protected]'],
},
{
email: ['[email protected]'],
},
],
},
},
},
],
JSON_ARRAY: {},
]),
},
XML: {},
FORM: {},
},
Expand Down

0 comments on commit d6577e3

Please sign in to comment.