Skip to content

Commit

Permalink
feat(http): add support for isDefaultMapping (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs authored Feb 13, 2025
1 parent bfad78d commit 05553eb
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cdk/v2/destinations/http/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/integrations/destinations/http/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
50 changes: 50 additions & 0 deletions test/integrations/destinations/http/processor/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
],
},
},
},
];

0 comments on commit 05553eb

Please sign in to comment.