-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MC contacts upsert to handle multiple identifiers (#2032)
* Update MC contacts upsert to handle multiple identifiers * Update defaults for phone_number_id, anonymous_id * Update default for anonymous_id * Change anonymous_id to anonymousId
- Loading branch information
1 parent
807258a
commit e99e29f
Showing
4 changed files
with
104 additions
and
25 deletions.
There are no files selected for viewing
60 changes: 38 additions & 22 deletions
60
packages/destination-actions/src/destinations/sendgrid/__tests__/sendgrid-properties.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
import { tranformValueToAcceptedDataType } from '../sendgrid-properties' | ||
import { tranformValueToAcceptedDataType, validatePayload } from '../sendgrid-properties' | ||
|
||
describe('tranformValueToAcceptedDataType', () => { | ||
it('should transform a boolean value into a string', () => { | ||
expect(tranformValueToAcceptedDataType(true)).toBe('true') | ||
}) | ||
describe('sendgrid-properties', () => { | ||
describe('tranformValueToAcceptedDataType', () => { | ||
it('should transform a boolean value into a string', () => { | ||
expect(tranformValueToAcceptedDataType(true)).toBe('true') | ||
}) | ||
|
||
it('should transform an array value into a string', () => { | ||
expect(tranformValueToAcceptedDataType([1, 2, 3])).toBe('[1,2,3]') | ||
}) | ||
it('should transform an array value into a string', () => { | ||
expect(tranformValueToAcceptedDataType([1, 2, 3])).toBe('[1,2,3]') | ||
}) | ||
|
||
it('should transform an object value into a string', () => { | ||
expect(tranformValueToAcceptedDataType({ a: 1 })).toBe('{"a":1}') | ||
}) | ||
it('should transform an object value into a string', () => { | ||
expect(tranformValueToAcceptedDataType({ a: 1 })).toBe('{"a":1}') | ||
}) | ||
|
||
it('should transform nested arrays and objects into a string', () => { | ||
const data = [[1, 2, 3], { a: 1, b: 2, c: { d: 3, e: ['f', 'g'] } }] | ||
expect(tranformValueToAcceptedDataType(data)).toBe('[[1,2,3],{"a":1,"b":2,"c":{"d":3,"e":["f","g"]}}]') | ||
}) | ||
it('should transform nested arrays and objects into a string', () => { | ||
const data = [[1, 2, 3], { a: 1, b: 2, c: { d: 3, e: ['f', 'g'] } }] | ||
expect(tranformValueToAcceptedDataType(data)).toBe('[[1,2,3],{"a":1,"b":2,"c":{"d":3,"e":["f","g"]}}]') | ||
}) | ||
|
||
it('should return the value for number types', () => { | ||
expect(tranformValueToAcceptedDataType(123)).toBe(123) | ||
}) | ||
it('should return the value for number types', () => { | ||
expect(tranformValueToAcceptedDataType(123)).toBe(123) | ||
}) | ||
|
||
it('should return the value for string types', () => { | ||
expect(tranformValueToAcceptedDataType('Hello, test')).toBe('Hello, test') | ||
}) | ||
|
||
it('should return the value for string types', () => { | ||
expect(tranformValueToAcceptedDataType('Hello, test')).toBe('Hello, test') | ||
it('should return the value for date types', () => { | ||
expect(tranformValueToAcceptedDataType('2022-11-01T00:00:00Z')).toBe('2022-11-01T00:00:00Z') | ||
}) | ||
}) | ||
|
||
it('should return the value for date types', () => { | ||
expect(tranformValueToAcceptedDataType('2022-11-01T00:00:00Z')).toBe('2022-11-01T00:00:00Z') | ||
describe('validatePayload', () => { | ||
it('should throw an error if no identifying field is included', () => { | ||
const payload = {} | ||
expect(() => validatePayload(payload)).toThrowError( | ||
'Contact must have at least one identifying field included (email, phone_number_id, external_id, anonymous_id).' | ||
) | ||
}) | ||
|
||
it('should not throw an error if at least one identifying field is included', () => { | ||
const payload = { anonymous_id: 'hip-hop-anonymous' } | ||
expect(() => validatePayload(payload)).not.toThrow() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
packages/destination-actions/src/destinations/sendgrid/updateUserProfile/generated-types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters