@segment/actions-shared 1.150.1-staging-23ce14401.0 → 1.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dotdigital/api/resources/dd-contact-api.d.ts +16 -1
- package/dist/dotdigital/api/resources/dd-contact-api.js +52 -10
- package/dist/dotdigital/api/resources/dd-contact-api.js.map +1 -1
- package/dist/dotdigital/api/types.d.ts +10 -4
- package/dist/dotdigital/api/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -9,10 +9,25 @@ declare class DDContactApi extends DDApi {
|
|
|
9
9
|
channelIdentifier: string;
|
|
10
10
|
emailIdentifier?: string;
|
|
11
11
|
mobileNumberIdentifier?: string;
|
|
12
|
-
|
|
12
|
+
emailType?: string;
|
|
13
|
+
optInType?: string;
|
|
14
|
+
updateEmailSubscription?: boolean;
|
|
15
|
+
emailSubscriptionStatus?: string;
|
|
16
|
+
emailResubscribe?: boolean;
|
|
17
|
+
resubscribeWithoutChallengeEmail?: boolean;
|
|
18
|
+
preferredLocale?: string;
|
|
19
|
+
redirectUrlAfterChallenge?: string;
|
|
20
|
+
updateSmsSubscription?: boolean;
|
|
21
|
+
smsSubscriptionStatus?: string;
|
|
22
|
+
listId?: number;
|
|
13
23
|
dataFields?: {
|
|
14
24
|
[k: string]: unknown;
|
|
15
25
|
};
|
|
16
26
|
}): Promise<Contact>;
|
|
27
|
+
unsubscribeContact(payload: {
|
|
28
|
+
channelIdentifier: string;
|
|
29
|
+
emailIdentifier?: string;
|
|
30
|
+
mobileNumberIdentifier?: string;
|
|
31
|
+
}): Promise<Contact>;
|
|
17
32
|
}
|
|
18
33
|
export default DDContactApi;
|
|
@@ -18,7 +18,55 @@ class DDContactApi extends dd_api_1.default {
|
|
|
18
18
|
return response.data;
|
|
19
19
|
}
|
|
20
20
|
async upsertContact(payload) {
|
|
21
|
-
const { channelIdentifier, emailIdentifier, mobileNumberIdentifier, listId, dataFields } = payload;
|
|
21
|
+
const { channelIdentifier, emailIdentifier, mobileNumberIdentifier, emailType = 'html', optInType = 'single', updateEmailSubscription = true, emailSubscriptionStatus = 'subscribed', emailResubscribe = false, resubscribeWithoutChallengeEmail = false, preferredLocale, redirectUrlAfterChallenge, updateSmsSubscription = true, smsSubscriptionStatus = 'subscribed', listId, dataFields } = payload;
|
|
22
|
+
const idValue = channelIdentifier === 'email' ? emailIdentifier : mobileNumberIdentifier;
|
|
23
|
+
const identifiers = {
|
|
24
|
+
...(emailIdentifier && { email: emailIdentifier }),
|
|
25
|
+
...(mobileNumberIdentifier && { mobileNumber: mobileNumberIdentifier })
|
|
26
|
+
};
|
|
27
|
+
const channelProperties = {};
|
|
28
|
+
if (emailIdentifier) {
|
|
29
|
+
channelProperties.email = {
|
|
30
|
+
emailType,
|
|
31
|
+
optInType
|
|
32
|
+
};
|
|
33
|
+
if (updateEmailSubscription) {
|
|
34
|
+
if (emailSubscriptionStatus === 'subscribed') {
|
|
35
|
+
if (emailResubscribe) {
|
|
36
|
+
channelProperties.email.status = 'subscribed';
|
|
37
|
+
const resubscribeOptions = {
|
|
38
|
+
resubscribeWithNoChallenge: resubscribeWithoutChallengeEmail
|
|
39
|
+
};
|
|
40
|
+
if (!resubscribeWithoutChallengeEmail) {
|
|
41
|
+
if (preferredLocale)
|
|
42
|
+
resubscribeOptions.preferredLocale = preferredLocale;
|
|
43
|
+
if (redirectUrlAfterChallenge)
|
|
44
|
+
resubscribeOptions.redirectUrlAfterChallenge = redirectUrlAfterChallenge;
|
|
45
|
+
}
|
|
46
|
+
channelProperties.email.resubscribeOptions = resubscribeOptions;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (emailSubscriptionStatus) {
|
|
50
|
+
channelProperties.email.status = emailSubscriptionStatus;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (mobileNumberIdentifier && updateSmsSubscription && smsSubscriptionStatus) {
|
|
55
|
+
channelProperties.sms = {
|
|
56
|
+
status: smsSubscriptionStatus
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const data = {
|
|
60
|
+
identifiers,
|
|
61
|
+
channelProperties,
|
|
62
|
+
...(listId && { lists: [listId] }),
|
|
63
|
+
dataFields: dataFields
|
|
64
|
+
};
|
|
65
|
+
const response = await this.patch(`/contacts/v3/${channelIdentifier}/${idValue}?merge-option=overwrite`, data);
|
|
66
|
+
return response.data;
|
|
67
|
+
}
|
|
68
|
+
async unsubscribeContact(payload) {
|
|
69
|
+
const { channelIdentifier, emailIdentifier, mobileNumberIdentifier } = payload;
|
|
22
70
|
const idValue = channelIdentifier === 'email' ? emailIdentifier : mobileNumberIdentifier;
|
|
23
71
|
const identifiers = {
|
|
24
72
|
...(emailIdentifier && { email: emailIdentifier }),
|
|
@@ -26,21 +74,15 @@ class DDContactApi extends dd_api_1.default {
|
|
|
26
74
|
};
|
|
27
75
|
const channelProperties = {
|
|
28
76
|
...(emailIdentifier && {
|
|
29
|
-
email: {
|
|
30
|
-
status: 'subscribed',
|
|
31
|
-
emailType: 'html',
|
|
32
|
-
optInType: 'single'
|
|
33
|
-
}
|
|
77
|
+
email: { status: 'unsubscribed' }
|
|
34
78
|
}),
|
|
35
79
|
...(mobileNumberIdentifier && {
|
|
36
|
-
sms: { status: '
|
|
80
|
+
sms: { status: 'unsubscribed' }
|
|
37
81
|
})
|
|
38
82
|
};
|
|
39
83
|
const data = {
|
|
40
84
|
identifiers,
|
|
41
|
-
channelProperties
|
|
42
|
-
lists: [listId],
|
|
43
|
-
dataFields: dataFields
|
|
85
|
+
channelProperties
|
|
44
86
|
};
|
|
45
87
|
const response = await this.patch(`/contacts/v3/${channelIdentifier}/${idValue}?merge-option=overwrite`, data);
|
|
46
88
|
return response.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dd-contact-api.js","sourceRoot":"","sources":["../../../../src/dotdigital/api/resources/dd-contact-api.ts"],"names":[],"mappings":";;;;;AACA,uDAA6B;AAG7B,MAAM,Y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E,CAAC;SACxE,CAAA;QAED,MAAM,iBAAiB,GAAsB;YAC3C,GAAG,CAAC,eAAe,IAAI;gBACrB,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;aAClC,CAAC;YACF,GAAG,CAAC,sBAAsB,IAAI;gBAC5B,GAAG,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;aAChC,CAAC;SACH,CAAA;QAED,MAAM,IAAI,GAAsB;YAC9B,WAAW;YACX,iBAAiB;SAClB,CAAA;QAED,MAAM,QAAQ,GAA8B,MAAM,IAAI,CAAC,KAAK,CAC1D,gBAAgB,iBAAiB,IAAI,OAAO,yBAAyB,EACrE,IAAI,CACL,CAAA;QAED,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CACF;AAED,kBAAe,YAAY,CAAA"}
|
|
@@ -36,11 +36,17 @@ export interface Identifiers {
|
|
|
36
36
|
export interface DataFields {
|
|
37
37
|
[key: string]: string | number | boolean | null;
|
|
38
38
|
}
|
|
39
|
+
export interface ResubscribeOptions {
|
|
40
|
+
resubscribeWithNoChallenge?: boolean;
|
|
41
|
+
preferredLocale?: string;
|
|
42
|
+
redirectUrlAfterChallenge?: string;
|
|
43
|
+
}
|
|
39
44
|
export interface ChannelProperties {
|
|
40
45
|
email?: {
|
|
41
|
-
status
|
|
42
|
-
emailType
|
|
43
|
-
optInType
|
|
46
|
+
status?: string;
|
|
47
|
+
emailType?: string;
|
|
48
|
+
optInType?: string;
|
|
49
|
+
resubscribeOptions?: ResubscribeOptions;
|
|
44
50
|
};
|
|
45
51
|
sms?: {
|
|
46
52
|
status: string;
|
|
@@ -97,7 +103,7 @@ export type ChannelIdentifier = {
|
|
|
97
103
|
export interface UpsertContactJSON {
|
|
98
104
|
identifiers: Identifiers;
|
|
99
105
|
channelProperties: ChannelProperties;
|
|
100
|
-
lists
|
|
106
|
+
lists?: number[];
|
|
101
107
|
dataFields?: DataFields;
|
|
102
108
|
}
|
|
103
109
|
export interface CpaasMessageBody {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dotdigital/api/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dotdigital/api/types.ts"],"names":[],"mappings":";;;AA+EA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,gCAAe,CAAA;IACf,4CAA2B,CAAA;AAC7B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/actions-shared",
|
|
3
3
|
"description": "Shared destination action methods and definitions.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.152.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@amplitude/ua-parser-js": "^0.7.25",
|
|
40
|
-
"@segment/actions-core": "3.
|
|
40
|
+
"@segment/actions-core": "^3.167.0",
|
|
41
41
|
"cheerio": "^1.0.0-rc.10",
|
|
42
42
|
"dayjs": "^1.10.7",
|
|
43
43
|
"escape-goat": "^3",
|
|
44
|
-
"liquidjs": "^10.
|
|
45
|
-
"lodash": "^4.
|
|
44
|
+
"liquidjs": "^10.8.4",
|
|
45
|
+
"lodash": "^4.17.21"
|
|
46
46
|
},
|
|
47
47
|
"jest": {
|
|
48
48
|
"preset": "ts-jest",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"<rootDir>/test/setup-after-env.ts"
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "435786c4b8f370a4de536eca7bcebe078b72eb6f"
|
|
68
68
|
}
|