From 618161702972b81dbb3a8360c4f26681c201a85b Mon Sep 17 00:00:00 2001 From: Vinay Teki Date: Thu, 12 Dec 2024 11:00:52 +0530 Subject: [PATCH] fix: changed body formatting based on server expectations --- src/v0/destinations/webhook/utils.js | 6 +- .../destinations/webhook/processor/data.ts | 96 ++++++++++++++++++- 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/src/v0/destinations/webhook/utils.js b/src/v0/destinations/webhook/utils.js index 08ab765ec5..e0f5995c8a 100644 --- a/src/v0/destinations/webhook/utils.js +++ b/src/v0/destinations/webhook/utils.js @@ -1,5 +1,5 @@ const { isFeatureEnabled } = require('feature-flag-sdk'); -const { getXMLPayload, getFORMPayload } = require('../../../cdk/v2/destinations/http/utils'); +const { getXMLPayload } = require('../../../cdk/v2/destinations/http/utils'); const { EventType } = require('../../../constants'); const { getFieldValueFromMessage, flattenJson } = require('../../util'); @@ -24,9 +24,9 @@ const getFormattedPayload = (headers, payload) => { switch (contentTypeSimplified) { case XML: - return { payload: getXMLPayload(payload), contentTypeSimplified }; + return { payload: { payload: getXMLPayload(payload) }, contentTypeSimplified }; case FORM: - return { payload: getFORMPayload(payload), contentTypeSimplified }; + return { payload, contentTypeSimplified }; default: return { payload, contentTypeSimplified }; } diff --git a/test/integrations/destinations/webhook/processor/data.ts b/test/integrations/destinations/webhook/processor/data.ts index 2835e1c67d..16096c8f5b 100644 --- a/test/integrations/destinations/webhook/processor/data.ts +++ b/test/integrations/destinations/webhook/processor/data.ts @@ -144,7 +144,96 @@ export const data = [ JSON: {}, JSON_ARRAY: {}, XML: {}, - FORM: 'anonymousId=c82cbdff-e5be-4009-ac78-cdeea09ab4b1&context=&event=spin_result&integrations=&message_id=a80f82be-9bdc-4a9f-b2a5-15621ee41df8&properties=×tamp=2019-09-01T15%3A46%3A51.693229%2B05%3A30&type=track&user_properties=', + FORM: { + anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + context: { + device: { + id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + manufacturer: 'Xiaomi', + model: 'Redmi 6', + name: 'xiaomi', + }, + network: { + carrier: 'Banglalink', + }, + os: { + name: 'android', + version: '8.1.0', + }, + traits: { + address: { + city: 'Dhaka', + country: 'Bangladesh', + }, + anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + }, + }, + event: 'spin_result', + integrations: { + All: true, + }, + message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8', + properties: { + additional_bet_index: 0, + battle_id: 'N/A', + bet_amount: 9, + bet_level: 1, + bet_multiplier: 1, + coin_balance: 9466052, + current_module_name: 'CasinoGameModule', + days_in_game: 0, + extra_param: 'N/A', + fb_profile: '0', + featureGameType: 'N/A', + game_fps: 30, + game_id: 'fireEagleBase', + game_name: 'FireEagleSlots', + gem_balance: 0, + graphicsQuality: 'HD', + idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252', + internetReachability: 'ReachableViaLocalAreaNetwork', + isLowEndDevice: 'False', + is_auto_spin: 'False', + is_turbo: 'False', + isf: 'False', + ishighroller: 'False', + jackpot_win_amount: 90, + jackpot_win_type: 'Silver', + level: 6, + lifetime_gem_balance: 0, + no_of_spin: 1, + player_total_battles: 0, + player_total_shields: 0, + start_date: '2019-08-01', + total_payments: 0, + tournament_id: 'T1561970819', + userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + versionSessionCount: 2, + win_amount: 0, + }, + timestamp: '2019-09-01T15:46:51.693229+05:30', + type: 'track', + user_properties: { + coin_balance: 9466052, + current_module_name: 'CasinoGameModule', + fb_profile: '0', + game_fps: 30, + game_name: 'FireEagleSlots', + gem_balance: 0, + graphicsQuality: 'HD', + idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252', + internetReachability: 'ReachableViaLocalAreaNetwork', + isLowEndDevice: false, + level: 6, + lifetime_gem_balance: 0, + player_total_battles: 0, + player_total_shields: 0, + start_date: '2019-08-01', + total_payments: 0, + userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + versionSessionCount: 2, + }, + }, }, version: '1', userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', @@ -311,7 +400,10 @@ export const data = [ body: { JSON: {}, JSON_ARRAY: {}, - XML: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1df16bffa-5c3d-4fbb-9bce-3bab098129a7RXiaomiRedmi 6xiaomiBanglalinkandroid8.1.0
DhakaBangladesh
c82cbdff-e5be-4009-ac78-cdeea09ab4b1
spin_resulttruea80f82be-9bdc-4a9f-b2a5-15621ee41df80N/A9119466052CasinoGameModule0N/A0N/A30fireEagleBaseFireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkFalseFalseFalseFalseFalse90Silver601002019-08-010T1561970819c82cbdff-e5be-4009-ac78-cdeea09ab4b1202019-09-01T15:46:51.693229+05:30track9466052CasinoGameModule030FireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkfalse60002019-08-010c82cbdff-e5be-4009-ac78-cdeea09ab4b12', + XML: { + payload: + 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1df16bffa-5c3d-4fbb-9bce-3bab098129a7RXiaomiRedmi 6xiaomiBanglalinkandroid8.1.0
DhakaBangladesh
c82cbdff-e5be-4009-ac78-cdeea09ab4b1
spin_resulttruea80f82be-9bdc-4a9f-b2a5-15621ee41df80N/A9119466052CasinoGameModule0N/A0N/A30fireEagleBaseFireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkFalseFalseFalseFalseFalse90Silver601002019-08-010T1561970819c82cbdff-e5be-4009-ac78-cdeea09ab4b1202019-09-01T15:46:51.693229+05:30track9466052CasinoGameModule030FireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkfalse60002019-08-010c82cbdff-e5be-4009-ac78-cdeea09ab4b12', + }, FORM: {}, }, version: '1',