@ridhamgolakiya/n8n-nodes-pinterest 1.0.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/credentials/PinterestOAuth2Api.credentials.ts +39 -0
- package/credentials/pinterest-dark.svg +4 -0
- package/credentials/pinterest-light.svg +4 -0
- package/credentials/pinterest.svg +4 -0
- package/dist/credentials/PinterestOAuth2Api.credentials.d.ts +12 -0
- package/dist/credentials/PinterestOAuth2Api.credentials.js +40 -0
- package/dist/credentials/pinterest-dark.svg +4 -0
- package/dist/credentials/pinterest-light.svg +4 -0
- package/dist/credentials/pinterest.svg +4 -0
- package/dist/nodes/Pinterest/Pinterest.node.d.ts +11 -0
- package/dist/nodes/Pinterest/Pinterest.node.js +1471 -0
- package/dist/nodes/Pinterest/pinterest-dark.svg +4 -0
- package/dist/nodes/Pinterest/pinterest-light.svg +4 -0
- package/dist/nodes/Pinterest/pinterest.svg +4 -0
- package/eslint.config.mjs +3 -0
- package/nodes/Pinterest/Pinterest.node.ts +1553 -0
- package/nodes/Pinterest/pinterest-dark.svg +4 -0
- package/nodes/Pinterest/pinterest-light.svg +4 -0
- package/nodes/Pinterest/pinterest.svg +4 -0
- package/package.json +35 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,1471 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pinterest = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class Pinterest {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Pinterest',
|
|
9
|
+
name: 'pinterest',
|
|
10
|
+
icon: { light: 'file:pinterest-light.svg', dark: 'file:pinterest-dark.svg' },
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
|
|
14
|
+
description: 'Consume Pinterest API v5',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Pinterest',
|
|
17
|
+
},
|
|
18
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
20
|
+
credentials: [
|
|
21
|
+
{
|
|
22
|
+
name: 'pinterestOAuth2Api',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
usableAsTool: true,
|
|
27
|
+
properties: [
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Resource',
|
|
30
|
+
name: 'resource',
|
|
31
|
+
type: 'options',
|
|
32
|
+
noDataExpression: true,
|
|
33
|
+
options: [
|
|
34
|
+
{
|
|
35
|
+
name: 'Ad Account',
|
|
36
|
+
value: 'adAccount',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Board',
|
|
40
|
+
value: 'board',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Pin',
|
|
44
|
+
value: 'pin',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'User Account',
|
|
48
|
+
value: 'userAccount',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 'pin',
|
|
52
|
+
},
|
|
53
|
+
// Ad Account operations
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Operation',
|
|
56
|
+
name: 'operation',
|
|
57
|
+
type: 'options',
|
|
58
|
+
noDataExpression: true,
|
|
59
|
+
displayOptions: {
|
|
60
|
+
show: {
|
|
61
|
+
resource: [
|
|
62
|
+
'adAccount',
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
options: [
|
|
67
|
+
{
|
|
68
|
+
name: 'Get Many',
|
|
69
|
+
value: 'getAll',
|
|
70
|
+
description: 'Get many ad accounts',
|
|
71
|
+
action: 'Get many ad accounts',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Get Many Campaigns',
|
|
75
|
+
value: 'getCampaigns',
|
|
76
|
+
description: 'Get many campaigns under an ad account',
|
|
77
|
+
action: 'Get many campaigns',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
default: 'getAll',
|
|
81
|
+
},
|
|
82
|
+
// Board operations
|
|
83
|
+
{
|
|
84
|
+
displayName: 'Operation',
|
|
85
|
+
name: 'operation',
|
|
86
|
+
type: 'options',
|
|
87
|
+
noDataExpression: true,
|
|
88
|
+
displayOptions: {
|
|
89
|
+
show: {
|
|
90
|
+
resource: [
|
|
91
|
+
'board',
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
options: [
|
|
96
|
+
{
|
|
97
|
+
name: 'Create',
|
|
98
|
+
value: 'create',
|
|
99
|
+
description: 'Create a new board',
|
|
100
|
+
action: 'Create a board',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'Get',
|
|
104
|
+
value: 'get',
|
|
105
|
+
description: 'Get a board by ID',
|
|
106
|
+
action: 'Get a board',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'Get Many',
|
|
110
|
+
value: 'getAll',
|
|
111
|
+
description: 'Get many boards',
|
|
112
|
+
action: 'Get many boards',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
default: 'getAll',
|
|
116
|
+
},
|
|
117
|
+
// Pin operations
|
|
118
|
+
{
|
|
119
|
+
displayName: 'Operation',
|
|
120
|
+
name: 'operation',
|
|
121
|
+
type: 'options',
|
|
122
|
+
noDataExpression: true,
|
|
123
|
+
displayOptions: {
|
|
124
|
+
show: {
|
|
125
|
+
resource: [
|
|
126
|
+
'pin',
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
options: [
|
|
131
|
+
{
|
|
132
|
+
name: 'Create',
|
|
133
|
+
value: 'create',
|
|
134
|
+
description: 'Create a new pin',
|
|
135
|
+
action: 'Create a pin',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'Get',
|
|
139
|
+
value: 'get',
|
|
140
|
+
description: 'Get a pin by ID',
|
|
141
|
+
action: 'Get a pin',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'Get Analytics',
|
|
145
|
+
value: 'getAnalytics',
|
|
146
|
+
description: 'Get performance metrics for a specific Pin',
|
|
147
|
+
action: 'Get pin analytics',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'Get Many',
|
|
151
|
+
value: 'getAll',
|
|
152
|
+
description: 'Get many pins',
|
|
153
|
+
action: 'Get many pins',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
default: 'getAll',
|
|
157
|
+
},
|
|
158
|
+
// User Account operations
|
|
159
|
+
{
|
|
160
|
+
displayName: 'Operation',
|
|
161
|
+
name: 'operation',
|
|
162
|
+
type: 'options',
|
|
163
|
+
noDataExpression: true,
|
|
164
|
+
displayOptions: {
|
|
165
|
+
show: {
|
|
166
|
+
resource: [
|
|
167
|
+
'userAccount',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
options: [
|
|
172
|
+
{
|
|
173
|
+
name: 'Get Analytics',
|
|
174
|
+
value: 'getAnalytics',
|
|
175
|
+
description: 'Get user account analytics',
|
|
176
|
+
action: 'Get user account analytics',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'Get Top Pins',
|
|
180
|
+
value: 'getTopPins',
|
|
181
|
+
action: 'Get top pins',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
default: 'getAnalytics',
|
|
185
|
+
},
|
|
186
|
+
// --- AD ACCOUNT FIELDS ---
|
|
187
|
+
// Ad Account Get Campaigns fields
|
|
188
|
+
{
|
|
189
|
+
displayName: 'Ad Account Name or ID',
|
|
190
|
+
name: 'adAccountId',
|
|
191
|
+
type: 'options',
|
|
192
|
+
typeOptions: {
|
|
193
|
+
loadOptionsMethod: 'getAdAccounts',
|
|
194
|
+
},
|
|
195
|
+
required: true,
|
|
196
|
+
displayOptions: {
|
|
197
|
+
show: {
|
|
198
|
+
resource: [
|
|
199
|
+
'adAccount',
|
|
200
|
+
],
|
|
201
|
+
operation: [
|
|
202
|
+
'getCampaigns',
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
default: '',
|
|
207
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
208
|
+
},
|
|
209
|
+
// Ad Account GetAll fields
|
|
210
|
+
{
|
|
211
|
+
displayName: 'Return All',
|
|
212
|
+
name: 'returnAll',
|
|
213
|
+
type: 'boolean',
|
|
214
|
+
displayOptions: {
|
|
215
|
+
show: {
|
|
216
|
+
resource: [
|
|
217
|
+
'adAccount',
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
default: false,
|
|
222
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
displayName: 'Limit',
|
|
226
|
+
name: 'limit',
|
|
227
|
+
type: 'number',
|
|
228
|
+
displayOptions: {
|
|
229
|
+
show: {
|
|
230
|
+
resource: [
|
|
231
|
+
'adAccount',
|
|
232
|
+
],
|
|
233
|
+
returnAll: [
|
|
234
|
+
false,
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
typeOptions: {
|
|
239
|
+
minValue: 1,
|
|
240
|
+
maxValue: 250,
|
|
241
|
+
},
|
|
242
|
+
default: 50,
|
|
243
|
+
description: 'Max number of results to return',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
displayName: 'Additional Fields',
|
|
247
|
+
name: 'additionalFieldsAdAccount',
|
|
248
|
+
type: 'collection',
|
|
249
|
+
placeholder: 'Add Field',
|
|
250
|
+
default: {},
|
|
251
|
+
displayOptions: {
|
|
252
|
+
show: {
|
|
253
|
+
resource: [
|
|
254
|
+
'adAccount',
|
|
255
|
+
],
|
|
256
|
+
operation: [
|
|
257
|
+
'getAll',
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
options: [
|
|
262
|
+
{
|
|
263
|
+
displayName: 'Include Shared Accounts',
|
|
264
|
+
name: 'includeSharedAccounts',
|
|
265
|
+
type: 'boolean',
|
|
266
|
+
default: false,
|
|
267
|
+
description: 'Whether to include shared accounts in the results',
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
displayName: 'Additional Fields',
|
|
273
|
+
name: 'additionalFieldsCampaign',
|
|
274
|
+
type: 'collection',
|
|
275
|
+
placeholder: 'Add Field',
|
|
276
|
+
default: {},
|
|
277
|
+
displayOptions: {
|
|
278
|
+
show: {
|
|
279
|
+
resource: [
|
|
280
|
+
'adAccount',
|
|
281
|
+
],
|
|
282
|
+
operation: [
|
|
283
|
+
'getCampaigns',
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
options: [
|
|
288
|
+
{
|
|
289
|
+
displayName: 'Entity Statuses',
|
|
290
|
+
name: 'entityStatuses',
|
|
291
|
+
type: 'multiOptions',
|
|
292
|
+
options: [
|
|
293
|
+
{
|
|
294
|
+
name: 'Active',
|
|
295
|
+
value: 'ACTIVE',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'Archived',
|
|
299
|
+
value: 'ARCHIVED',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: 'Deleted Draft',
|
|
303
|
+
value: 'DELETED_DRAFT',
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
name: 'Draft',
|
|
307
|
+
value: 'DRAFT',
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'Paused',
|
|
311
|
+
value: 'PAUSED',
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
default: ['ACTIVE'],
|
|
315
|
+
description: 'Entity statuses to filter by',
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
// --- BOARD FIELDS ---
|
|
320
|
+
// Board Create fields
|
|
321
|
+
{
|
|
322
|
+
displayName: 'Name',
|
|
323
|
+
name: 'name',
|
|
324
|
+
type: 'string',
|
|
325
|
+
required: true,
|
|
326
|
+
displayOptions: {
|
|
327
|
+
show: {
|
|
328
|
+
resource: [
|
|
329
|
+
'board',
|
|
330
|
+
],
|
|
331
|
+
operation: [
|
|
332
|
+
'create',
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
default: '',
|
|
337
|
+
description: 'The name of the new board',
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
displayName: 'Description',
|
|
341
|
+
name: 'description',
|
|
342
|
+
type: 'string',
|
|
343
|
+
displayOptions: {
|
|
344
|
+
show: {
|
|
345
|
+
resource: [
|
|
346
|
+
'board',
|
|
347
|
+
],
|
|
348
|
+
operation: [
|
|
349
|
+
'create',
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
default: '',
|
|
354
|
+
description: 'A description for the board',
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
displayName: 'Privacy',
|
|
358
|
+
name: 'privacy',
|
|
359
|
+
type: 'options',
|
|
360
|
+
displayOptions: {
|
|
361
|
+
show: {
|
|
362
|
+
resource: [
|
|
363
|
+
'board',
|
|
364
|
+
],
|
|
365
|
+
operation: [
|
|
366
|
+
'create',
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
options: [
|
|
371
|
+
{
|
|
372
|
+
name: 'Protected',
|
|
373
|
+
value: 'PROTECTED',
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
name: 'Public',
|
|
377
|
+
value: 'PUBLIC',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: 'Secret',
|
|
381
|
+
value: 'SECRET',
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
default: 'PUBLIC',
|
|
385
|
+
description: 'The privacy level of the board',
|
|
386
|
+
},
|
|
387
|
+
// Board Get fields
|
|
388
|
+
{
|
|
389
|
+
displayName: 'Board ID',
|
|
390
|
+
name: 'boardId',
|
|
391
|
+
type: 'string',
|
|
392
|
+
required: true,
|
|
393
|
+
displayOptions: {
|
|
394
|
+
show: {
|
|
395
|
+
resource: [
|
|
396
|
+
'board',
|
|
397
|
+
],
|
|
398
|
+
operation: [
|
|
399
|
+
'get',
|
|
400
|
+
],
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
default: '',
|
|
404
|
+
description: 'The unique identifier of the board',
|
|
405
|
+
},
|
|
406
|
+
// Board GetAll fields
|
|
407
|
+
{
|
|
408
|
+
displayName: 'Return All',
|
|
409
|
+
name: 'returnAll',
|
|
410
|
+
type: 'boolean',
|
|
411
|
+
displayOptions: {
|
|
412
|
+
show: {
|
|
413
|
+
resource: [
|
|
414
|
+
'board',
|
|
415
|
+
],
|
|
416
|
+
operation: [
|
|
417
|
+
'getAll',
|
|
418
|
+
],
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
default: false,
|
|
422
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
displayName: 'Limit',
|
|
426
|
+
name: 'limit',
|
|
427
|
+
type: 'number',
|
|
428
|
+
displayOptions: {
|
|
429
|
+
show: {
|
|
430
|
+
resource: [
|
|
431
|
+
'board',
|
|
432
|
+
],
|
|
433
|
+
operation: [
|
|
434
|
+
'getAll',
|
|
435
|
+
],
|
|
436
|
+
returnAll: [
|
|
437
|
+
false,
|
|
438
|
+
],
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
typeOptions: {
|
|
442
|
+
minValue: 1,
|
|
443
|
+
maxValue: 250,
|
|
444
|
+
},
|
|
445
|
+
default: 50,
|
|
446
|
+
description: 'Max number of results to return',
|
|
447
|
+
},
|
|
448
|
+
// --- PIN FIELDS ---
|
|
449
|
+
// Pin Create fields
|
|
450
|
+
{
|
|
451
|
+
displayName: 'Board Name or ID',
|
|
452
|
+
name: 'boardId',
|
|
453
|
+
type: 'options',
|
|
454
|
+
typeOptions: {
|
|
455
|
+
loadOptionsMethod: 'getBoards',
|
|
456
|
+
},
|
|
457
|
+
required: true,
|
|
458
|
+
displayOptions: {
|
|
459
|
+
show: {
|
|
460
|
+
resource: [
|
|
461
|
+
'pin',
|
|
462
|
+
],
|
|
463
|
+
operation: [
|
|
464
|
+
'create',
|
|
465
|
+
],
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
default: '',
|
|
469
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
displayName: 'Media Source (Image URL)',
|
|
473
|
+
name: 'imageUrl',
|
|
474
|
+
type: 'string',
|
|
475
|
+
required: true,
|
|
476
|
+
displayOptions: {
|
|
477
|
+
show: {
|
|
478
|
+
resource: [
|
|
479
|
+
'pin',
|
|
480
|
+
],
|
|
481
|
+
operation: [
|
|
482
|
+
'create',
|
|
483
|
+
],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
default: '',
|
|
487
|
+
description: 'The URL of the image to Pin',
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
displayName: 'Title',
|
|
491
|
+
name: 'title',
|
|
492
|
+
type: 'string',
|
|
493
|
+
displayOptions: {
|
|
494
|
+
show: {
|
|
495
|
+
resource: [
|
|
496
|
+
'pin',
|
|
497
|
+
],
|
|
498
|
+
operation: [
|
|
499
|
+
'create',
|
|
500
|
+
],
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
default: '',
|
|
504
|
+
description: 'Title of the Pin (max 100 characters)',
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
displayName: 'Description',
|
|
508
|
+
name: 'description',
|
|
509
|
+
type: 'string',
|
|
510
|
+
displayOptions: {
|
|
511
|
+
show: {
|
|
512
|
+
resource: [
|
|
513
|
+
'pin',
|
|
514
|
+
],
|
|
515
|
+
operation: [
|
|
516
|
+
'create',
|
|
517
|
+
],
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
default: '',
|
|
521
|
+
description: 'Description of the Pin (max 800 characters)',
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
displayName: 'Link',
|
|
525
|
+
name: 'link',
|
|
526
|
+
type: 'string',
|
|
527
|
+
displayOptions: {
|
|
528
|
+
show: {
|
|
529
|
+
resource: [
|
|
530
|
+
'pin',
|
|
531
|
+
],
|
|
532
|
+
operation: [
|
|
533
|
+
'create',
|
|
534
|
+
],
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
default: '',
|
|
538
|
+
description: 'The URL the Pin should link back to',
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
displayName: 'Alt Text',
|
|
542
|
+
name: 'altText',
|
|
543
|
+
type: 'string',
|
|
544
|
+
displayOptions: {
|
|
545
|
+
show: {
|
|
546
|
+
resource: [
|
|
547
|
+
'pin',
|
|
548
|
+
],
|
|
549
|
+
operation: [
|
|
550
|
+
'create',
|
|
551
|
+
],
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
default: '',
|
|
555
|
+
description: 'Alternative text description of the image (max 500 characters)',
|
|
556
|
+
},
|
|
557
|
+
// Pin Get fields
|
|
558
|
+
{
|
|
559
|
+
displayName: 'Pin ID',
|
|
560
|
+
name: 'pinId',
|
|
561
|
+
type: 'string',
|
|
562
|
+
required: true,
|
|
563
|
+
displayOptions: {
|
|
564
|
+
show: {
|
|
565
|
+
resource: [
|
|
566
|
+
'pin',
|
|
567
|
+
],
|
|
568
|
+
operation: [
|
|
569
|
+
'get',
|
|
570
|
+
'getAnalytics',
|
|
571
|
+
],
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
default: '',
|
|
575
|
+
description: 'The unique identifier of the Pin',
|
|
576
|
+
},
|
|
577
|
+
// Pin Analytics fields
|
|
578
|
+
{
|
|
579
|
+
displayName: 'Start Date',
|
|
580
|
+
name: 'startDate',
|
|
581
|
+
type: 'dateTime',
|
|
582
|
+
required: true,
|
|
583
|
+
displayOptions: {
|
|
584
|
+
show: {
|
|
585
|
+
resource: [
|
|
586
|
+
'pin',
|
|
587
|
+
],
|
|
588
|
+
operation: [
|
|
589
|
+
'getAnalytics',
|
|
590
|
+
],
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
default: '',
|
|
594
|
+
description: 'Metric report start date (UTC) in YYYY-MM-DD format',
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
displayName: 'End Date',
|
|
598
|
+
name: 'endDate',
|
|
599
|
+
type: 'dateTime',
|
|
600
|
+
required: true,
|
|
601
|
+
displayOptions: {
|
|
602
|
+
show: {
|
|
603
|
+
resource: [
|
|
604
|
+
'pin',
|
|
605
|
+
],
|
|
606
|
+
operation: [
|
|
607
|
+
'getAnalytics',
|
|
608
|
+
],
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
default: '',
|
|
612
|
+
description: 'Metric report end date (UTC) in YYYY-MM-DD format',
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
displayName: 'Metric Types',
|
|
616
|
+
name: 'metricTypes',
|
|
617
|
+
type: 'multiOptions',
|
|
618
|
+
required: true,
|
|
619
|
+
displayOptions: {
|
|
620
|
+
show: {
|
|
621
|
+
resource: [
|
|
622
|
+
'pin',
|
|
623
|
+
],
|
|
624
|
+
operation: [
|
|
625
|
+
'getAnalytics',
|
|
626
|
+
],
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
options: [
|
|
630
|
+
{
|
|
631
|
+
name: 'Engagement',
|
|
632
|
+
value: 'ENGAGEMENT',
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: 'Impression',
|
|
636
|
+
value: 'IMPRESSION',
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
name: 'Outbound Click',
|
|
640
|
+
value: 'OUTBOUND_CLICK',
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: 'Pin Click',
|
|
644
|
+
value: 'PIN_CLICK',
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
name: 'Save',
|
|
648
|
+
value: 'SAVE',
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: 'Video MRC View',
|
|
652
|
+
value: 'VIDEO_MRC_VIEW',
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: 'Video Start View',
|
|
656
|
+
value: 'VIDEO_START_VIEW',
|
|
657
|
+
},
|
|
658
|
+
],
|
|
659
|
+
default: ['IMPRESSION', 'SAVE', 'PIN_CLICK', 'OUTBOUND_CLICK'],
|
|
660
|
+
description: 'Metric types to retrieve',
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
displayName: 'Additional Fields',
|
|
664
|
+
name: 'additionalFieldsPinAnalytics',
|
|
665
|
+
type: 'collection',
|
|
666
|
+
placeholder: 'Add Field',
|
|
667
|
+
default: {},
|
|
668
|
+
displayOptions: {
|
|
669
|
+
show: {
|
|
670
|
+
resource: [
|
|
671
|
+
'pin',
|
|
672
|
+
],
|
|
673
|
+
operation: [
|
|
674
|
+
'getAnalytics',
|
|
675
|
+
],
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
options: [
|
|
679
|
+
{
|
|
680
|
+
displayName: 'Ad Account ID',
|
|
681
|
+
name: 'adAccountId',
|
|
682
|
+
type: 'string',
|
|
683
|
+
default: '',
|
|
684
|
+
description: 'Unique identifier of an ad account',
|
|
685
|
+
},
|
|
686
|
+
],
|
|
687
|
+
},
|
|
688
|
+
// Pin GetAll fields
|
|
689
|
+
{
|
|
690
|
+
displayName: 'Board Name or ID',
|
|
691
|
+
name: 'boardId',
|
|
692
|
+
type: 'options',
|
|
693
|
+
typeOptions: {
|
|
694
|
+
loadOptionsMethod: 'getBoards',
|
|
695
|
+
},
|
|
696
|
+
displayOptions: {
|
|
697
|
+
show: {
|
|
698
|
+
resource: [
|
|
699
|
+
'pin',
|
|
700
|
+
],
|
|
701
|
+
operation: [
|
|
702
|
+
'getAll',
|
|
703
|
+
],
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
default: '',
|
|
707
|
+
description: 'Filter pins by a specific board. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
displayName: 'Return All',
|
|
711
|
+
name: 'returnAll',
|
|
712
|
+
type: 'boolean',
|
|
713
|
+
displayOptions: {
|
|
714
|
+
show: {
|
|
715
|
+
resource: [
|
|
716
|
+
'pin',
|
|
717
|
+
],
|
|
718
|
+
operation: [
|
|
719
|
+
'getAll',
|
|
720
|
+
],
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
default: false,
|
|
724
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
displayName: 'Limit',
|
|
728
|
+
name: 'limit',
|
|
729
|
+
type: 'number',
|
|
730
|
+
displayOptions: {
|
|
731
|
+
show: {
|
|
732
|
+
resource: [
|
|
733
|
+
'pin',
|
|
734
|
+
],
|
|
735
|
+
operation: [
|
|
736
|
+
'getAll',
|
|
737
|
+
],
|
|
738
|
+
returnAll: [
|
|
739
|
+
false,
|
|
740
|
+
],
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
typeOptions: {
|
|
744
|
+
minValue: 1,
|
|
745
|
+
maxValue: 250,
|
|
746
|
+
},
|
|
747
|
+
default: 50,
|
|
748
|
+
description: 'Max number of results to return',
|
|
749
|
+
},
|
|
750
|
+
// --- USER ACCOUNT FIELDS ---
|
|
751
|
+
// User Account Common fields
|
|
752
|
+
{
|
|
753
|
+
displayName: 'Start Date',
|
|
754
|
+
name: 'startDate',
|
|
755
|
+
type: 'dateTime',
|
|
756
|
+
required: true,
|
|
757
|
+
displayOptions: {
|
|
758
|
+
show: {
|
|
759
|
+
resource: [
|
|
760
|
+
'userAccount',
|
|
761
|
+
],
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
default: '',
|
|
765
|
+
description: 'Metric report start date (UTC) in YYYY-MM-DD format',
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
displayName: 'End Date',
|
|
769
|
+
name: 'endDate',
|
|
770
|
+
type: 'dateTime',
|
|
771
|
+
required: true,
|
|
772
|
+
displayOptions: {
|
|
773
|
+
show: {
|
|
774
|
+
resource: [
|
|
775
|
+
'userAccount',
|
|
776
|
+
],
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
default: '',
|
|
780
|
+
description: 'Metric report end date (UTC) in YYYY-MM-DD format',
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
displayName: 'Sort By',
|
|
784
|
+
name: 'sortBy',
|
|
785
|
+
type: 'options',
|
|
786
|
+
required: true,
|
|
787
|
+
displayOptions: {
|
|
788
|
+
show: {
|
|
789
|
+
resource: [
|
|
790
|
+
'userAccount',
|
|
791
|
+
],
|
|
792
|
+
operation: [
|
|
793
|
+
'getTopPins',
|
|
794
|
+
],
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
options: [
|
|
798
|
+
{
|
|
799
|
+
name: 'Engagement',
|
|
800
|
+
value: 'ENGAGEMENT',
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
name: 'Impression',
|
|
804
|
+
value: 'IMPRESSION',
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: 'Outbound Click',
|
|
808
|
+
value: 'OUTBOUND_CLICK',
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
name: 'Pin Click',
|
|
812
|
+
value: 'PIN_CLICK',
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
name: 'Save',
|
|
816
|
+
value: 'SAVE',
|
|
817
|
+
},
|
|
818
|
+
],
|
|
819
|
+
default: 'IMPRESSION',
|
|
820
|
+
description: 'The metric used to sort the top pins',
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
displayName: 'Additional Fields',
|
|
824
|
+
name: 'additionalFieldsUserAnalytics',
|
|
825
|
+
type: 'collection',
|
|
826
|
+
placeholder: 'Add Field',
|
|
827
|
+
default: {},
|
|
828
|
+
displayOptions: {
|
|
829
|
+
show: {
|
|
830
|
+
resource: [
|
|
831
|
+
'userAccount',
|
|
832
|
+
],
|
|
833
|
+
operation: [
|
|
834
|
+
'getAnalytics',
|
|
835
|
+
],
|
|
836
|
+
},
|
|
837
|
+
},
|
|
838
|
+
options: [
|
|
839
|
+
{
|
|
840
|
+
displayName: 'Ad Account ID',
|
|
841
|
+
name: 'adAccountId',
|
|
842
|
+
type: 'string',
|
|
843
|
+
default: '',
|
|
844
|
+
description: 'Unique identifier of an ad account',
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
displayName: 'App Types',
|
|
848
|
+
name: 'appTypes',
|
|
849
|
+
type: 'options',
|
|
850
|
+
options: [
|
|
851
|
+
{
|
|
852
|
+
name: 'All',
|
|
853
|
+
value: 'ALL',
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
name: 'Mobile',
|
|
857
|
+
value: 'MOBILE',
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
name: 'Tablet',
|
|
861
|
+
value: 'TABLET',
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: 'Web',
|
|
865
|
+
value: 'WEB',
|
|
866
|
+
},
|
|
867
|
+
],
|
|
868
|
+
default: 'ALL',
|
|
869
|
+
description: 'Filter by app or device type',
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
displayName: 'From Claim Content',
|
|
873
|
+
name: 'fromClaimContent',
|
|
874
|
+
type: 'options',
|
|
875
|
+
options: [
|
|
876
|
+
{
|
|
877
|
+
name: 'Both',
|
|
878
|
+
value: 'BOTH',
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
name: 'Declared',
|
|
882
|
+
value: 'DECLARED',
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
name: 'Linked',
|
|
886
|
+
value: 'LINKED',
|
|
887
|
+
},
|
|
888
|
+
],
|
|
889
|
+
default: 'BOTH',
|
|
890
|
+
description: 'Filter on Pins that match your claimed domain',
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
displayName: 'Pin Format',
|
|
894
|
+
name: 'pinFormat',
|
|
895
|
+
type: 'options',
|
|
896
|
+
options: [
|
|
897
|
+
{
|
|
898
|
+
name: 'All',
|
|
899
|
+
value: 'ALL',
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
name: 'Organic',
|
|
903
|
+
value: 'ORGANIC',
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
name: 'Product',
|
|
907
|
+
value: 'PRODUCT',
|
|
908
|
+
},
|
|
909
|
+
],
|
|
910
|
+
default: 'ALL',
|
|
911
|
+
description: 'Filter by Pin format',
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
displayName: 'Split Field',
|
|
915
|
+
name: 'splitField',
|
|
916
|
+
type: 'options',
|
|
917
|
+
options: [
|
|
918
|
+
{
|
|
919
|
+
name: 'App Type',
|
|
920
|
+
value: 'APP_TYPE',
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
name: 'No Split',
|
|
924
|
+
value: 'NO_SPLIT',
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
name: 'Owned Status',
|
|
928
|
+
value: 'OWNED_STATUS',
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
name: 'Pin Format',
|
|
932
|
+
value: 'PIN_FORMAT',
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
name: 'Source',
|
|
936
|
+
value: 'SOURCE',
|
|
937
|
+
},
|
|
938
|
+
],
|
|
939
|
+
default: 'NO_SPLIT',
|
|
940
|
+
description: 'How to split the metrics',
|
|
941
|
+
},
|
|
942
|
+
],
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
displayName: 'Additional Fields',
|
|
946
|
+
name: 'additionalFieldsTopPins',
|
|
947
|
+
type: 'collection',
|
|
948
|
+
placeholder: 'Add Field',
|
|
949
|
+
default: {},
|
|
950
|
+
displayOptions: {
|
|
951
|
+
show: {
|
|
952
|
+
resource: [
|
|
953
|
+
'userAccount',
|
|
954
|
+
],
|
|
955
|
+
operation: [
|
|
956
|
+
'getTopPins',
|
|
957
|
+
],
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
options: [
|
|
961
|
+
{
|
|
962
|
+
displayName: 'Ad Account ID',
|
|
963
|
+
name: 'adAccountId',
|
|
964
|
+
type: 'string',
|
|
965
|
+
default: '',
|
|
966
|
+
description: 'Unique identifier of an ad account',
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
displayName: 'App Types',
|
|
970
|
+
name: 'appTypes',
|
|
971
|
+
type: 'options',
|
|
972
|
+
options: [
|
|
973
|
+
{
|
|
974
|
+
name: 'All',
|
|
975
|
+
value: 'ALL',
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
name: 'Mobile',
|
|
979
|
+
value: 'MOBILE',
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
name: 'Tablet',
|
|
983
|
+
value: 'TABLET',
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
name: 'Web',
|
|
987
|
+
value: 'WEB',
|
|
988
|
+
},
|
|
989
|
+
],
|
|
990
|
+
default: 'ALL',
|
|
991
|
+
description: 'Filter by app or device type',
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
displayName: 'Content Type',
|
|
995
|
+
name: 'contentType',
|
|
996
|
+
type: 'options',
|
|
997
|
+
options: [
|
|
998
|
+
{
|
|
999
|
+
name: 'All',
|
|
1000
|
+
value: 'ALL',
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
name: 'Organic',
|
|
1004
|
+
value: 'ORGANIC',
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
name: 'Paid',
|
|
1008
|
+
value: 'PAID',
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
1011
|
+
default: 'ALL',
|
|
1012
|
+
description: 'Filter to paid or organic data',
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
displayName: 'From Claimed Content',
|
|
1016
|
+
name: 'fromClaimedContent',
|
|
1017
|
+
type: 'options',
|
|
1018
|
+
options: [
|
|
1019
|
+
{
|
|
1020
|
+
name: 'Both',
|
|
1021
|
+
value: 'BOTH',
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
name: 'Claimed',
|
|
1025
|
+
value: 'CLAIMED',
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
name: 'Other',
|
|
1029
|
+
value: 'OTHER',
|
|
1030
|
+
},
|
|
1031
|
+
],
|
|
1032
|
+
default: 'BOTH',
|
|
1033
|
+
description: 'Filter on Pins that match your claimed domain',
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
displayName: 'Limit',
|
|
1037
|
+
name: 'limit',
|
|
1038
|
+
type: 'number',
|
|
1039
|
+
typeOptions: {
|
|
1040
|
+
minValue: 1,
|
|
1041
|
+
maxValue: 50,
|
|
1042
|
+
},
|
|
1043
|
+
default: 50,
|
|
1044
|
+
description: 'Max number of results to return',
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
displayName: 'Pin Format',
|
|
1048
|
+
name: 'pinFormat',
|
|
1049
|
+
type: 'options',
|
|
1050
|
+
options: [
|
|
1051
|
+
{
|
|
1052
|
+
name: 'Ads Idea',
|
|
1053
|
+
value: 'ADS_IDEA',
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: 'Ads Product',
|
|
1057
|
+
value: 'ADS_PRODUCT',
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
name: 'Ads Standard',
|
|
1061
|
+
value: 'ADS_STANDARD',
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
name: 'Ads Video',
|
|
1065
|
+
value: 'ADS_VIDEO',
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
name: 'All',
|
|
1069
|
+
value: 'ALL',
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
name: 'Organic Image',
|
|
1073
|
+
value: 'ORGANIC_IMAGE',
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: 'Organic Product',
|
|
1077
|
+
value: 'ORGANIC_PRODUCT',
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
name: 'Organic Video',
|
|
1081
|
+
value: 'ORGANIC_VIDEO',
|
|
1082
|
+
},
|
|
1083
|
+
],
|
|
1084
|
+
default: 'ALL',
|
|
1085
|
+
description: 'Filter by Pin format',
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
displayName: 'Source',
|
|
1089
|
+
name: 'source',
|
|
1090
|
+
type: 'options',
|
|
1091
|
+
options: [
|
|
1092
|
+
{
|
|
1093
|
+
name: 'All',
|
|
1094
|
+
value: 'ALL',
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
name: 'Others',
|
|
1098
|
+
value: 'OTHERS',
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
name: 'Yours',
|
|
1102
|
+
value: 'YOURS',
|
|
1103
|
+
},
|
|
1104
|
+
],
|
|
1105
|
+
default: 'ALL',
|
|
1106
|
+
description: 'Filter activity from Pins created/saved by you vs. others.',
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
},
|
|
1110
|
+
],
|
|
1111
|
+
};
|
|
1112
|
+
this.methods = {
|
|
1113
|
+
loadOptions: {
|
|
1114
|
+
async getBoards() {
|
|
1115
|
+
const returnData = [];
|
|
1116
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1117
|
+
method: 'GET',
|
|
1118
|
+
url: 'https://api.pinterest.com/v5/boards',
|
|
1119
|
+
json: true,
|
|
1120
|
+
});
|
|
1121
|
+
const boards = response.items || [];
|
|
1122
|
+
for (const board of boards) {
|
|
1123
|
+
returnData.push({
|
|
1124
|
+
name: board.name,
|
|
1125
|
+
value: board.id,
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
return returnData;
|
|
1129
|
+
},
|
|
1130
|
+
async getAdAccounts() {
|
|
1131
|
+
const returnData = [];
|
|
1132
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1133
|
+
method: 'GET',
|
|
1134
|
+
url: 'https://api.pinterest.com/v5/ad_accounts',
|
|
1135
|
+
json: true,
|
|
1136
|
+
});
|
|
1137
|
+
const accounts = response.items || [];
|
|
1138
|
+
for (const account of accounts) {
|
|
1139
|
+
returnData.push({
|
|
1140
|
+
name: account.name,
|
|
1141
|
+
value: account.id,
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
return returnData;
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
async execute() {
|
|
1150
|
+
const items = this.getInputData();
|
|
1151
|
+
const returnData = [];
|
|
1152
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
1153
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
1154
|
+
const toExecutionData = (data, itemIndex) => {
|
|
1155
|
+
return this.helpers.returnJsonArray(data).map((item) => {
|
|
1156
|
+
item.pairedItem = { item: itemIndex };
|
|
1157
|
+
return item;
|
|
1158
|
+
});
|
|
1159
|
+
};
|
|
1160
|
+
for (let i = 0; i < items.length; i++) {
|
|
1161
|
+
try {
|
|
1162
|
+
if (resource === 'adAccount') {
|
|
1163
|
+
if (operation === 'getAll') {
|
|
1164
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
1165
|
+
const limit = this.getNodeParameter('limit', i, 50);
|
|
1166
|
+
const additionalFields = this.getNodeParameter('additionalFieldsAdAccount', i);
|
|
1167
|
+
const qs = {};
|
|
1168
|
+
if (additionalFields.includeSharedAccounts) {
|
|
1169
|
+
qs.include_shared_accounts = additionalFields.includeSharedAccounts;
|
|
1170
|
+
}
|
|
1171
|
+
let responseData;
|
|
1172
|
+
let bookmark = undefined;
|
|
1173
|
+
const accounts = [];
|
|
1174
|
+
do {
|
|
1175
|
+
const currentQs = { ...qs };
|
|
1176
|
+
if (bookmark) {
|
|
1177
|
+
currentQs.bookmark = bookmark;
|
|
1178
|
+
}
|
|
1179
|
+
if (!returnAll && limit) {
|
|
1180
|
+
currentQs.page_size = Math.min(limit - accounts.length, 250);
|
|
1181
|
+
}
|
|
1182
|
+
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1183
|
+
method: 'GET',
|
|
1184
|
+
url: 'https://api.pinterest.com/v5/ad_accounts',
|
|
1185
|
+
qs: currentQs,
|
|
1186
|
+
json: true,
|
|
1187
|
+
});
|
|
1188
|
+
accounts.push(...(responseData.items || []));
|
|
1189
|
+
bookmark = responseData.bookmark;
|
|
1190
|
+
if (!returnAll && accounts.length >= limit) {
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
} while (bookmark);
|
|
1194
|
+
const executionData = toExecutionData(accounts, i);
|
|
1195
|
+
returnData.push(...executionData);
|
|
1196
|
+
}
|
|
1197
|
+
else if (operation === 'getCampaigns') {
|
|
1198
|
+
const adAccountId = this.getNodeParameter('adAccountId', i);
|
|
1199
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
1200
|
+
const limit = this.getNodeParameter('limit', i, 50);
|
|
1201
|
+
const additionalFields = this.getNodeParameter('additionalFieldsCampaign', i);
|
|
1202
|
+
const qs = {};
|
|
1203
|
+
if (additionalFields.entityStatuses) {
|
|
1204
|
+
qs.entity_statuses = additionalFields.entityStatuses.join(',');
|
|
1205
|
+
}
|
|
1206
|
+
let responseData;
|
|
1207
|
+
let bookmark = undefined;
|
|
1208
|
+
const campaigns = [];
|
|
1209
|
+
do {
|
|
1210
|
+
const currentQs = { ...qs };
|
|
1211
|
+
if (bookmark) {
|
|
1212
|
+
currentQs.bookmark = bookmark;
|
|
1213
|
+
}
|
|
1214
|
+
if (!returnAll && limit) {
|
|
1215
|
+
currentQs.page_size = Math.min(limit - campaigns.length, 250);
|
|
1216
|
+
}
|
|
1217
|
+
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1218
|
+
method: 'GET',
|
|
1219
|
+
url: `https://api.pinterest.com/v5/ad_accounts/${adAccountId}/campaigns`,
|
|
1220
|
+
qs: currentQs,
|
|
1221
|
+
json: true,
|
|
1222
|
+
});
|
|
1223
|
+
campaigns.push(...(responseData.items || []));
|
|
1224
|
+
bookmark = responseData.bookmark;
|
|
1225
|
+
if (!returnAll && campaigns.length >= limit) {
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
} while (bookmark);
|
|
1229
|
+
const executionData = toExecutionData(campaigns, i);
|
|
1230
|
+
returnData.push(...executionData);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
else if (resource === 'board') {
|
|
1234
|
+
if (operation === 'create') {
|
|
1235
|
+
const name = this.getNodeParameter('name', i);
|
|
1236
|
+
const description = this.getNodeParameter('description', i);
|
|
1237
|
+
const privacy = this.getNodeParameter('privacy', i);
|
|
1238
|
+
const body = {
|
|
1239
|
+
name,
|
|
1240
|
+
};
|
|
1241
|
+
if (description)
|
|
1242
|
+
body.description = description;
|
|
1243
|
+
if (privacy)
|
|
1244
|
+
body.privacy = privacy;
|
|
1245
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1246
|
+
method: 'POST',
|
|
1247
|
+
url: 'https://api.pinterest.com/v5/boards',
|
|
1248
|
+
body,
|
|
1249
|
+
json: true,
|
|
1250
|
+
});
|
|
1251
|
+
const executionData = toExecutionData(responseData, i);
|
|
1252
|
+
returnData.push(...executionData);
|
|
1253
|
+
}
|
|
1254
|
+
else if (operation === 'get') {
|
|
1255
|
+
const boardId = this.getNodeParameter('boardId', i);
|
|
1256
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1257
|
+
method: 'GET',
|
|
1258
|
+
url: `https://api.pinterest.com/v5/boards/${boardId}`,
|
|
1259
|
+
json: true,
|
|
1260
|
+
});
|
|
1261
|
+
const executionData = toExecutionData(responseData, i);
|
|
1262
|
+
returnData.push(...executionData);
|
|
1263
|
+
}
|
|
1264
|
+
else if (operation === 'getAll') {
|
|
1265
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
1266
|
+
const limit = this.getNodeParameter('limit', i, 50);
|
|
1267
|
+
let responseData;
|
|
1268
|
+
let bookmark = undefined;
|
|
1269
|
+
const boards = [];
|
|
1270
|
+
do {
|
|
1271
|
+
const qs = {};
|
|
1272
|
+
if (bookmark) {
|
|
1273
|
+
qs.bookmark = bookmark;
|
|
1274
|
+
}
|
|
1275
|
+
if (!returnAll && limit) {
|
|
1276
|
+
qs.page_size = Math.min(limit - boards.length, 250);
|
|
1277
|
+
}
|
|
1278
|
+
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1279
|
+
method: 'GET',
|
|
1280
|
+
url: 'https://api.pinterest.com/v5/boards',
|
|
1281
|
+
qs,
|
|
1282
|
+
json: true,
|
|
1283
|
+
});
|
|
1284
|
+
boards.push(...(responseData.items || []));
|
|
1285
|
+
bookmark = responseData.bookmark;
|
|
1286
|
+
if (!returnAll && boards.length >= limit) {
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1289
|
+
} while (bookmark);
|
|
1290
|
+
const executionData = toExecutionData(boards, i);
|
|
1291
|
+
returnData.push(...executionData);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
else if (resource === 'pin') {
|
|
1295
|
+
if (operation === 'create') {
|
|
1296
|
+
const boardId = this.getNodeParameter('boardId', i);
|
|
1297
|
+
const imageUrl = this.getNodeParameter('imageUrl', i);
|
|
1298
|
+
const title = this.getNodeParameter('title', i);
|
|
1299
|
+
const description = this.getNodeParameter('description', i);
|
|
1300
|
+
const link = this.getNodeParameter('link', i);
|
|
1301
|
+
const altText = this.getNodeParameter('altText', i);
|
|
1302
|
+
const body = {
|
|
1303
|
+
board_id: boardId,
|
|
1304
|
+
media_source: {
|
|
1305
|
+
source_type: 'image_url',
|
|
1306
|
+
url: imageUrl,
|
|
1307
|
+
},
|
|
1308
|
+
};
|
|
1309
|
+
if (title)
|
|
1310
|
+
body.title = title;
|
|
1311
|
+
if (description)
|
|
1312
|
+
body.description = description;
|
|
1313
|
+
if (link)
|
|
1314
|
+
body.link = link;
|
|
1315
|
+
if (altText)
|
|
1316
|
+
body.alt_text = altText;
|
|
1317
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1318
|
+
method: 'POST',
|
|
1319
|
+
url: 'https://api.pinterest.com/v5/pins',
|
|
1320
|
+
body,
|
|
1321
|
+
json: true,
|
|
1322
|
+
});
|
|
1323
|
+
const executionData = toExecutionData(responseData, i);
|
|
1324
|
+
returnData.push(...executionData);
|
|
1325
|
+
}
|
|
1326
|
+
else if (operation === 'get') {
|
|
1327
|
+
const pinId = this.getNodeParameter('pinId', i);
|
|
1328
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1329
|
+
method: 'GET',
|
|
1330
|
+
url: `https://api.pinterest.com/v5/pins/${pinId}`,
|
|
1331
|
+
json: true,
|
|
1332
|
+
});
|
|
1333
|
+
const executionData = toExecutionData(responseData, i);
|
|
1334
|
+
returnData.push(...executionData);
|
|
1335
|
+
}
|
|
1336
|
+
else if (operation === 'getAnalytics') {
|
|
1337
|
+
const pinId = this.getNodeParameter('pinId', i);
|
|
1338
|
+
const startDate = this.getNodeParameter('startDate', i).split('T')[0];
|
|
1339
|
+
const endDate = this.getNodeParameter('endDate', i).split('T')[0];
|
|
1340
|
+
const metricTypes = this.getNodeParameter('metricTypes', i);
|
|
1341
|
+
const additionalFields = this.getNodeParameter('additionalFieldsPinAnalytics', i);
|
|
1342
|
+
const qs = {
|
|
1343
|
+
start_date: startDate,
|
|
1344
|
+
end_date: endDate,
|
|
1345
|
+
metric_types: metricTypes.join(','),
|
|
1346
|
+
};
|
|
1347
|
+
if (additionalFields.adAccountId) {
|
|
1348
|
+
qs.ad_account_id = additionalFields.adAccountId;
|
|
1349
|
+
}
|
|
1350
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1351
|
+
method: 'GET',
|
|
1352
|
+
url: `https://api.pinterest.com/v5/pins/${pinId}/analytics`,
|
|
1353
|
+
qs,
|
|
1354
|
+
json: true,
|
|
1355
|
+
});
|
|
1356
|
+
const executionData = toExecutionData(responseData, i);
|
|
1357
|
+
returnData.push(...executionData);
|
|
1358
|
+
}
|
|
1359
|
+
else if (operation === 'getAll') {
|
|
1360
|
+
const boardId = this.getNodeParameter('boardId', i, '');
|
|
1361
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
1362
|
+
const limit = this.getNodeParameter('limit', i, 50);
|
|
1363
|
+
let responseData;
|
|
1364
|
+
let bookmark = undefined;
|
|
1365
|
+
const pins = [];
|
|
1366
|
+
const url = boardId
|
|
1367
|
+
? `https://api.pinterest.com/v5/boards/${boardId}/pins`
|
|
1368
|
+
: 'https://api.pinterest.com/v5/pins';
|
|
1369
|
+
do {
|
|
1370
|
+
const qs = {};
|
|
1371
|
+
if (bookmark) {
|
|
1372
|
+
qs.bookmark = bookmark;
|
|
1373
|
+
}
|
|
1374
|
+
if (!returnAll && limit) {
|
|
1375
|
+
qs.page_size = Math.min(limit - pins.length, 250);
|
|
1376
|
+
}
|
|
1377
|
+
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1378
|
+
method: 'GET',
|
|
1379
|
+
url,
|
|
1380
|
+
qs,
|
|
1381
|
+
json: true,
|
|
1382
|
+
});
|
|
1383
|
+
pins.push(...(responseData.items || []));
|
|
1384
|
+
bookmark = responseData.bookmark;
|
|
1385
|
+
if (!returnAll && pins.length >= limit) {
|
|
1386
|
+
break;
|
|
1387
|
+
}
|
|
1388
|
+
} while (bookmark);
|
|
1389
|
+
const executionData = toExecutionData(pins, i);
|
|
1390
|
+
returnData.push(...executionData);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
else if (resource === 'userAccount') {
|
|
1394
|
+
if (operation === 'getAnalytics') {
|
|
1395
|
+
const startDate = this.getNodeParameter('startDate', i).split('T')[0];
|
|
1396
|
+
const endDate = this.getNodeParameter('endDate', i).split('T')[0];
|
|
1397
|
+
const additionalFields = this.getNodeParameter('additionalFieldsUserAnalytics', i);
|
|
1398
|
+
const qs = {
|
|
1399
|
+
start_date: startDate,
|
|
1400
|
+
end_date: endDate,
|
|
1401
|
+
};
|
|
1402
|
+
if (additionalFields.adAccountId)
|
|
1403
|
+
qs.ad_account_id = additionalFields.adAccountId;
|
|
1404
|
+
if (additionalFields.fromClaimContent)
|
|
1405
|
+
qs.from_claim_content = additionalFields.fromClaimContent;
|
|
1406
|
+
if (additionalFields.pinFormat)
|
|
1407
|
+
qs.pin_format = additionalFields.pinFormat;
|
|
1408
|
+
if (additionalFields.appTypes)
|
|
1409
|
+
qs.app_types = additionalFields.appTypes;
|
|
1410
|
+
if (additionalFields.splitField)
|
|
1411
|
+
qs.split_field = additionalFields.splitField;
|
|
1412
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1413
|
+
method: 'GET',
|
|
1414
|
+
url: 'https://api.pinterest.com/v5/user_account/analytics',
|
|
1415
|
+
qs,
|
|
1416
|
+
json: true,
|
|
1417
|
+
});
|
|
1418
|
+
const executionData = toExecutionData(responseData, i);
|
|
1419
|
+
returnData.push(...executionData);
|
|
1420
|
+
}
|
|
1421
|
+
else if (operation === 'getTopPins') {
|
|
1422
|
+
const startDate = this.getNodeParameter('startDate', i).split('T')[0];
|
|
1423
|
+
const endDate = this.getNodeParameter('endDate', i).split('T')[0];
|
|
1424
|
+
const sortBy = this.getNodeParameter('sortBy', i);
|
|
1425
|
+
const additionalFields = this.getNodeParameter('additionalFieldsTopPins', i);
|
|
1426
|
+
const qs = {
|
|
1427
|
+
start_date: startDate,
|
|
1428
|
+
end_date: endDate,
|
|
1429
|
+
sort_by: sortBy,
|
|
1430
|
+
};
|
|
1431
|
+
if (additionalFields.adAccountId)
|
|
1432
|
+
qs.ad_account_id = additionalFields.adAccountId;
|
|
1433
|
+
if (additionalFields.fromClaimedContent)
|
|
1434
|
+
qs.from_claimed_content = additionalFields.fromClaimedContent;
|
|
1435
|
+
if (additionalFields.pinFormat)
|
|
1436
|
+
qs.pin_format = additionalFields.pinFormat;
|
|
1437
|
+
if (additionalFields.appTypes)
|
|
1438
|
+
qs.app_types = additionalFields.appTypes;
|
|
1439
|
+
if (additionalFields.contentType)
|
|
1440
|
+
qs.content_type = additionalFields.contentType;
|
|
1441
|
+
if (additionalFields.source)
|
|
1442
|
+
qs.source = additionalFields.source;
|
|
1443
|
+
if (additionalFields.limit)
|
|
1444
|
+
qs.limit = additionalFields.limit;
|
|
1445
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pinterestOAuth2Api', {
|
|
1446
|
+
method: 'GET',
|
|
1447
|
+
url: 'https://api.pinterest.com/v5/user_account/analytics/top_pins',
|
|
1448
|
+
qs,
|
|
1449
|
+
json: true,
|
|
1450
|
+
});
|
|
1451
|
+
const executionData = toExecutionData(responseData, i);
|
|
1452
|
+
returnData.push(...executionData);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
catch (error) {
|
|
1457
|
+
if (this.continueOnFail()) {
|
|
1458
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1459
|
+
returnData.push({
|
|
1460
|
+
json: { error: errorMessage },
|
|
1461
|
+
pairedItem: { item: i },
|
|
1462
|
+
});
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { itemIndex: i });
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
return [returnData];
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
exports.Pinterest = Pinterest;
|