Skip to content

Commit

Permalink
chore: addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Feb 27, 2024
1 parent b89e215 commit ec361c4
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/v0/destinations/hs/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const getTransformedJSON = async (message, destination, propertyMap) => {
const hsSupportedKey = formatKey(traitsKey);
if (!rawPayload[traitsKey] && propertyMap[hsSupportedKey]) {
// HS accepts empty string to remove the property from contact
// https://community.hubspot.com/t5/APIs-Integrations/Clearing-values-of-custom-properties-in-Hubspot-contact-using/m-p/409156
let propValue = isNull(traits[traitsKey]) ? '' : traits[traitsKey];
if (propertyMap[hsSupportedKey] === 'date') {
propValue = getUTCMidnightTimeStampValue(propValue);
Expand Down
97 changes: 52 additions & 45 deletions test/integrations/destinations/hs/processor/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
import { Destination } from '../../../../../src/types';
import { generateMetadata, generateSimplifiedIdentifyPayload } from '../../../testUtils';

const commonOutputHeaders = {
'Content-Type': 'application/json',
Authorization: 'Bearer dummy-access-token',
};

const destination: Destination = {
Config: {
authorizationType: 'newPrivateAppApi',
accessToken: 'dummy-access-token',
hubID: 'dummy-hubId',
apiKey: 'dummy-apikey',
apiVersion: 'newApi',
lookupField: 'email',
hubspotEvents: [],
eventFilteringOption: 'disable',
blacklistedEvents: [
{
eventName: '',
},
],
whitelistedEvents: [
{
eventName: '',
},
],
},
Enabled: true,
ID: '123',
Name: 'hs',
DestinationDefinition: {
ID: '123',
Name: 'hs',
DisplayName: 'Hubspot',
Config: {},
},
WorkspaceID: '123',
Transformations: [],
};

export const data = [
{
name: 'hs',
Expand Down Expand Up @@ -5279,52 +5321,19 @@ export const data = [
request: {
body: [
{
message: {
description: '[HS] (newApi): check converion to empty string if hs property is null',
channel: 'web',
destination,
message: generateSimplifiedIdentifyPayload({
userId: '12345',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.0.0',
},
traits: {
email: 'noname@email.com',
firstname: null,
gender: '',
lookupField: 'email',
},
},
type: 'identify',
userId: '12345',
integrations: {
All: true,
},
},
destination: {
Config: {
authorizationType: 'newPrivateAppApi',
accessToken: 'dummy-access-token',
hubID: 'dummy-hubId',
apiKey: 'dummy-apikey',
apiVersion: 'newApi',
lookupField: 'email',
hubspotEvents: [],
eventFilteringOption: 'disable',
blacklistedEvents: [
{
eventName: '',
},
],
whitelistedEvents: [
{
eventName: '',
},
],
},
Enabled: true,
},
}),
metadata: generateMetadata(1),
},
],
},
Expand All @@ -5340,13 +5349,12 @@ export const data = [
userId: '',
method: 'POST',
endpoint: 'https://api.hubapi.com/crm/v3/objects/contacts',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer dummy-access-token',
},
params: {},
files: {},
headers: commonOutputHeaders,
operation: 'createContacts',
params: {},
body: {
FORM: {},
JSON: {
properties: {
email: 'noname@email.com',
Expand All @@ -5356,11 +5364,10 @@ export const data = [
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
},
statusCode: 200,
metadata: generateMetadata(1),
},
],
},
Expand Down

0 comments on commit ec361c4

Please sign in to comment.