From 05553eb5cbf3aa0afd752dca9af74e32722876ed Mon Sep 17 00:00:00 2001 From: Sandeep Digumarty Date: Thu, 13 Feb 2025 21:18:49 +0530 Subject: [PATCH] feat(http): add support for isDefaultMapping (#4073) --- .../v2/destinations/http/procWorkflow.yaml | 3 +- test/integrations/destinations/http/common.ts | 23 +++++++++ .../http/processor/configuration.ts | 50 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/cdk/v2/destinations/http/procWorkflow.yaml b/src/cdk/v2/destinations/http/procWorkflow.yaml index 1db0fce1d72..1371eded905 100644 --- a/src/cdk/v2/destinations/http/procWorkflow.yaml +++ b/src/cdk/v2/destinations/http/procWorkflow.yaml @@ -55,7 +55,8 @@ steps: - name: prepareBody template: | - const payload = $.getCustomMappings(.message, .destination.Config.propertiesMapping); + const propertiesMapping = .destination.Config.isDefaultMapping ? [{"to": "$", "from": "$"}] : .destination.Config.propertiesMapping; + const payload = $.getCustomMappings(.message, propertiesMapping); $.context.payload = $.prepareBody(payload, $.context.format, .destination.Config.xmlRootKey); - name: buildResponseForProcessTransformation diff --git a/test/integrations/destinations/http/common.ts b/test/integrations/destinations/http/common.ts index 6c2887859f3..7f9cc61048f 100644 --- a/test/integrations/destinations/http/common.ts +++ b/test/integrations/destinations/http/common.ts @@ -623,6 +623,29 @@ const destinations: Destination[] = [ Transformations: [], WorkspaceID: 'test-workspace-id', }, + { + Config: { + apiUrl: 'http://abc.com/contacts', + auth: 'noAuth', + method: 'POST', + format: 'JSON', + isBatchingEnabled: true, + maxBatchSize: '2', + isDefaultMapping: true, + propertiesMapping: [], + }, + DestinationDefinition: { + DisplayName: displayName, + ID: '123', + Name: destTypeInUpperCase, + Config: { cdkV2Enabled: true }, + }, + Enabled: true, + ID: '123', + Name: destTypeInUpperCase, + Transformations: [], + WorkspaceID: 'test-workspace-id', + }, ]; const traits = { diff --git a/test/integrations/destinations/http/processor/configuration.ts b/test/integrations/destinations/http/processor/configuration.ts index 51a28fc2abf..62676ba63de 100644 --- a/test/integrations/destinations/http/processor/configuration.ts +++ b/test/integrations/destinations/http/processor/configuration.ts @@ -530,4 +530,54 @@ export const configuration: ProcessorTestData[] = [ }, }, }, + { + id: 'http-configuration-test-11', + name: destType, + description: 'Identify call with default properties mapping', + scenario: 'Business', + successCriteria: 'Response should be in json format with default properties mapping', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: destinations[14], + message: { + type: 'identify', + userId: 'userId123', + anonymousId: 'anonId123', + }, + metadata: generateMetadata(1), + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint: destinations[14].Config.apiUrl, + headers: { + 'Content-Type': 'application/json', + }, + JSON: { + type: 'identify', + userId: 'userId123', + anonymousId: 'anonId123', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, ];