@segment/action-destinations 3.227.4-staging.0 → 3.227.4-staging.2
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/destinations/klaviyo/generated-types.d.ts +0 -4
- package/dist/destinations/klaviyo/index.d.ts +2 -2
- package/dist/destinations/klaviyo/index.js +3 -20
- package/dist/destinations/klaviyo/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/api/api.test.d.ts +1 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js +220 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js.map +1 -0
- package/dist/destinations/marketo-static-lists/addToList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/addToList/index.js +16 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/constants.d.ts +41 -2
- package/dist/destinations/marketo-static-lists/constants.js +11 -2
- package/dist/destinations/marketo-static-lists/constants.js.map +1 -1
- package/dist/destinations/marketo-static-lists/functions.d.ts +7 -0
- package/dist/destinations/marketo-static-lists/functions.js +71 -0
- package/dist/destinations/marketo-static-lists/functions.js.map +1 -0
- package/dist/destinations/marketo-static-lists/index.js +38 -22
- package/dist/destinations/marketo-static-lists/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/properties.d.ts +6 -0
- package/dist/destinations/marketo-static-lists/properties.js +49 -0
- package/dist/destinations/marketo-static-lists/properties.js.map +1 -0
- package/dist/destinations/marketo-static-lists/removeFromList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/removeFromList/index.js +17 -5
- package/dist/destinations/marketo-static-lists/removeFromList/index.js.map +1 -1
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js.map +1 -0
- package/dist/destinations/{movable-ink/conversion → yahoo-audiences/createCustomerNode}/index.d.ts +1 -1
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js +26 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.d.ts +6 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.js.map +1 -0
- package/dist/destinations/{movable-ink/identify → yahoo-audiences/createSegment}/index.d.ts +1 -1
- package/dist/destinations/yahoo-audiences/createSegment/index.js +38 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/utils.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/utils.js +30 -0
- package/dist/destinations/yahoo-audiences/utils.js.map +1 -0
- package/package.json +1 -1
- package/dist/destinations/movable-ink/categoryView/generated-types.d.ts +0 -22
- package/dist/destinations/movable-ink/categoryView/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/categoryView/index.d.ts +0 -5
- package/dist/destinations/movable-ink/categoryView/index.js +0 -43
- package/dist/destinations/movable-ink/categoryView/index.js.map +0 -1
- package/dist/destinations/movable-ink/conversion/generated-types.d.ts +0 -20
- package/dist/destinations/movable-ink/conversion/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/conversion/index.js +0 -45
- package/dist/destinations/movable-ink/conversion/index.js.map +0 -1
- package/dist/destinations/movable-ink/fields.d.ts +0 -21
- package/dist/destinations/movable-ink/fields.js +0 -236
- package/dist/destinations/movable-ink/fields.js.map +0 -1
- package/dist/destinations/movable-ink/identify/generated-types.d.ts +0 -7
- package/dist/destinations/movable-ink/identify/generated-types.js +0 -3
- package/dist/destinations/movable-ink/identify/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/identify/index.js +0 -32
- package/dist/destinations/movable-ink/identify/index.js.map +0 -1
- package/dist/destinations/movable-ink/productAdded/generated-types.d.ts +0 -22
- package/dist/destinations/movable-ink/productAdded/generated-types.js +0 -3
- package/dist/destinations/movable-ink/productAdded/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/productAdded/index.d.ts +0 -5
- package/dist/destinations/movable-ink/productAdded/index.js +0 -43
- package/dist/destinations/movable-ink/productAdded/index.js.map +0 -1
- package/dist/destinations/movable-ink/productViewed/generated-types.d.ts +0 -21
- package/dist/destinations/movable-ink/productViewed/generated-types.js +0 -3
- package/dist/destinations/movable-ink/productViewed/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/productViewed/index.d.ts +0 -5
- package/dist/destinations/movable-ink/productViewed/index.js +0 -43
- package/dist/destinations/movable-ink/productViewed/index.js.map +0 -1
- package/dist/destinations/movable-ink/search/generated-types.d.ts +0 -12
- package/dist/destinations/movable-ink/search/generated-types.js +0 -3
- package/dist/destinations/movable-ink/search/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/search/index.d.ts +0 -5
- package/dist/destinations/movable-ink/search/index.js +0 -43
- package/dist/destinations/movable-ink/search/index.js.map +0 -1
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.d.ts +0 -25
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js +0 -3
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/sendCustomEvent/index.d.ts +0 -5
- package/dist/destinations/movable-ink/sendCustomEvent/index.js +0 -48
- package/dist/destinations/movable-ink/sendCustomEvent/index.js.map +0 -1
- /package/dist/destinations/{movable-ink/categoryView → yahoo-audiences/createCustomerNode}/generated-types.js +0 -0
- /package/dist/destinations/{movable-ink/conversion → yahoo-audiences/createSegment}/generated-types.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AudienceDestinationDefinition } from '@segment/actions-core';
|
|
2
|
-
import type { Settings
|
|
3
|
-
declare const destination: AudienceDestinationDefinition<Settings
|
|
2
|
+
import type { Settings } from './generated-types';
|
|
3
|
+
declare const destination: AudienceDestinationDefinition<Settings>;
|
|
4
4
|
export default destination;
|
|
@@ -57,20 +57,7 @@ const destination = {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
},
|
|
60
|
-
audienceFields: {
|
|
61
|
-
list_name: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
label: 'A List Name is required by the destination',
|
|
64
|
-
description: 'A List Name is required by the destination',
|
|
65
|
-
required: true
|
|
66
|
-
},
|
|
67
|
-
api_key: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
label: 'A Api Key is required by the destination',
|
|
70
|
-
description: 'A Api Key is required by the destination',
|
|
71
|
-
required: true
|
|
72
|
-
}
|
|
73
|
-
},
|
|
60
|
+
audienceFields: {},
|
|
74
61
|
audienceConfig: {
|
|
75
62
|
mode: {
|
|
76
63
|
type: 'synced',
|
|
@@ -78,17 +65,13 @@ const destination = {
|
|
|
78
65
|
},
|
|
79
66
|
async createAudience(request, createAudienceInput) {
|
|
80
67
|
const audienceName = createAudienceInput.audienceName;
|
|
81
|
-
const
|
|
82
|
-
const apiKey = createAudienceInput.audienceSettings?.api_key;
|
|
68
|
+
const apiKey = createAudienceInput.settings?.api_key;
|
|
83
69
|
if (!audienceName) {
|
|
84
70
|
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
85
71
|
}
|
|
86
72
|
if (!apiKey) {
|
|
87
73
|
throw new actions_core_1.IntegrationError('Missing Api Key value', 'MISSING_REQUIRED_FIELD', 400);
|
|
88
74
|
}
|
|
89
|
-
if (!listName) {
|
|
90
|
-
throw new actions_core_1.IntegrationError('Missing List Name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
91
|
-
}
|
|
92
75
|
const response = await request(`${config_1.API_URL}/lists`, {
|
|
93
76
|
method: 'POST',
|
|
94
77
|
headers: {
|
|
@@ -98,7 +81,7 @@ const destination = {
|
|
|
98
81
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
99
82
|
},
|
|
100
83
|
json: {
|
|
101
|
-
data: { type: 'list', attributes: { name:
|
|
84
|
+
data: { type: 'list', attributes: { name: audienceName } }
|
|
102
85
|
}
|
|
103
86
|
});
|
|
104
87
|
const r = await response.json();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAuF;AAGvF,qCAAiD;AACjD,oEAA2C;AAC3C,0EAAiD;AACjD,gFAAuD;AACvD,8DAAqC;AACrC,sEAA6C;AAE7C,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAuF;AAGvF,qCAAiD;AACjD,oEAA2C;AAC3C,0EAAiD;AACjD,gFAAuD;AACvD,8DAAqC;AACrC,sEAA6C;AAE7C,MAAM,WAAW,GAA4C;IAC3D,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,gBAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,gBAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA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
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const create_request_client_1 = __importDefault(require("../../../../../core/src/create-request-client"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const requestClient = create_request_client_1.default();
|
|
11
|
+
describe('LinkedIn Conversions', () => {
|
|
12
|
+
describe('dynamicFields', () => {
|
|
13
|
+
const linkedIn = new api_1.LinkedInConversions(requestClient);
|
|
14
|
+
it('should fetch a list of ad accounts, with their names', async () => {
|
|
15
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
16
|
+
.get(`/adAccountUsers`)
|
|
17
|
+
.query({ q: 'authenticatedUser' })
|
|
18
|
+
.reply(200, {
|
|
19
|
+
elements: [
|
|
20
|
+
{
|
|
21
|
+
account: 'urn:li:sponsoredAccount:516413367',
|
|
22
|
+
changeAuditStamps: {
|
|
23
|
+
created: {
|
|
24
|
+
actor: 'urn:li:unknown:0',
|
|
25
|
+
time: 1500331577000
|
|
26
|
+
},
|
|
27
|
+
lastModified: {
|
|
28
|
+
actor: 'urn:li:unknown:0',
|
|
29
|
+
time: 1505328748000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
33
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
34
|
+
version: {
|
|
35
|
+
versionTag: '89'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
account: 'urn:li:sponsoredAccount:516880883',
|
|
40
|
+
changeAuditStamps: {
|
|
41
|
+
created: {
|
|
42
|
+
actor: 'urn:li:unknown:0',
|
|
43
|
+
time: 1505326590000
|
|
44
|
+
},
|
|
45
|
+
lastModified: {
|
|
46
|
+
actor: 'urn:li:unknown:0',
|
|
47
|
+
time: 1505326615000
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
51
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
52
|
+
version: {
|
|
53
|
+
versionTag: '3'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
paging: {
|
|
58
|
+
count: 2,
|
|
59
|
+
links: [],
|
|
60
|
+
start: 0,
|
|
61
|
+
total: 2
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const getAdAccountsRes = await linkedIn.getAdAccounts();
|
|
65
|
+
expect(getAdAccountsRes).toEqual({
|
|
66
|
+
choices: [
|
|
67
|
+
{
|
|
68
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
69
|
+
value: 'urn:li:sponsoredAccount:516413367'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
73
|
+
value: 'urn:li:sponsoredAccount:516880883'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should fetch a list of conversion rules', async () => {
|
|
79
|
+
const payload = {
|
|
80
|
+
adAccountId: '123456'
|
|
81
|
+
};
|
|
82
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
83
|
+
.get(`/conversions`)
|
|
84
|
+
.query({ q: 'account', account: payload.adAccountId })
|
|
85
|
+
.reply(200, {
|
|
86
|
+
elements: [
|
|
87
|
+
{
|
|
88
|
+
postClickAttributionWindowSize: 30,
|
|
89
|
+
viewThroughAttributionWindowSize: 7,
|
|
90
|
+
created: 1563230311551,
|
|
91
|
+
type: 'LEAD',
|
|
92
|
+
enabled: true,
|
|
93
|
+
name: 'Conversion API Segment 2',
|
|
94
|
+
lastModified: 1563230311551,
|
|
95
|
+
id: 104012,
|
|
96
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
97
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
98
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
postClickAttributionWindowSize: 30,
|
|
102
|
+
viewThroughAttributionWindowSize: 7,
|
|
103
|
+
created: 1563230255308,
|
|
104
|
+
type: 'PURCHASE',
|
|
105
|
+
enabled: true,
|
|
106
|
+
name: 'Conversion API Segment 3',
|
|
107
|
+
lastModified: 1563230265652,
|
|
108
|
+
id: 104004,
|
|
109
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
110
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
111
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
const getConversionRulesListRes = await linkedIn.getConversionRulesList(payload.adAccountId);
|
|
116
|
+
expect(getConversionRulesListRes).toEqual({
|
|
117
|
+
choices: [
|
|
118
|
+
{
|
|
119
|
+
label: 'Conversion API Segment 2',
|
|
120
|
+
value: 104012
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: 'Conversion API Segment 3',
|
|
124
|
+
value: 104004
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it('should fetch a list of campaigns', async () => {
|
|
130
|
+
const payload = {
|
|
131
|
+
adAccountId: '123456'
|
|
132
|
+
};
|
|
133
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
134
|
+
.get(`/adAccounts/${payload.adAccountId}/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))`)
|
|
135
|
+
.reply(200, {
|
|
136
|
+
paging: {
|
|
137
|
+
start: 0,
|
|
138
|
+
count: 10,
|
|
139
|
+
links: [],
|
|
140
|
+
total: 1
|
|
141
|
+
},
|
|
142
|
+
elements: [
|
|
143
|
+
{
|
|
144
|
+
test: false,
|
|
145
|
+
storyDeliveryEnabled: false,
|
|
146
|
+
format: 'TEXT_AD',
|
|
147
|
+
targetingCriteria: {
|
|
148
|
+
include: {
|
|
149
|
+
and: [
|
|
150
|
+
{
|
|
151
|
+
or: {
|
|
152
|
+
'urn:li:adTargetingFacet:locations': ['urn:li:geo:90000084']
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
or: {
|
|
157
|
+
'urn:li:adTargetingFacet:interfaceLocales': ['urn:li:locale:en_US']
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
servingStatuses: ['ACCOUNT_SERVING_HOLD'],
|
|
164
|
+
locale: {
|
|
165
|
+
country: 'US',
|
|
166
|
+
language: 'en'
|
|
167
|
+
},
|
|
168
|
+
type: 'TEXT_AD',
|
|
169
|
+
version: {
|
|
170
|
+
versionTag: '11'
|
|
171
|
+
},
|
|
172
|
+
objectiveType: 'WEBSITE_TRAFFIC',
|
|
173
|
+
associatedEntity: 'urn:li:organization:2425698',
|
|
174
|
+
optimizationTargetType: 'NONE',
|
|
175
|
+
runSchedule: {
|
|
176
|
+
start: 1498178362345
|
|
177
|
+
},
|
|
178
|
+
changeAuditStamps: {
|
|
179
|
+
created: {
|
|
180
|
+
actor: 'urn:li:unknown:0',
|
|
181
|
+
time: 1498178304000
|
|
182
|
+
},
|
|
183
|
+
lastModified: {
|
|
184
|
+
actor: 'urn:li:unknown:0',
|
|
185
|
+
time: 1698494362000
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
campaignGroup: 'urn:li:sponsoredCampaignGroup:600360846',
|
|
189
|
+
dailyBudget: {
|
|
190
|
+
currencyCode: 'USD',
|
|
191
|
+
amount: '25'
|
|
192
|
+
},
|
|
193
|
+
costType: 'CPC',
|
|
194
|
+
creativeSelection: 'OPTIMIZED',
|
|
195
|
+
unitCost: {
|
|
196
|
+
currencyCode: 'USD',
|
|
197
|
+
amount: '8.19'
|
|
198
|
+
},
|
|
199
|
+
name: 'Test',
|
|
200
|
+
offsiteDeliveryEnabled: false,
|
|
201
|
+
id: 125868226,
|
|
202
|
+
audienceExpansionEnabled: true,
|
|
203
|
+
account: 'urn:li:sponsoredAccount:507525021',
|
|
204
|
+
status: 'ACTIVE'
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
const getCampaignsListRes = await linkedIn.getCampaignsList(payload.adAccountId);
|
|
209
|
+
expect(getCampaignsListRes).toEqual({
|
|
210
|
+
choices: [
|
|
211
|
+
{
|
|
212
|
+
label: 'Test',
|
|
213
|
+
value: 125868226
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
//# sourceMappingURL=api.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/api.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,0GAA+E;AAC/E,gCAA4C;AAC5C,4CAAuC;AAEvC,MAAM,aAAa,GAAG,+BAAmB,EAAE,CAAA;AAE3C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAwB,IAAI,yBAAmB,CAAC,aAAa,CAAC,CAAA;QAE5E,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;YACpE,cAAI,CAAC,GAAG,oBAAQ,EAAE,CAAC;iBAChB,GAAG,CAAC,iBAAiB,CAAC;iBACtB,KAAK,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;iBACjC,KAAK,CAAC,GAAG,EAAE;gBACV,QAAQ,EAAE;oBACR;wBACE,OAAO,EAAE,mCAAmC;wBAC5C,iBAAiB,EAAE;4BACjB,OAAO,EAAE;gCACP,KAAK,EAAE,kBAAkB;gCACzB,IAAI,EAAE,aAAa;6BACpB;4BACD,YAAY,EAAE;gCACZ,KAAK,EAA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wBACD,IAAI,EAAE,MAAM;wBACZ,sBAAsB,EAAE,KAAK;wBAC7B,EAAE,EAAE,SAAS;wBACb,wBAAwB,EAAE,IAAI;wBAC9B,OAAO,EAAE,mCAAmC;wBAC5C,MAAM,EAAE,QAAQ;qBACjB;iBACF;aACF,CAAC,CAAA;YAEJ,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;YAChF,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC;gBAClC,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,MAAM;wBACb,KAAK,EAAE,SAAS;qBACjB;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const properties_1 = require("../properties");
|
|
4
|
+
const functions_1 = require("../functions");
|
|
3
5
|
const action = {
|
|
4
6
|
title: 'Add to List',
|
|
5
|
-
description: 'Add users
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
description: 'Add users from an Engage Audience to a list in Marketo.',
|
|
8
|
+
defaultSubscription: 'event = "Audience Entered"',
|
|
9
|
+
fields: {
|
|
10
|
+
external_id: { ...properties_1.external_id },
|
|
11
|
+
email: { ...properties_1.email },
|
|
12
|
+
enable_batching: { ...properties_1.enable_batching },
|
|
13
|
+
batch_size: { ...properties_1.batch_size },
|
|
14
|
+
event_name: { ...properties_1.event_name }
|
|
15
|
+
},
|
|
16
|
+
perform: async (request, { settings, payload }) => {
|
|
17
|
+
return functions_1.addToList(request, settings, [payload]);
|
|
18
|
+
},
|
|
19
|
+
performBatch: async (request, { settings, payload }) => {
|
|
20
|
+
return functions_1.addToList(request, settings, payload);
|
|
9
21
|
}
|
|
10
22
|
};
|
|
11
23
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/marketo-static-lists/addToList/index.ts"],"names":[],"mappings":";;AAGA,8CAA2F;AAC3F,4CAAwC;AAExC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yDAAyD;IACtE,mBAAmB,EAAE,4BAA4B;IACjD,MAAM,EAAE;QACN,WAAW,EAAE,EAAE,GAAG,wBAAW,EAAE;QAC/B,KAAK,EAAE,EAAE,GAAG,kBAAK,EAAE;QACnB,eAAe,EAAE,EAAE,GAAG,4BAAe,EAAE;QACvC,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;QAC7B,UAAU,EAAE,EAAE,GAAG,uBAAU,EAAE;KAC9B;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,OAAO,qBAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACrD,OAAO,qBAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { RequestClient } from '@segment/actions-core
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
2
|
import { Settings } from './generated-types';
|
|
3
|
+
export declare const GET_FOLDER_ENDPOINT: string;
|
|
4
|
+
export declare const CREATE_LIST_ENDPOINT: string;
|
|
5
|
+
export declare const GET_LIST_ENDPOINT: string;
|
|
6
|
+
export declare const BULK_IMPORT_ENDPOINT: string;
|
|
7
|
+
export declare const GET_LEADS_ENDPOINT: string;
|
|
8
|
+
export declare const REMOVE_USERS_ENDPOINT: string;
|
|
9
|
+
export declare const CSV_LIMIT = 10000000;
|
|
3
10
|
export interface RefreshTokenResponse {
|
|
4
11
|
access_token: string;
|
|
5
12
|
}
|
|
6
|
-
|
|
13
|
+
interface MarketoResponse {
|
|
14
|
+
requestId: string;
|
|
7
15
|
success: boolean;
|
|
8
16
|
errors: [
|
|
9
17
|
{
|
|
@@ -11,6 +19,8 @@ export interface MarketoResonse {
|
|
|
11
19
|
message: string;
|
|
12
20
|
}
|
|
13
21
|
];
|
|
22
|
+
}
|
|
23
|
+
export interface MarketoListResponse extends MarketoResponse {
|
|
14
24
|
result: [
|
|
15
25
|
{
|
|
16
26
|
name: string;
|
|
@@ -18,4 +28,33 @@ export interface MarketoResonse {
|
|
|
18
28
|
}
|
|
19
29
|
];
|
|
20
30
|
}
|
|
31
|
+
export interface MarketoBulkImportResponse extends MarketoResponse {
|
|
32
|
+
result: [
|
|
33
|
+
{
|
|
34
|
+
batchId: number;
|
|
35
|
+
importId: string;
|
|
36
|
+
status: string;
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
export interface MarketoGetLeadsResponse extends MarketoResponse {
|
|
41
|
+
result: [MarketoLeads];
|
|
42
|
+
}
|
|
43
|
+
export interface MarketoDeleteLeadsResponse extends MarketoResponse {
|
|
44
|
+
result: [
|
|
45
|
+
{
|
|
46
|
+
id: number;
|
|
47
|
+
status: string;
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export interface MarketoLeads {
|
|
52
|
+
id: number;
|
|
53
|
+
firstName: string;
|
|
54
|
+
lastName: string;
|
|
55
|
+
email: string;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
}
|
|
21
59
|
export declare function getAccessToken(request: RequestClient, settings: Settings): Promise<string>;
|
|
60
|
+
export {};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessToken = void 0;
|
|
3
|
+
exports.getAccessToken = exports.CSV_LIMIT = exports.REMOVE_USERS_ENDPOINT = exports.GET_LEADS_ENDPOINT = exports.BULK_IMPORT_ENDPOINT = exports.GET_LIST_ENDPOINT = exports.CREATE_LIST_ENDPOINT = exports.GET_FOLDER_ENDPOINT = void 0;
|
|
4
|
+
const API_VERSION = 'v1';
|
|
5
|
+
const OAUTH_ENDPOINT = 'identity/oauth/token';
|
|
6
|
+
exports.GET_FOLDER_ENDPOINT = `/rest/asset/${API_VERSION}/folder/byName.json?name=folderName`;
|
|
7
|
+
exports.CREATE_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticLists.json?folder=folderId&name=listName`;
|
|
8
|
+
exports.GET_LIST_ENDPOINT = `/rest/asset/${API_VERSION}/staticList/listId.json`;
|
|
9
|
+
exports.BULK_IMPORT_ENDPOINT = `/bulk/${API_VERSION}/leads.json?format=csv&listId=externalId`;
|
|
10
|
+
exports.GET_LEADS_ENDPOINT = `/rest/${API_VERSION}/leads.json?filterType=email&filterValues=emailsToFilter`;
|
|
11
|
+
exports.REMOVE_USERS_ENDPOINT = `/rest/${API_VERSION}/lists/listId/leads.json?id=idsToDelete`;
|
|
12
|
+
exports.CSV_LIMIT = 10000000;
|
|
4
13
|
async function getAccessToken(request, settings) {
|
|
5
|
-
const res = await request(`${settings.api_endpoint}
|
|
14
|
+
const res = await request(`${settings.api_endpoint}/${OAUTH_ENDPOINT}`, {
|
|
6
15
|
method: 'POST',
|
|
7
16
|
body: new URLSearchParams({
|
|
8
17
|
client_id: settings.client_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/constants.ts"],"names":[],"mappings":";;;AAGA,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,cAAc,GAAG,sBAAsB,CAAA;AAChC,QAAA,mBAAmB,GAAG,eAAe,WAAW,qCAAqC,CAAA;AACrF,QAAA,oBAAoB,GAAG,eAAe,WAAW,iDAAiD,CAAA;AAClG,QAAA,iBAAiB,GAAG,eAAe,WAAW,yBAAyB,CAAA;AACvE,QAAA,oBAAoB,GAAG,SAAS,WAAW,0CAA0C,CAAA;AACrF,QAAA,kBAAkB,GAAG,SAAS,WAAW,0DAA0D,CAAA;AACnG,QAAA,qBAAqB,GAAG,SAAS,WAAW,yCAAyC,CAAA;AAErF,QAAA,SAAS,GAAG,QAAQ,CAAA;AAyD1B,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,QAAkB;IAC7E,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,GAAG,QAAQ,CAAC,YAAY,IAAI,cAAc,EAAE,EAAE;QAC5F,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,eAAe,CAAC;YACxB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,aAAa,EAAE,QAAQ,CAAC,aAAa;YACrC,UAAU,EAAE,oBAAoB;SACjC,CAAC;KACH,CAAC,CAAA;IAEF,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAA;AAC9B,CAAC;AAXD,wCAWC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { Settings } from './generated-types';
|
|
3
|
+
import { Payload as AddToListPayload } from './addToList/generated-types';
|
|
4
|
+
import { Payload as RemoveFromListPayload } from './removeFromList/generated-types';
|
|
5
|
+
import { MarketoBulkImportResponse, MarketoDeleteLeadsResponse } from './constants';
|
|
6
|
+
export declare function addToList(request: RequestClient, settings: Settings, payloads: AddToListPayload[]): Promise<MarketoBulkImportResponse>;
|
|
7
|
+
export declare function removeFromList(request: RequestClient, settings: Settings, payloads: RemoveFromListPayload[]): Promise<MarketoDeleteLeadsResponse>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeFromList = exports.addToList = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
async function addToList(request, settings, payloads) {
|
|
7
|
+
const csvData = extractCSV(payloads);
|
|
8
|
+
const csvSize = Buffer.byteLength(csvData, 'utf8');
|
|
9
|
+
if (csvSize > constants_1.CSV_LIMIT) {
|
|
10
|
+
throw new actions_core_1.IntegrationError(`CSV data size exceeds limit of ${constants_1.CSV_LIMIT} bytes`, 'INVALID_REQUEST_DATA', 400);
|
|
11
|
+
}
|
|
12
|
+
const url = settings.api_endpoint + constants_1.BULK_IMPORT_ENDPOINT.replace('externalId', payloads[0].external_id);
|
|
13
|
+
const response = await request(url, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'multipart/form-data; boundary=--SEGMENT-DATA--'
|
|
17
|
+
},
|
|
18
|
+
body: createFormData(csvData)
|
|
19
|
+
});
|
|
20
|
+
if (!response.data.success) {
|
|
21
|
+
throw new actions_core_1.IntegrationError(response.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
22
|
+
}
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
exports.addToList = addToList;
|
|
26
|
+
async function removeFromList(request, settings, payloads) {
|
|
27
|
+
const emailsToRemove = extractEmails(payloads);
|
|
28
|
+
const getLeadsUrl = settings.api_endpoint + constants_1.GET_LEADS_ENDPOINT.replace('emailsToFilter', encodeURIComponent(emailsToRemove));
|
|
29
|
+
const getLeadsResponse = await request(getLeadsUrl, {
|
|
30
|
+
method: 'GET',
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!getLeadsResponse.data.success) {
|
|
36
|
+
throw new actions_core_1.IntegrationError(getLeadsResponse.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
37
|
+
}
|
|
38
|
+
const leadIds = extractLeadIds(getLeadsResponse.data.result);
|
|
39
|
+
const deleteLeadsUrl = settings.api_endpoint +
|
|
40
|
+
constants_1.REMOVE_USERS_ENDPOINT.replace('listId', payloads[0].external_id).replace('idsToDelete', leadIds);
|
|
41
|
+
const deleteLeadsResponse = await request(deleteLeadsUrl, {
|
|
42
|
+
method: 'DELETE',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!deleteLeadsResponse.data.success) {
|
|
48
|
+
throw new actions_core_1.IntegrationError(getLeadsResponse.data.errors[0].message, 'INVALID_RESPONSE', 400);
|
|
49
|
+
}
|
|
50
|
+
return deleteLeadsResponse.data;
|
|
51
|
+
}
|
|
52
|
+
exports.removeFromList = removeFromList;
|
|
53
|
+
function extractCSV(payloads) {
|
|
54
|
+
const header = 'Email\n';
|
|
55
|
+
const csvData = payloads.map((payload) => `${payload.email}`).join('\n');
|
|
56
|
+
return header + csvData;
|
|
57
|
+
}
|
|
58
|
+
function createFormData(csvData) {
|
|
59
|
+
const boundary = '--SEGMENT-DATA--';
|
|
60
|
+
const formData = `--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="leads.csv"\r\nContent-Type: text/csv\r\n\r\n${csvData}\r\n--${boundary}--\r\n`;
|
|
61
|
+
return formData;
|
|
62
|
+
}
|
|
63
|
+
function extractEmails(payloads) {
|
|
64
|
+
const emails = payloads.map((payload) => `${payload.email}`).join(',');
|
|
65
|
+
return emails;
|
|
66
|
+
}
|
|
67
|
+
function extractLeadIds(leads) {
|
|
68
|
+
const ids = leads.map((lead) => `${lead.id}`).join(',');
|
|
69
|
+
return ids;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/marketo-static-lists/functions.ts"],"names":[],"mappings":";;;AAAA,wDAAuE;AAIvE,2CASoB;AAEb,KAAK,UAAU,SAAS,CAAC,OAAsB,EAAE,QAAkB,EAAE,QAA4B;IACtG,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,OAAO,GAAG,qBAAS,EAAE;QACvB,MAAM,IAAI,+BAAgB,CAAC,kCAAkC,qBAAS,QAAQ,EAAE,sBAAsB,EAAE,GAAG,CAAC,CAAA;KAC7G;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,YAAY,GAAG,gCAAoB,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IAEvG,MAAM,QAAQ,GAAG,MAAM,OAAO,CAA4B,GAAG,EAAE;QAC7D,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,gDAAgD;SACjE;QACD,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,MAAM,IAAI,+BAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAA;KACrF;IACD,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC;AArBD,8BAqBC;AAEM,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,QAAkB,EAAE,QAAiC;IAChH,MAAM,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAE9C,MAA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Q,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxE,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;IACnC,MAAM,QAAQ,GAAG,KAAK,QAAQ,0GAA0G,OAAO,SAAS,QAAQ,QAAQ,CAAA;IACxK,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,QAA4B;IACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACtE,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAqB;IAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -57,53 +57,69 @@ const destination = {
|
|
|
57
57
|
full_audience_sync: false
|
|
58
58
|
},
|
|
59
59
|
async createAudience(request, createAudienceInput) {
|
|
60
|
-
const
|
|
60
|
+
const audienceName = createAudienceInput.audienceName;
|
|
61
61
|
const folder = createAudienceInput.settings.folder_name;
|
|
62
62
|
const endpoint = createAudienceInput.settings.api_endpoint;
|
|
63
63
|
const statsClient = createAudienceInput?.statsContext?.statsClient;
|
|
64
64
|
const statsTags = createAudienceInput?.statsContext?.tags;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (!audienceName) {
|
|
66
|
+
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
67
|
+
}
|
|
68
|
+
const accessToken = await constants_1.getAccessToken(request, createAudienceInput.settings);
|
|
69
|
+
const getFolderUrl = endpoint + constants_1.GET_FOLDER_ENDPOINT.replace('folderName', encodeURIComponent(folder));
|
|
70
|
+
const getFolderResponse = await request(getFolderUrl, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
headers: {
|
|
73
|
+
authorization: `Bearer ${accessToken}`
|
|
74
|
+
}
|
|
67
75
|
});
|
|
68
|
-
if (!
|
|
76
|
+
if (!getFolderResponse.data.success && getFolderResponse.data.errors) {
|
|
69
77
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
70
|
-
throw new actions_core_1.IntegrationError(`${
|
|
78
|
+
throw new actions_core_1.IntegrationError(`${getFolderResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
71
79
|
}
|
|
72
|
-
if (!
|
|
80
|
+
if (!getFolderResponse.data.result) {
|
|
73
81
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
74
82
|
throw new actions_core_1.IntegrationError(`A folder with the name ${folder} not found`, 'INVALID_REQUEST_DATA', 400);
|
|
75
83
|
}
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
84
|
+
const folderId = getFolderResponse.data.result[0].id.toString();
|
|
85
|
+
const createListUrl = endpoint +
|
|
86
|
+
constants_1.CREATE_LIST_ENDPOINT.replace('folderId', folderId).replace('listName', encodeURIComponent(audienceName));
|
|
87
|
+
const createListResponse = await request(createListUrl, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
authorization: `Bearer ${accessToken}`
|
|
91
|
+
}
|
|
79
92
|
});
|
|
80
|
-
if (!
|
|
93
|
+
if (!createListResponse.data.success && createListResponse.data.errors) {
|
|
81
94
|
statsClient?.incr('createAudience.error', 1, statsTags);
|
|
82
|
-
throw new actions_core_1.IntegrationError(`${
|
|
83
|
-
}
|
|
84
|
-
const external_id = create_list_response.data.result[0].id.toString();
|
|
85
|
-
if (external_id) {
|
|
86
|
-
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
95
|
+
throw new actions_core_1.IntegrationError(`${createListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
87
96
|
}
|
|
97
|
+
const externalId = createListResponse.data.result[0].id.toString();
|
|
98
|
+
statsClient?.incr('createAudience.success', 1, statsTags);
|
|
88
99
|
return {
|
|
89
|
-
externalId:
|
|
100
|
+
externalId: externalId
|
|
90
101
|
};
|
|
91
102
|
},
|
|
92
103
|
async getAudience(request, getAudienceInput) {
|
|
93
104
|
const endpoint = getAudienceInput.settings.api_endpoint;
|
|
94
|
-
const
|
|
105
|
+
const listId = getAudienceInput.externalId;
|
|
95
106
|
const statsClient = getAudienceInput?.statsContext?.statsClient;
|
|
96
107
|
const statsTags = getAudienceInput?.statsContext?.tags;
|
|
97
|
-
const
|
|
98
|
-
|
|
108
|
+
const accessToken = await constants_1.getAccessToken(request, getAudienceInput.settings);
|
|
109
|
+
const getListUrl = endpoint + constants_1.GET_LIST_ENDPOINT.replace('listId', listId);
|
|
110
|
+
const getListResponse = await request(getListUrl, {
|
|
111
|
+
method: 'GET',
|
|
112
|
+
headers: {
|
|
113
|
+
authorization: `Bearer ${accessToken}`
|
|
114
|
+
}
|
|
99
115
|
});
|
|
100
|
-
if (!
|
|
116
|
+
if (!getListResponse.data.success && getListResponse.data.errors) {
|
|
101
117
|
statsClient?.incr('getAudience.error', 1, statsTags);
|
|
102
|
-
throw new actions_core_1.IntegrationError(`${
|
|
118
|
+
throw new actions_core_1.IntegrationError(`${getListResponse.data.errors[0].message}`, 'INVALID_RESPONSE', 400);
|
|
103
119
|
}
|
|
104
120
|
statsClient?.incr('getAudience.success', 1, statsTags);
|
|
105
121
|
return {
|
|
106
|
-
externalId:
|
|
122
|
+
externalId: listId
|
|
107
123
|
};
|
|
108
124
|
}
|
|
109
125
|
},
|