@unboundcx/sdk 4.5.0 → 4.6.1

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.
@@ -0,0 +1,276 @@
1
+ export class DocumentTemplatesService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ /**
7
+ * Create a document template head (draft, no version row).
8
+ * @param {Object} params
9
+ * @param {string} params.name - Template name (required)
10
+ * @param {string} [params.description]
11
+ * @param {string} [params.tag]
12
+ * @param {string[]} [params.uses] - Consumer surfaces (`fax`). Empty = all.
13
+ * @param {'generative'|'overlay'} [params.engine='generative']
14
+ * @param {string} [params.sourcePdfStorageId] - Required when engine is overlay
15
+ * @param {Object} [params.draftSchemaJson]
16
+ * @param {Object} [params.draftLayoutJson]
17
+ * @param {Object} [params.draftPageJson]
18
+ * @param {Object} [params.draftThemeJson]
19
+ * @returns {Promise<Object>} Created template (includes draft*)
20
+ */
21
+ async create({
22
+ name,
23
+ description,
24
+ tag,
25
+ uses,
26
+ engine,
27
+ sourcePdfStorageId,
28
+ draftSchemaJson,
29
+ draftLayoutJson,
30
+ draftPageJson,
31
+ draftThemeJson,
32
+ }) {
33
+ this.sdk.validateParams(
34
+ { name },
35
+ {
36
+ name: { type: 'string', required: true },
37
+ description: { type: 'string', required: false },
38
+ tag: { type: 'string', required: false },
39
+ uses: { type: 'object', required: false },
40
+ engine: { type: 'string', required: false },
41
+ sourcePdfStorageId: { type: 'string', required: false },
42
+ draftSchemaJson: { type: 'object', required: false },
43
+ draftLayoutJson: { type: 'object', required: false },
44
+ draftPageJson: { type: 'object', required: false },
45
+ draftThemeJson: { type: 'object', required: false },
46
+ },
47
+ );
48
+
49
+ const body = { name };
50
+ if (description !== undefined) body.description = description;
51
+ if (tag !== undefined) body.tag = tag;
52
+ if (uses !== undefined) body.uses = uses;
53
+ if (engine !== undefined) body.engine = engine;
54
+ if (sourcePdfStorageId !== undefined) {
55
+ body.sourcePdfStorageId = sourcePdfStorageId;
56
+ }
57
+ if (draftSchemaJson !== undefined) body.draftSchemaJson = draftSchemaJson;
58
+ if (draftLayoutJson !== undefined) body.draftLayoutJson = draftLayoutJson;
59
+ if (draftPageJson !== undefined) body.draftPageJson = draftPageJson;
60
+ if (draftThemeJson !== undefined) body.draftThemeJson = draftThemeJson;
61
+
62
+ return this.sdk._fetch('/documents/templates', 'POST', { body });
63
+ }
64
+
65
+ /**
66
+ * List document templates (not deleted). Returns draft* for authoring.
67
+ * @param {Object} [params]
68
+ * @param {string} [params.tag]
69
+ * @param {string} [params.status]
70
+ * @param {string} [params.use] - Consumer surface (`fax`). Empty uses match all.
71
+ * @param {number} [params.limit]
72
+ * @returns {Promise<{results: Object[]}>}
73
+ */
74
+ async list({ tag, status, use, limit } = {}) {
75
+ const query = {};
76
+ if (tag) query.tag = tag;
77
+ if (status) query.status = status;
78
+ if (use) query.use = use;
79
+ if (limit) query.limit = limit;
80
+ return this.sdk._fetch('/documents/templates', 'GET', { query });
81
+ }
82
+
83
+ /**
84
+ * Get a document template by id (head + draft* + published version if any).
85
+ * @param {string} id
86
+ * @returns {Promise<Object>}
87
+ */
88
+ async get(id) {
89
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
90
+ return this.sdk._fetch(`/documents/templates/${id}`, 'GET');
91
+ }
92
+
93
+ /**
94
+ * Update name/description/tag/draft*. Cannot change engine.
95
+ * @param {string} id
96
+ * @param {Object} params
97
+ * @param {string} [params.name]
98
+ * @param {string} [params.description]
99
+ * @param {string} [params.tag]
100
+ * @param {string[]} [params.uses]
101
+ * @param {Object} [params.draftSchemaJson]
102
+ * @param {Object} [params.draftLayoutJson]
103
+ * @param {Object} [params.draftPageJson]
104
+ * @param {Object} [params.draftThemeJson]
105
+ * @returns {Promise<Object>}
106
+ */
107
+ async update(
108
+ id,
109
+ {
110
+ name,
111
+ description,
112
+ tag,
113
+ uses,
114
+ recordTypeId,
115
+ draftSchemaJson,
116
+ draftLayoutJson,
117
+ draftPageJson,
118
+ draftThemeJson,
119
+ } = {},
120
+ ) {
121
+ this.sdk.validateParams(
122
+ { id },
123
+ {
124
+ id: { type: 'string', required: true },
125
+ name: { type: 'string', required: false },
126
+ description: { type: 'string', required: false },
127
+ tag: { type: 'string', required: false },
128
+ uses: { type: 'object', required: false },
129
+ recordTypeId: { type: 'string', required: false },
130
+ draftSchemaJson: { type: 'object', required: false },
131
+ draftLayoutJson: { type: 'object', required: false },
132
+ draftPageJson: { type: 'object', required: false },
133
+ draftThemeJson: { type: 'object', required: false },
134
+ },
135
+ );
136
+
137
+ const body = {};
138
+ if (name !== undefined) body.name = name;
139
+ if (description !== undefined) body.description = description;
140
+ if (tag !== undefined) body.tag = tag;
141
+ if (uses !== undefined) body.uses = uses;
142
+ if (recordTypeId !== undefined) body.recordTypeId = recordTypeId;
143
+ if (draftSchemaJson !== undefined) body.draftSchemaJson = draftSchemaJson;
144
+ if (draftLayoutJson !== undefined) body.draftLayoutJson = draftLayoutJson;
145
+ if (draftPageJson !== undefined) body.draftPageJson = draftPageJson;
146
+ if (draftThemeJson !== undefined) body.draftThemeJson = draftThemeJson;
147
+
148
+ return this.sdk._fetch(`/documents/templates/${id}`, 'PATCH', { body });
149
+ }
150
+
151
+ /**
152
+ * Snapshot draft* into a new published version and set currentVersionId.
153
+ * @param {string} id
154
+ * @returns {Promise<Object>}
155
+ */
156
+ async publish(id) {
157
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
158
+ return this.sdk._fetch(`/documents/templates/${id}/publish`, 'POST', {
159
+ body: {},
160
+ });
161
+ }
162
+
163
+ /**
164
+ * Soft-delete a document template.
165
+ * @param {string} id
166
+ * @returns {Promise<{id: string, deleted: boolean}>}
167
+ */
168
+ async delete(id) {
169
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
170
+ return this.sdk._fetch(`/documents/templates/${id}`, 'DELETE');
171
+ }
172
+ }
173
+
174
+ export class DocumentsService {
175
+ constructor(sdk) {
176
+ this.sdk = sdk;
177
+ this.templates = new DocumentTemplatesService(sdk);
178
+ }
179
+
180
+ /**
181
+ * Generate a PDF from the published template version.
182
+ * @param {Object} params
183
+ * @param {string} params.templateId
184
+ * @param {Object} params.data
185
+ * @param {string} [params.versionId]
186
+ * @param {Object} [params.options]
187
+ * @param {string} [params.options.filename]
188
+ * @param {Object} [params.source]
189
+ * @param {string} [params.source.type]
190
+ * @param {string} [params.source.id]
191
+ * @returns {Promise<Object>}
192
+ */
193
+ async generate({ templateId, data, versionId, options, source }) {
194
+ this.sdk.validateParams(
195
+ { templateId, data },
196
+ {
197
+ templateId: { type: 'string', required: true },
198
+ data: { type: 'object', required: true },
199
+ versionId: { type: 'string', required: false },
200
+ options: { type: 'object', required: false },
201
+ source: { type: 'object', required: false },
202
+ },
203
+ );
204
+
205
+ const body = { templateId, data };
206
+ if (versionId !== undefined) body.versionId = versionId;
207
+ if (options !== undefined) body.options = options;
208
+ if (source !== undefined) body.source = source;
209
+
210
+ return this.sdk._fetch('/documents/generate', 'POST', { body });
211
+ }
212
+
213
+ /**
214
+ * Preview a PDF from draft* (or a specific versionId). isPreview=1.
215
+ * @param {Object} params
216
+ * @param {string} params.templateId
217
+ * @param {Object} [params.data]
218
+ * @param {string} [params.versionId]
219
+ * @returns {Promise<Object>}
220
+ */
221
+ async preview({ templateId, data, versionId }) {
222
+ this.sdk.validateParams(
223
+ { templateId },
224
+ {
225
+ templateId: { type: 'string', required: true },
226
+ data: { type: 'object', required: false },
227
+ versionId: { type: 'string', required: false },
228
+ },
229
+ );
230
+
231
+ const body = { templateId };
232
+ if (data !== undefined) body.data = data;
233
+ if (versionId !== undefined) body.versionId = versionId;
234
+
235
+ return this.sdk._fetch('/documents/preview', 'POST', { body });
236
+ }
237
+
238
+ /**
239
+ * Attach a consumer id (e.g. fax document) after send.
240
+ * @param {Object} params
241
+ * @param {string} params.id - generatedDocuments id
242
+ * @param {string} [params.sourceId]
243
+ * @param {string} [params.sourceType]
244
+ * @returns {Promise<Object>}
245
+ */
246
+ async updateGenerated({ id, sourceId, sourceType }) {
247
+ this.sdk.validateParams(
248
+ { id },
249
+ {
250
+ id: { type: 'string', required: true },
251
+ sourceId: { type: 'string', required: false },
252
+ sourceType: { type: 'string', required: false },
253
+ },
254
+ );
255
+
256
+ const body = {};
257
+ if (sourceId !== undefined) body.sourceId = sourceId;
258
+ if (sourceType !== undefined) body.sourceType = sourceType;
259
+
260
+ return this.sdk._fetch(`/documents/generated/${id}`, 'PATCH', { body });
261
+ }
262
+
263
+ /**
264
+ * Page count / size for a stored PDF.
265
+ * @param {Object} params
266
+ * @param {string} params.storageId
267
+ * @returns {Promise<{pageCount: number, pageSize: string|null}>}
268
+ */
269
+ async inspect({ storageId }) {
270
+ this.sdk.validateParams(
271
+ { storageId },
272
+ { storageId: { type: 'string', required: true } },
273
+ );
274
+ return this.sdk._fetch('/documents/inspect', 'POST', { body: { storageId } });
275
+ }
276
+ }
@@ -141,6 +141,7 @@ export class ExternalOAuthService {
141
141
  scopes,
142
142
  authorizationUrl,
143
143
  tokenUrl,
144
+ fromConnectionId,
144
145
  }) {
145
146
  this.sdk.validateParams(
146
147
  { name, provider },
@@ -152,6 +153,7 @@ export class ExternalOAuthService {
152
153
  scopes: { type: 'array', required: false },
153
154
  authorizationUrl: { type: 'string', required: false },
154
155
  tokenUrl: { type: 'string', required: false },
156
+ fromConnectionId: { type: 'string', required: false },
155
157
  },
156
158
  );
157
159
 
@@ -161,10 +163,30 @@ export class ExternalOAuthService {
161
163
  if (scopes) body.scopes = scopes;
162
164
  if (authorizationUrl) body.authorizationUrl = authorizationUrl;
163
165
  if (tokenUrl) body.tokenUrl = tokenUrl;
166
+ if (fromConnectionId) body.fromConnectionId = fromConnectionId;
164
167
 
165
168
  const result = await this.sdk._fetch('/externalOAuth/authorize', 'POST', {
166
169
  body,
167
170
  });
168
171
  return result;
169
172
  }
173
+
174
+ /**
175
+ * Check whether a connection can be used for a purpose (e.g. Google Ads / Meta ads).
176
+ *
177
+ * @param {string} id
178
+ * @param {object} [args]
179
+ * @param {string} [args.purpose='googleAds']
180
+ * @returns {Promise<object>}
181
+ */
182
+ async verify(id, { purpose = 'googleAds' } = {}) {
183
+ this.sdk.validateParams(
184
+ { id },
185
+ { id: { type: 'string', required: true } },
186
+ );
187
+
188
+ return this.sdk._fetch(`/externalOAuth/${id}/verify`, 'POST', {
189
+ body: { purpose },
190
+ });
191
+ }
170
192
  }
package/services/fax.js CHANGED
@@ -78,6 +78,8 @@ export class FaxService {
78
78
  * Required if pdfStorageId and tiffStorageId are not provided.
79
79
  * @param {string} [options.pdfStorageId] - Storage ID of the PDF version. Required if storageId is not provided.
80
80
  * @param {string} [options.tiffStorageId] - Storage ID of the TIFF version. Required if storageId is not provided.
81
+ * @param {string} [options.coverStorageId] - Optional cover PDF (or TIFF). Concatenated in front of the body before TIFF convert.
82
+ * @param {('letter'|'legal'|'a4')} [options.paperSize] - Paper size hint for TIFF conversion. Server also reads PDF MediaBox.
81
83
  * @param {string} [options.faxHeader] - TSI header text (defaults to mailbox faxHeader)
82
84
  * @param {string} [options.resolution] - Fax resolution (defaults to mailbox resolution)
83
85
  * @param {boolean} [options.ecm] - Enable Error Correction Mode (default: true)
@@ -95,6 +97,8 @@ export class FaxService {
95
97
  * toNumber: '+15551234567',
96
98
  * fromNumber: '+15559876543',
97
99
  * storageId: '017xyz788...',
100
+ * paperSize: 'legal',
101
+ * coverStorageId: '017cover...',
98
102
  * });
99
103
  * console.log(result.id); // '158def456...'
100
104
  * console.log(result.status); // 'sending'
@@ -120,13 +124,15 @@ export class FaxService {
120
124
  storageId,
121
125
  pdfStorageId,
122
126
  tiffStorageId,
127
+ coverStorageId,
128
+ paperSize,
123
129
  faxHeader,
124
130
  resolution,
125
131
  ecm,
126
132
  timeout,
127
133
  }) {
128
134
  this.sdk.validateParams(
129
- { faxMailboxId, toNumber, fromNumber },
135
+ { faxMailboxId, toNumber, fromNumber, coverStorageId, paperSize },
130
136
  {
131
137
  faxMailboxId: { type: 'string', required: true },
132
138
  toNumber: { type: 'string', required: true },
@@ -134,6 +140,8 @@ export class FaxService {
134
140
  storageId: { type: 'string', required: false },
135
141
  pdfStorageId: { type: 'string', required: false },
136
142
  tiffStorageId: { type: 'string', required: false },
143
+ coverStorageId: { type: 'string', required: false },
144
+ paperSize: { type: 'string', required: false },
137
145
  },
138
146
  );
139
147
 
@@ -151,6 +159,8 @@ export class FaxService {
151
159
  storageId,
152
160
  pdfStorageId,
153
161
  tiffStorageId,
162
+ coverStorageId,
163
+ paperSize,
154
164
  faxHeader,
155
165
  resolution,
156
166
  ecm,
@@ -211,25 +211,27 @@ export class ObjectsService {
211
211
  * Update an object record by ID
212
212
  *
213
213
  * Preferred usage (new signature):
214
- * sdk.objects.updateById({ object: 'users', id: 'userId', update: { name: 'Jane' } })
214
+ * sdk.objects.updateById({ object: 'users', id: 'userId', update: { name: 'Jane' }, skipTriggers: true })
215
215
  *
216
216
  * Legacy usage (deprecated, but supported):
217
217
  * sdk.objects.updateById('users', 'userId', { name: 'Jane' })
218
218
  *
219
219
  * @param {object} args - Update parameters
220
+ * @param {boolean} [args.skipTriggers=false] - Skip trigger execution for this write
220
221
  * @returns {Promise} Updated object data
221
222
  */
222
223
  async updateById(...args) {
223
- // New signature: updateById({ object, id, update })
224
+ // New signature: updateById({ object, id, update, skipTriggers })
224
225
  if (args.length === 1 && typeof args[0] === 'object' && args[0].object) {
225
- const { object, id, update } = args[0];
226
+ const { object, id, update, skipTriggers = false } = args[0];
226
227
 
227
228
  this.sdk.validateParams(
228
- { object, id, update },
229
+ { object, id, update, skipTriggers },
229
230
  {
230
231
  object: { type: 'string', required: true },
231
232
  id: { type: 'string', required: true },
232
233
  update: { type: 'object', required: true },
234
+ skipTriggers: { type: 'boolean', required: false },
233
235
  },
234
236
  );
235
237
 
@@ -239,6 +241,7 @@ export class ObjectsService {
239
241
  update,
240
242
  },
241
243
  };
244
+ if (skipTriggers) params.query = { skipTriggers: true };
242
245
 
243
246
  return await this.sdk._fetch(`/object/${object}`, 'PUT', params);
244
247
  }
@@ -269,13 +272,32 @@ export class ObjectsService {
269
272
  throw new Error('Invalid arguments for updateById method');
270
273
  }
271
274
 
272
- async update({ object, where, update }) {
275
+ /**
276
+ * Update records matching a where clause.
277
+ *
278
+ * @param {object} args
279
+ * @param {string} args.object
280
+ * @param {object} args.where
281
+ * @param {object} args.update
282
+ * @param {boolean} [args.skipTriggers=false] - Do not run triggers for this write
283
+ * @returns {Promise} Update result
284
+ *
285
+ * @example
286
+ * await sdk.objects.update({
287
+ * object: 'people',
288
+ * where: { id: '013…' },
289
+ * update: { leadScore: 200 },
290
+ * skipTriggers: true,
291
+ * });
292
+ */
293
+ async update({ object, where, update, skipTriggers = false }) {
273
294
  this.sdk.validateParams(
274
- { object, where, update },
295
+ { object, where, update, skipTriggers },
275
296
  {
276
297
  object: { type: 'string', required: true },
277
298
  where: { type: 'object', required: true },
278
299
  update: { type: 'object', required: true },
300
+ skipTriggers: { type: 'boolean', required: false },
279
301
  },
280
302
  );
281
303
 
@@ -285,6 +307,7 @@ export class ObjectsService {
285
307
  update,
286
308
  },
287
309
  };
310
+ if (skipTriggers) params.query = { skipTriggers: true };
288
311
 
289
312
  const result = await this.sdk._fetch(`/object/${object}`, 'PUT', params);
290
313
  return result;
@@ -294,28 +317,31 @@ export class ObjectsService {
294
317
  * Create a new object record
295
318
  *
296
319
  * Preferred usage (new signature):
297
- * sdk.objects.create({ object: 'users', body: { name: 'John', email: 'john@example.com' } })
320
+ * sdk.objects.create({ object: 'users', body: { name: 'John', email: 'john@example.com' }, skipTriggers: true })
298
321
  *
299
322
  * Legacy usage (deprecated, but supported):
300
323
  * sdk.objects.create('users', { name: 'John', email: 'john@example.com' })
301
324
  *
302
325
  * @param {object} args - Creation parameters
326
+ * @param {boolean} [args.skipTriggers=false] - Skip trigger execution for this write
303
327
  * @returns {Promise} Created object data
304
328
  */
305
329
  async create(...args) {
306
- // New signature: create({ object, body })
330
+ // New signature: create({ object, body, skipTriggers })
307
331
  if (args.length === 1 && typeof args[0] === 'object' && args[0].object) {
308
- const { object, body } = args[0];
332
+ const { object, body, skipTriggers = false } = args[0];
309
333
 
310
334
  this.sdk.validateParams(
311
- { object, body },
335
+ { object, body, skipTriggers },
312
336
  {
313
337
  object: { type: 'string', required: true },
314
338
  body: { type: 'object', required: true },
339
+ skipTriggers: { type: 'boolean', required: false },
315
340
  },
316
341
  );
317
342
 
318
343
  const params = { body };
344
+ if (skipTriggers) params.query = { skipTriggers: true };
319
345
  return await this.sdk._fetch(`/object/${object}`, 'POST', params);
320
346
  }
321
347
 
@@ -338,12 +364,29 @@ export class ObjectsService {
338
364
  throw new Error('Invalid arguments for create method');
339
365
  }
340
366
 
341
- async delete({ object, where }) {
367
+ /**
368
+ * Delete records matching a where clause.
369
+ *
370
+ * @param {object} args
371
+ * @param {string} args.object
372
+ * @param {object} args.where
373
+ * @param {boolean} [args.skipTriggers=false] - Do not run triggers for this write
374
+ * @returns {Promise} Delete result
375
+ *
376
+ * @example
377
+ * await sdk.objects.delete({
378
+ * object: 'people',
379
+ * where: { id: '013…' },
380
+ * skipTriggers: true,
381
+ * });
382
+ */
383
+ async delete({ object, where, skipTriggers = false }) {
342
384
  this.sdk.validateParams(
343
- { object, where },
385
+ { object, where, skipTriggers },
344
386
  {
345
387
  object: { type: 'string', required: true },
346
388
  where: { type: 'object', required: true },
389
+ skipTriggers: { type: 'boolean', required: false },
347
390
  },
348
391
  );
349
392
 
@@ -352,17 +395,31 @@ export class ObjectsService {
352
395
  where,
353
396
  },
354
397
  };
398
+ if (skipTriggers) params.query = { skipTriggers: true };
355
399
 
356
400
  const result = await this.sdk._fetch(`/object/${object}`, 'DELETE', params);
357
401
  return result;
358
402
  }
359
403
 
360
- async deleteById({ object, id }) {
404
+ /**
405
+ * Delete a record by id.
406
+ *
407
+ * @param {object} args
408
+ * @param {string} args.object
409
+ * @param {string} args.id
410
+ * @param {boolean} [args.skipTriggers=false] - Do not run triggers for this write
411
+ * @returns {Promise} Delete result
412
+ *
413
+ * @example
414
+ * await sdk.objects.deleteById({ object: 'people', id: '013…', skipTriggers: true });
415
+ */
416
+ async deleteById({ object, id, skipTriggers = false }) {
361
417
  this.sdk.validateParams(
362
- { object, id },
418
+ { object, id, skipTriggers },
363
419
  {
364
420
  object: { type: 'string', required: true },
365
421
  id: { type: 'string', required: true },
422
+ skipTriggers: { type: 'boolean', required: false },
366
423
  },
367
424
  );
368
425
 
@@ -373,6 +430,7 @@ export class ObjectsService {
373
430
  },
374
431
  },
375
432
  };
433
+ if (skipTriggers) params.query = { skipTriggers: true };
376
434
 
377
435
  const result = await this.sdk._fetch(`/object/${object}`, 'DELETE', params);
378
436
  return result;
@@ -942,4 +1000,83 @@ export class ObjectsService {
942
1000
  );
943
1001
  return result;
944
1002
  }
1003
+
1004
+ /**
1005
+ * List Google Ads customer IDs for an OAuth connection.
1006
+ *
1007
+ * @param {object} args
1008
+ * @param {string} args.connectionId
1009
+ * @returns {Promise<{results: object[], warning?: string|null}>}
1010
+ */
1011
+ async listGoogleAdAccounts({ connectionId }) {
1012
+ this.sdk.validateParams(
1013
+ { connectionId },
1014
+ { connectionId: { type: 'string', required: true } },
1015
+ );
1016
+ return this.sdk._fetch('/object/ad-catalog/google/accounts', 'GET', {
1017
+ query: { connectionId },
1018
+ });
1019
+ }
1020
+
1021
+ /**
1022
+ * List Google Ads campaigns for a customer.
1023
+ *
1024
+ * @param {object} args
1025
+ * @param {string} args.connectionId
1026
+ * @param {string} args.customerId
1027
+ * @param {string} [args.loginCustomerId]
1028
+ * @returns {Promise<{results: object[]}>}
1029
+ */
1030
+ async listGoogleAdCampaigns({ connectionId, customerId, loginCustomerId }) {
1031
+ this.sdk.validateParams(
1032
+ { connectionId, customerId },
1033
+ {
1034
+ connectionId: { type: 'string', required: true },
1035
+ customerId: { type: 'string', required: true },
1036
+ },
1037
+ );
1038
+ const query = { connectionId, customerId };
1039
+ if (loginCustomerId) query.loginCustomerId = loginCustomerId;
1040
+ return this.sdk._fetch('/object/ad-catalog/google/campaigns', 'GET', {
1041
+ query,
1042
+ });
1043
+ }
1044
+
1045
+ /**
1046
+ * List Meta ad accounts for an OAuth connection.
1047
+ *
1048
+ * @param {object} args
1049
+ * @param {string} args.connectionId
1050
+ * @returns {Promise<{results: object[]}>}
1051
+ */
1052
+ async listMetaAdAccounts({ connectionId }) {
1053
+ this.sdk.validateParams(
1054
+ { connectionId },
1055
+ { connectionId: { type: 'string', required: true } },
1056
+ );
1057
+ return this.sdk._fetch('/object/ad-catalog/meta/accounts', 'GET', {
1058
+ query: { connectionId },
1059
+ });
1060
+ }
1061
+
1062
+ /**
1063
+ * List Meta campaigns for an ad account.
1064
+ *
1065
+ * @param {object} args
1066
+ * @param {string} args.connectionId
1067
+ * @param {string} args.adAccountId
1068
+ * @returns {Promise<{results: object[]}>}
1069
+ */
1070
+ async listMetaAdCampaigns({ connectionId, adAccountId }) {
1071
+ this.sdk.validateParams(
1072
+ { connectionId, adAccountId },
1073
+ {
1074
+ connectionId: { type: 'string', required: true },
1075
+ adAccountId: { type: 'string', required: true },
1076
+ },
1077
+ );
1078
+ return this.sdk._fetch('/object/ad-catalog/meta/campaigns', 'GET', {
1079
+ query: { connectionId, adAccountId },
1080
+ });
1081
+ }
945
1082
  }