Skip to content

Commit

Permalink
fix: changed body formatting based on server expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayteki95 committed Dec 12, 2024
1 parent 41f700a commit 6181617
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/v0/destinations/webhook/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { isFeatureEnabled } = require('feature-flag-sdk');

Check failure on line 1 in src/v0/destinations/webhook/utils.js

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

Unable to resolve path to module 'feature-flag-sdk'

Check failure on line 1 in src/v0/destinations/webhook/utils.js

View workflow job for this annotation

GitHub Actions / Code Coverage

Unable to resolve path to module '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');

Expand All @@ -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 };
}
Expand Down
96 changes: 94 additions & 2 deletions test/integrations/destinations/webhook/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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=&timestamp=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',
Expand Down Expand Up @@ -311,7 +400,10 @@ export const data = [
body: {
JSON: {},
JSON_ARRAY: {},
XML: '<?xml version="1.0" encoding="UTF-8"?><anonymousId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</anonymousId><context><device><id>df16bffa-5c3d-4fbb-9bce-3bab098129a7R</id><manufacturer>Xiaomi</manufacturer><model>Redmi 6</model><name>xiaomi</name></device><network><carrier>Banglalink</carrier></network><os><name>android</name><version>8.1.0</version></os><traits><address><city>Dhaka</city><country>Bangladesh</country></address><anonymousId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</anonymousId></traits></context><event>spin_result</event><integrations><All>true</All></integrations><message_id>a80f82be-9bdc-4a9f-b2a5-15621ee41df8</message_id><properties><additional_bet_index>0</additional_bet_index><battle_id>N/A</battle_id><bet_amount>9</bet_amount><bet_level>1</bet_level><bet_multiplier>1</bet_multiplier><coin_balance>9466052</coin_balance><current_module_name>CasinoGameModule</current_module_name><days_in_game>0</days_in_game><extra_param>N/A</extra_param><fb_profile>0</fb_profile><featureGameType>N/A</featureGameType><game_fps>30</game_fps><game_id>fireEagleBase</game_id><game_name>FireEagleSlots</game_name><gem_balance>0</gem_balance><graphicsQuality>HD</graphicsQuality><idfa>2bf99787-33d2-4ae2-a76a-c49672f97252</idfa><internetReachability>ReachableViaLocalAreaNetwork</internetReachability><isLowEndDevice>False</isLowEndDevice><is_auto_spin>False</is_auto_spin><is_turbo>False</is_turbo><isf>False</isf><ishighroller>False</ishighroller><jackpot_win_amount>90</jackpot_win_amount><jackpot_win_type>Silver</jackpot_win_type><level>6</level><lifetime_gem_balance>0</lifetime_gem_balance><no_of_spin>1</no_of_spin><player_total_battles>0</player_total_battles><player_total_shields>0</player_total_shields><start_date>2019-08-01</start_date><total_payments>0</total_payments><tournament_id>T1561970819</tournament_id><userId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</userId><versionSessionCount>2</versionSessionCount><win_amount>0</win_amount></properties><timestamp>2019-09-01T15:46:51.693229+05:30</timestamp><type>track</type><user_properties><coin_balance>9466052</coin_balance><current_module_name>CasinoGameModule</current_module_name><fb_profile>0</fb_profile><game_fps>30</game_fps><game_name>FireEagleSlots</game_name><gem_balance>0</gem_balance><graphicsQuality>HD</graphicsQuality><idfa>2bf99787-33d2-4ae2-a76a-c49672f97252</idfa><internetReachability>ReachableViaLocalAreaNetwork</internetReachability><isLowEndDevice>false</isLowEndDevice><level>6</level><lifetime_gem_balance>0</lifetime_gem_balance><player_total_battles>0</player_total_battles><player_total_shields>0</player_total_shields><start_date>2019-08-01</start_date><total_payments>0</total_payments><userId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</userId><versionSessionCount>2</versionSessionCount></user_properties>',
XML: {
payload:
'<?xml version="1.0" encoding="UTF-8"?><anonymousId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</anonymousId><context><device><id>df16bffa-5c3d-4fbb-9bce-3bab098129a7R</id><manufacturer>Xiaomi</manufacturer><model>Redmi 6</model><name>xiaomi</name></device><network><carrier>Banglalink</carrier></network><os><name>android</name><version>8.1.0</version></os><traits><address><city>Dhaka</city><country>Bangladesh</country></address><anonymousId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</anonymousId></traits></context><event>spin_result</event><integrations><All>true</All></integrations><message_id>a80f82be-9bdc-4a9f-b2a5-15621ee41df8</message_id><properties><additional_bet_index>0</additional_bet_index><battle_id>N/A</battle_id><bet_amount>9</bet_amount><bet_level>1</bet_level><bet_multiplier>1</bet_multiplier><coin_balance>9466052</coin_balance><current_module_name>CasinoGameModule</current_module_name><days_in_game>0</days_in_game><extra_param>N/A</extra_param><fb_profile>0</fb_profile><featureGameType>N/A</featureGameType><game_fps>30</game_fps><game_id>fireEagleBase</game_id><game_name>FireEagleSlots</game_name><gem_balance>0</gem_balance><graphicsQuality>HD</graphicsQuality><idfa>2bf99787-33d2-4ae2-a76a-c49672f97252</idfa><internetReachability>ReachableViaLocalAreaNetwork</internetReachability><isLowEndDevice>False</isLowEndDevice><is_auto_spin>False</is_auto_spin><is_turbo>False</is_turbo><isf>False</isf><ishighroller>False</ishighroller><jackpot_win_amount>90</jackpot_win_amount><jackpot_win_type>Silver</jackpot_win_type><level>6</level><lifetime_gem_balance>0</lifetime_gem_balance><no_of_spin>1</no_of_spin><player_total_battles>0</player_total_battles><player_total_shields>0</player_total_shields><start_date>2019-08-01</start_date><total_payments>0</total_payments><tournament_id>T1561970819</tournament_id><userId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</userId><versionSessionCount>2</versionSessionCount><win_amount>0</win_amount></properties><timestamp>2019-09-01T15:46:51.693229+05:30</timestamp><type>track</type><user_properties><coin_balance>9466052</coin_balance><current_module_name>CasinoGameModule</current_module_name><fb_profile>0</fb_profile><game_fps>30</game_fps><game_name>FireEagleSlots</game_name><gem_balance>0</gem_balance><graphicsQuality>HD</graphicsQuality><idfa>2bf99787-33d2-4ae2-a76a-c49672f97252</idfa><internetReachability>ReachableViaLocalAreaNetwork</internetReachability><isLowEndDevice>false</isLowEndDevice><level>6</level><lifetime_gem_balance>0</lifetime_gem_balance><player_total_battles>0</player_total_battles><player_total_shields>0</player_total_shields><start_date>2019-08-01</start_date><total_payments>0</total_payments><userId>c82cbdff-e5be-4009-ac78-cdeea09ab4b1</userId><versionSessionCount>2</versionSessionCount></user_properties>',
},
FORM: {},
},
version: '1',
Expand Down

0 comments on commit 6181617

Please sign in to comment.