@pipedream/trello 0.3.14 → 0.4.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.
Files changed (56) hide show
  1. package/actions/add-attachment-to-card/add-attachment-to-card.mjs +124 -0
  2. package/actions/add-checklist/add-checklist.mjs +56 -38
  3. package/actions/add-comment/add-comment.mjs +44 -34
  4. package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +26 -11
  5. package/actions/add-member-to-card/add-member-to-card.mjs +26 -11
  6. package/actions/archive-card/archive-card.mjs +13 -7
  7. package/actions/close-board/close-board.mjs +10 -4
  8. package/actions/common.mjs +2 -2
  9. package/actions/complete-checklist-item/complete-checklist-item.mjs +61 -31
  10. package/actions/create-board/create-board.mjs +96 -61
  11. package/actions/create-card/create-card.mjs +83 -39
  12. package/actions/create-checklist/create-checklist.mjs +26 -14
  13. package/actions/create-checklist-item/create-checklist-item.mjs +64 -39
  14. package/actions/create-comment-on-card/create-comment-on-card.mjs +26 -9
  15. package/actions/create-label/create-label.mjs +37 -36
  16. package/actions/create-list/create-list.mjs +51 -42
  17. package/actions/delete-checklist/delete-checklist.mjs +24 -11
  18. package/actions/find-labels/find-labels.mjs +13 -10
  19. package/actions/find-list/find-list.mjs +12 -9
  20. package/actions/get-card/get-card.mjs +12 -8
  21. package/actions/get-list/get-list.mjs +29 -15
  22. package/actions/move-card-to-list/move-card-to-list.mjs +16 -12
  23. package/actions/remove-label-from-card/remove-label-from-card.mjs +26 -10
  24. package/actions/rename-list/rename-list.mjs +23 -9
  25. package/actions/search-boards/search-boards.mjs +17 -15
  26. package/actions/search-cards/search-cards.mjs +17 -15
  27. package/actions/search-checklists/search-checklists.mjs +102 -46
  28. package/actions/search-members/search-members.mjs +48 -28
  29. package/actions/update-card/update-card.mjs +62 -45
  30. package/package.json +4 -3
  31. package/sources/card-archived/card-archived.mjs +21 -5
  32. package/sources/card-due-date-reminder/card-due-date-reminder.mjs +31 -30
  33. package/sources/card-moved/card-moved.mjs +12 -6
  34. package/sources/card-updates/card-updates.mjs +19 -10
  35. package/sources/common/common-board-based.mjs +4 -2
  36. package/sources/common/common-webhook.mjs +63 -20
  37. package/sources/common/common.mjs +2 -2
  38. package/sources/custom-webhook-events/custom-webhook-events.mjs +30 -11
  39. package/sources/new-activity/new-activity.mjs +5 -3
  40. package/sources/new-attachment/new-attachment.mjs +20 -4
  41. package/sources/new-board/new-board.mjs +5 -3
  42. package/sources/new-card/new-card.mjs +19 -10
  43. package/sources/new-checklist/new-checklist.mjs +15 -3
  44. package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +30 -9
  45. package/sources/new-label/new-label.mjs +7 -3
  46. package/sources/new-label-added-to-card/new-label-added-to-card.mjs +20 -10
  47. package/sources/new-list/new-list.mjs +7 -3
  48. package/sources/new-member-on-card/new-member-on-card.mjs +15 -3
  49. package/sources/new-notification/new-notification.mjs +15 -5
  50. package/trello.app.mjs +269 -487
  51. package/actions/add-attachment-to-card-via-url/add-attachment-to-card-via-url.mjs +0 -73
  52. package/actions/add-file-as-attachment-via-url/add-file-as-attachment-via-url.mjs +0 -72
  53. package/actions/add-image-attachment/add-image-attachment.mjs +0 -75
  54. package/actions/add-label-to-card/add-label-to-card.mjs +0 -55
  55. package/actions/copy-board/copy-board.mjs +0 -174
  56. /package/{common → sources/common}/events.mjs +0 -0
package/trello.app.mjs CHANGED
@@ -1,37 +1,40 @@
1
1
  import { axios } from "@pipedream/platform";
2
- import crypto from "crypto";
3
- import events from "./common/events.mjs";
4
2
  import fields from "./common/fields.mjs";
5
- import mime from "mime";
6
3
 
7
4
  export default {
8
5
  type: "app",
9
6
  app: "trello",
10
7
  description: "Pipedream Trello Components",
11
8
  propDefinitions: {
12
- cards: {
13
- type: "string[]",
14
- label: "Cards",
15
- description: "The Trello cards you wish to select",
16
- optional: true,
17
- async options(opts) {
18
- const cards = await this.getCards(opts.board);
19
- return cards.map((card) => ({
20
- label: card.name,
21
- value: card.id,
22
- }));
23
- },
24
- },
25
9
  board: {
26
10
  type: "string",
27
11
  label: "Board",
28
12
  description: "The Trello board you wish to select",
29
13
  async options() {
30
14
  const boards = await this.getBoards();
31
- const activeBoards = boards.filter((board) => board.closed === false);
32
- return activeBoards.map((board) => ({
33
- label: board.name,
34
- value: board.id,
15
+ return boards.filter(({ closed }) => closed === false)
16
+ .map(({
17
+ id: value, name: label,
18
+ }) => ({
19
+ label,
20
+ value,
21
+ }));
22
+ },
23
+ },
24
+ cards: {
25
+ type: "string[]",
26
+ label: "Cards",
27
+ description: "The Trello cards you wish to select",
28
+ optional: true,
29
+ async options({ board }) {
30
+ const cards = await this.getCards({
31
+ boardId: board,
32
+ });
33
+ return cards.map(({
34
+ id: value, name: label,
35
+ }) => ({
36
+ label,
37
+ value,
35
38
  }));
36
39
  },
37
40
  },
@@ -54,20 +57,15 @@ export default {
54
57
  "all",
55
58
  ],
56
59
  },
57
- eventTypes: {
58
- type: "string[]",
59
- label: "Event Types",
60
- optional: true,
61
- description: "Only emit events for the selected event types (e.g., `updateCard`).",
62
- options: events,
63
- },
64
60
  lists: {
65
61
  type: "string[]",
66
62
  label: "Lists",
67
63
  description: "The Trello lists you wish to select",
68
64
  optional: true,
69
- async options(opts) {
70
- const lists = await this.getLists(opts.board);
65
+ async options({ board }) {
66
+ const lists = await this.getLists({
67
+ boardId: board,
68
+ });
71
69
  return lists.map((list) => ({
72
70
  label: list.name,
73
71
  value: list.id,
@@ -84,9 +82,14 @@ export default {
84
82
  label: "Organization IDs",
85
83
  description: "Specify the organizations to search for boards in",
86
84
  async options() {
87
- const orgs = await this.listOrganizations(this.$auth.oauth_uid);
85
+ const orgs = await this.listOrganizations({
86
+ memberId: this.$auth.oauth_uid,
87
+ params: {
88
+ fields: "all",
89
+ },
90
+ });
88
91
  return orgs.map((org) => ({
89
- label: org.name || org.id,
92
+ label: org.displayName ?? org.name ?? org.id,
90
93
  value: org.id,
91
94
  }));
92
95
  },
@@ -108,11 +111,15 @@ export default {
108
111
  type: "string",
109
112
  label: "Label",
110
113
  description: "The ID of the Label to be added to the card",
111
- async options(opts) {
112
- const labels = await this.findLabel(opts.board);
113
- return labels.map((label) => ({
114
- label: label.name,
115
- value: label.id,
114
+ async options({ board }) {
115
+ const labels = await this.findLabel({
116
+ boardId: board,
117
+ });
118
+ return labels.map(({
119
+ name, color, id: value,
120
+ }) => ({
121
+ label: name || color,
122
+ value,
116
123
  }));
117
124
  },
118
125
  },
@@ -121,7 +128,9 @@ export default {
121
128
  label: "Member",
122
129
  description: "The ID of the Member to be added to the card",
123
130
  async options(opts) {
124
- const members = await this.listMembers(opts.board);
131
+ const members = await this.listMembers({
132
+ boardId: opts.board,
133
+ });
125
134
  return members.map((member) => ({
126
135
  label: member.fullName,
127
136
  value: member.id,
@@ -132,14 +141,16 @@ export default {
132
141
  type: "string",
133
142
  label: "Checklist",
134
143
  description: "The ID of a checklist to copy into the new checklist",
135
- async options(opts) {
136
- const {
137
- board,
138
- card,
139
- } = opts;
144
+ async options({
145
+ board, card,
146
+ }) {
140
147
  const checklists = card ?
141
- await this.listCardChecklists(card) :
142
- await this.listBoardChecklists(board);
148
+ await this.listCardChecklists({
149
+ cardId: card,
150
+ }) :
151
+ await this.listBoardChecklists({
152
+ boardId: board,
153
+ });
143
154
  return checklists.map((checklist) => ({
144
155
  label: checklist.name,
145
156
  value: checklist.id,
@@ -152,7 +163,9 @@ export default {
152
163
  description: "An array of custom field Ids to create/update",
153
164
  optional: true,
154
165
  async options({ boardId }) {
155
- const customFields = await this.listCustomFields(boardId);
166
+ const customFields = await this.listCustomFields({
167
+ boardId,
168
+ });
156
169
  return customFields?.map(({
157
170
  id: value, name: label,
158
171
  }) => ({
@@ -161,15 +174,6 @@ export default {
161
174
  })) || [];
162
175
  },
163
176
  },
164
- mimeType: {
165
- type: "string",
166
- label: "File Attachment Type",
167
- description: "Not required for URL attachment",
168
- optional: true,
169
- options() {
170
- return Object.values(mime._types);
171
- },
172
- },
173
177
  name: {
174
178
  type: "string",
175
179
  label: "Name",
@@ -180,6 +184,19 @@ export default {
180
184
  type: "string",
181
185
  label: "File Attachment URL",
182
186
  description: "URL must start with `http://` or `https://`",
187
+ optional: true,
188
+ },
189
+ mimeType: {
190
+ type: "string",
191
+ label: "File Attachment Type",
192
+ description: "Not required for **File Attachment URL** property. Eg. `application/pdf`",
193
+ optional: true,
194
+ },
195
+ file: {
196
+ type: "string",
197
+ label: "File Attachment Path",
198
+ description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory). If you provide a file path, the **File Attachment URL** field will be ignored.",
199
+ optional: true,
183
200
  },
184
201
  desc: {
185
202
  type: "string",
@@ -259,422 +276,203 @@ export default {
259
276
  default: false,
260
277
  optional: true,
261
278
  },
279
+ checklistItemId: {
280
+ type: "string",
281
+ label: "Checklist Item ID",
282
+ description: "The ID of the checklist item.",
283
+ async options({ checklistId }) {
284
+ const checkItems = await this.listCheckItems({
285
+ checklistId,
286
+ });
287
+ return checkItems.map(({
288
+ name: label, id: value,
289
+ }) => ({
290
+ label,
291
+ value,
292
+ }));
293
+ },
294
+ },
295
+ cardAttachmentId: {
296
+ type: "string",
297
+ label: "Cover Attachment ID",
298
+ description: "Assign an attachment id to be the cover image for the card",
299
+ optional: true,
300
+ async options({
301
+ cardId, params,
302
+ }) {
303
+ const attachments = await this.listCardAttachments({
304
+ cardId,
305
+ params,
306
+ });
307
+ return attachments.map(({
308
+ name, url, id: value,
309
+ }) => ({
310
+ label: name || url,
311
+ value,
312
+ }));
313
+ },
314
+ },
262
315
  },
263
316
  methods: {
264
- _getBaseUrl() {
265
- return "https://api.trello.com/1/";
266
- },
267
- async _getAuthorizationHeader({
268
- data, method, url,
269
- }, $) {
270
- const requestData = {
271
- data,
272
- method,
273
- url,
274
- };
275
- const token = {
276
- key: this.$auth.oauth_access_token,
277
- secret: this.$auth.oauth_refresh_token,
278
- };
279
- return axios($ ?? this, {
280
- method: "POST",
281
- url: this.$auth.oauth_signer_uri,
282
- data: {
283
- requestData,
284
- token,
285
- },
286
- });
317
+ getSignerUri() {
318
+ return this.$auth.oauth_signer_uri;
287
319
  },
288
- async _makeRequest(args, $) {
320
+ getToken() {
289
321
  const {
290
- method = "GET",
291
- path,
292
- ...otherArgs
293
- } = args;
294
- const config = {
295
- method,
296
- url: `${this._getBaseUrl()}${path}`,
297
- ...otherArgs,
298
- };
299
- const authorization = await this._getAuthorizationHeader(config, $);
300
- config.headers = {
301
- ...config.headers,
302
- authorization,
303
- };
304
- try {
305
- return await axios($ ?? this, config);
306
- } catch (err) {
307
- console.log(err);
308
- }
309
- },
310
- /**
311
- * Archives a card.
312
- *
313
- * @param {string} idCard - the ID of the Card to archive.
314
- * @returns an updated card object with `closed` (archived) property set to true.
315
- * See more at the API docs:
316
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
317
- */
318
- async archiveCard(idCard, $) {
319
- const config = {
320
- path: `cards/${idCard}`,
321
- method: "PUT",
322
- data: {
323
- closed: true,
324
- },
325
- };
326
- return this._makeRequest(config, $);
327
- },
328
- /**
329
- * Create an Attachment to a Card
330
- *
331
- * @param {string} idCard - the ID of the Card to move.
332
- * @param {Object} params - an object containing parameters for the API request
333
- * @returns {array} an string array with the ID of all the Card's Attachments.
334
- * See more at the API docs:
335
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post
336
- */
337
- async addAttachmentToCardViaUrl(idCard, params, $) {
338
- const config = {
339
- path: `cards/${idCard}/attachments`,
340
- method: "POST",
341
- params,
342
- };
343
- return this._makeRequest(config, $);
344
- },
345
- /**
346
- * Adds an existing label to the specified card.
347
- *
348
- * @param {string} idCard - the ID of the Card to move.
349
- * @param {Object} params - an object containing parameters for the API request
350
- * @returns {array} an string array with the ID of all the Card's Labels.
351
- * See more at the API docs:
352
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idlabels-post
353
- */
354
- async addExistingLabelToCard(idCard, params, $) {
355
- const config = {
356
- path: `cards/${idCard}/idLabels`,
357
- method: "POST",
358
- params,
359
- };
360
- return this._makeRequest(config, $);
361
- },
362
- /**
363
- * Add a member to a card
364
- *
365
- * @param {string} idCard - the ID of the Card to move.
366
- * @param {Object} params - an object containing parameters for the API request
367
- * @returns {array} an string array with the ID of all the Card's Members.
368
- * See more at the API docs:
369
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idmembers-post
370
- */
371
- async addMemberToCard(idCard, params, $) {
372
- const config = {
373
- path: `cards/${idCard}/idMembers`,
374
- method: "POST",
375
- params,
376
- };
377
- return this._makeRequest(config, $);
378
- },
379
- /**
380
- * Creates a checklist on the specified card.
381
- *
382
- * @param {Object} params - an object containing parameters for the API request
383
- * @returns an object with the created checklist.
384
- * See more at the API docs:
385
- * https://developer.atlassian.com/cloud/trello/rest/api-group-checklists/#api-checklists-post
386
- */
387
- async createChecklist(params, $) {
388
- const config = {
389
- path: "checklists",
390
- method: "POST",
391
- params,
392
- };
393
- return this._makeRequest(config, $);
394
- },
395
- /**
396
- * Creates a comment on a card.
397
- *
398
- * @param {string} idCard - the ID of the Card that the comment should be created on.
399
- * @param {Object} params - an object containing parameters for the API request
400
- * @returns a object containing a summary of the related card, members, and other Trello
401
- * entities related to the newly created comment.
402
- * See more at the API docs:
403
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-comments-post
404
- */
405
- async createCommentOnCard(idCard, comment, $) {
406
- const config = {
407
- path: `cards/${idCard}/actions/comments`,
408
- method: "POST",
409
- params: {
410
- text: comment,
411
- },
412
- };
413
- return this._makeRequest(config, $);
414
- },
415
- /**
416
- * Closes a board.
417
- *
418
- * @param {string} boardId - the ID of the Board to close.
419
- * @returns the updated board object with the `closed` property set to true.
420
- * See more at the API docs:
421
- * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-put
422
- */
423
- async closeBoard(boardId, $) {
424
- const config = {
425
- path: `boards/${boardId}`,
426
- method: "PUT",
427
- data: {
428
- closed: true,
429
- },
322
+ oauth_access_token: key,
323
+ oauth_refresh_token: secret,
324
+ } = this.$auth;
325
+ return {
326
+ key,
327
+ secret,
430
328
  };
431
- return this._makeRequest(config, $);
432
329
  },
433
- /**
434
- * Creates a new card.
435
- *
436
- * @param {Object} opts - an object containing data for the API request
437
- * @returns the created card object. See more at the API docs:
438
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
439
- */
440
- async createCard(opts, $) {
441
- const config = {
442
- path: "cards",
443
- method: "post",
444
- data: opts,
445
- };
446
- return this._makeRequest(config, $);
447
- },
448
- /**
449
- * Deletes the specified checklist.
450
- *
451
- * @param {string} idChecklist - the ID of the checklist to delete.
452
- * @returns {object} an empty `limits` object indicating the operation completed successfully.
453
- */
454
- async deleteChecklist(idChecklist, $) {
455
- const config = {
456
- path: `checklists/${idChecklist}`,
457
- method: "DELETE",
458
- };
459
- return this._makeRequest(config, $);
460
- },
461
- /**
462
- * Finds a label on a specific board.
463
- *
464
- * @param {string} boardId - unique identifier of the board to search for labels.
465
- * @param {Object} params - an object containing parameters for the API request
466
- * @returns {array} an array with label objects complying with the specified parameters.
467
- */
468
- async findLabel(boardId, params, $) {
469
- const config = {
470
- path: `boards/${boardId}/labels`,
471
- params,
472
- };
473
- return this._makeRequest(config, $);
330
+ getUrl(path) {
331
+ return `https://api.trello.com/1${path}`;
474
332
  },
475
- /**
476
- * Finds a list in the specified board.
477
- *
478
- * @param {string} - boardId unique identifier of the board to search for lists.
479
- * @param {Object} params - an object containing parameters for the API request
480
- * @returns {array} an array with list objects conforming with the specified parameters.
481
- */
482
- async findList(boardId, params, $) {
483
- const config = {
484
- path: `boards/${boardId}/lists`,
485
- params,
333
+ _makeRequest({
334
+ $ = this, path, ...args
335
+ } = {}) {
336
+ const signConfig = {
337
+ token: this.getToken(),
338
+ oauthSignerUri: this.getSignerUri(),
486
339
  };
487
- return this._makeRequest(config, $);
488
- },
489
- /**
490
- * Moves a card to the specified board/list pair.
491
- *
492
- * @param {string} idCard the ID of the Card to move.
493
- * @param {Object} data - an object containing data for the API request
494
- * @returns an updated card object set to the specified board and list ids.
495
- * See more at the API docs:
496
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
497
- */
498
- async moveCardToList(idCard, data, $) {
340
+
499
341
  const config = {
500
- path: `cards/${idCard}`,
501
- method: "PUT",
502
- data,
503
- };
504
- return this._makeRequest(config, $);
505
- },
506
- async verifyTrelloWebhookRequest(request, callbackURL) {
507
- let secret = this.$auth.oauth_refresh_token;
508
- const base64Digest = function (s) {
509
- return crypto.createHmac("sha1", secret).update(s)
510
- .digest("base64");
342
+ ...args,
343
+ url: this.getUrl(path),
511
344
  };
512
- const content = JSON.stringify(request.body) + callbackURL;
513
- const doubleHash = base64Digest(content);
514
- const headerHash = request.headers["x-trello-webhook"];
515
- return doubleHash === headerHash;
345
+
346
+ return axios($, config, signConfig);
516
347
  },
517
- async getBoardActivity(boardId, filter = null) {
348
+ post(args = {}) {
518
349
  return this._makeRequest({
519
- path: `boards/${boardId}/actions`,
520
- params: {
521
- filter,
522
- },
350
+ method: "POST",
351
+ ...args,
523
352
  });
524
353
  },
525
- async getCardActivity(cardId, filter = null) {
354
+ put(args = {}) {
526
355
  return this._makeRequest({
527
- path: `cards/${cardId}/actions`,
528
- params: {
529
- filter,
530
- },
356
+ method: "PUT",
357
+ ...args,
531
358
  });
532
359
  },
533
- async getBoard(id) {
360
+ delete(args = {}) {
534
361
  return this._makeRequest({
535
- path: `boards/${id}`,
362
+ method: "DELETE",
363
+ ...args,
536
364
  });
537
365
  },
538
- async getBoards(id = this.$auth.oauth_uid) {
539
- return this._makeRequest({
540
- path: `members/${id}/boards`,
366
+ createBoard(args = {}) {
367
+ return this.post({
368
+ path: "/boards",
369
+ ...args,
541
370
  });
542
371
  },
543
- /**
544
- * Gets details of a card.
545
- *
546
- * @param {string} id - the ID of the card to get details of.
547
- * @returns {object} a card object. See more at the API docs:
548
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
549
- */
550
- async getCard(id, params = {}, $) {
551
- return this._makeRequest({
552
- path: `cards/${id}`,
553
- params,
554
- }, $);
555
- },
556
- async getCards(id, params = {}, $) {
557
- return this._makeRequest({
558
- path: `boards/${id}/cards`,
559
- params,
560
- }, $);
561
- },
562
- async getFilteredCards(boardId, filter) {
563
- return this._makeRequest({
564
- path: `boards/${boardId}/cards`,
565
- params: {
566
- filter,
567
- },
372
+ updateBoard({
373
+ boardId, ...args
374
+ } = {}) {
375
+ return this.put({
376
+ path: `/boards/${boardId}`,
377
+ ...args,
568
378
  });
569
379
  },
570
- async getCardsInList(listId, params = {}, $) {
571
- return this._makeRequest({
572
- path: `lists/${listId}/cards`,
573
- params,
574
- }, $);
380
+ updateCard({
381
+ cardId, ...args
382
+ } = {}) {
383
+ return this.put({
384
+ path: `/cards/${cardId}`,
385
+ ...args,
386
+ });
575
387
  },
576
- async getMemberCards(userId) {
388
+ findLabel({
389
+ boardId, ...args
390
+ } = {}) {
577
391
  return this._makeRequest({
578
- path: `members/${userId}/cards`,
392
+ path: `/boards/${boardId}/labels`,
393
+ ...args,
579
394
  });
580
395
  },
581
- async getChecklist(id) {
396
+ getBoardActivity({
397
+ boardId, ...args
398
+ } = {}) {
582
399
  return this._makeRequest({
583
- path: `checklists/${id}`,
400
+ path: `/boards/${boardId}/actions`,
401
+ ...args,
584
402
  });
585
403
  },
586
- async getLabel(id) {
404
+ getBoard({
405
+ boardId, ...args
406
+ } = {}) {
587
407
  return this._makeRequest({
588
- path: `labels/${id}`,
408
+ path: `/boards/${boardId}`,
409
+ ...args,
589
410
  });
590
411
  },
591
- async getList(id) {
412
+ getBoards({
413
+ boardId = this.$auth.oauth_uid, ...args
414
+ } = {}) {
592
415
  return this._makeRequest({
593
- path: `lists/${id}`,
416
+ path: `/members/${boardId}/boards`,
417
+ ...args,
594
418
  });
595
419
  },
596
- async getLists(id) {
420
+ getCard({
421
+ cardId, ...args
422
+ } = {}) {
597
423
  return this._makeRequest({
598
- path: `boards/${id}/lists`,
424
+ path: `/cards/${cardId}`,
425
+ ...args,
599
426
  });
600
427
  },
601
- async getNotifications(id, params) {
428
+ getCards({
429
+ boardId, ...args
430
+ } = {}) {
602
431
  return this._makeRequest({
603
- path: `members/${id}/notifications`,
604
- params,
432
+ path: `/boards/${boardId}/cards`,
433
+ ...args,
605
434
  });
606
435
  },
607
- async getMember(id) {
436
+ getCardsInList({
437
+ listId, ...args
438
+ } = {}) {
608
439
  return this._makeRequest({
609
- path: `members/${id}`,
440
+ path: `/lists/${listId}/cards`,
441
+ ...args,
610
442
  });
611
443
  },
612
- async getAttachment(cardId, attachmentId) {
444
+ getLabel({
445
+ labelId, ...args
446
+ } = {}) {
613
447
  return this._makeRequest({
614
- path: `cards/${cardId}/attachments/${attachmentId}`,
448
+ path: `/labels/${labelId}`,
449
+ ...args,
615
450
  });
616
451
  },
617
- async getCardList(cardId) {
452
+ getLists({
453
+ boardId, ...args
454
+ } = {}) {
618
455
  return this._makeRequest({
619
- path: `cards/${cardId}/list`,
456
+ path: `/boards/${boardId}/lists`,
457
+ ...args,
620
458
  });
621
459
  },
622
- async createHook({
623
- id, endpoint,
624
- }) {
625
- const resp = await this._makeRequest({
626
- method: "post",
627
- path: "webhooks/",
628
- headers: {
629
- "Content-Type": "applicaton/json",
630
- },
631
- params: {
632
- idModel: id,
633
- description: "Pipedream Source ID", //todo add ID
634
- callbackURL: endpoint,
635
- },
460
+ getList({
461
+ listId, ...args
462
+ } = {}) {
463
+ return this._makeRequest({
464
+ path: `/lists/${listId}`,
465
+ ...args,
636
466
  });
637
- return resp;
638
467
  },
639
- async deleteHook({ hookId }) {
468
+ getMember({
469
+ memberId, ...args
470
+ } = {}) {
640
471
  return this._makeRequest({
641
- method: "delete",
642
- path: `webhooks/${hookId}`,
472
+ path: `/members/${memberId}`,
473
+ ...args,
643
474
  });
644
475
  },
645
- /**
646
- * Removes an existing label from the specified card.
647
- *
648
- * @param {string} idCard - the ID of the Card to remove the Label from.
649
- * @param {string} idLabel - the ID of the Label to be removed from the card.
650
- * @returns {object} an object with the null valued property `_value` indicating that
651
- * there were no errors
652
- */
653
- async removeLabelFromCard(idCard, idLabel, $) {
654
- const config = {
655
- path: `cards/${idCard}/idLabels/${idLabel}`,
656
- method: "DELETE",
657
- };
658
- return this._makeRequest(config, $);
659
- },
660
- /**
661
- * Renames the specified list
662
- *
663
- * @param {string} listId - the ID of the List to rename.
664
- * @param {Object} data - an object containing data for the API request
665
- * @returns {object} a list object with the `closed` property, indicated if the list is
666
- * closed or archived, `id` the id of the renamed List, `idBoard` the id of the Board parent
667
- * to the List, `name` with the new name of the List, and `pos` with the position of the List
668
- * in the Board.
669
- */
670
- async renameList(listId, data, $) {
671
- const config = {
672
- path: `lists/${listId}`,
673
- method: "PUT",
674
- data,
675
- };
676
- return this._makeRequest(config, $);
677
- },
678
476
  /**
679
477
  * Searches for members, cards, boards, and/or organizations matching the specified query.
680
478
  *
@@ -684,99 +482,83 @@ export default {
684
482
  * this case "cards"), `partial` the search `terms` as included in `query`, and other
685
483
  * `modifiers`.
686
484
  */
687
- async search(params, $) {
688
- const config = {
689
- path: "search",
690
- params,
691
- };
692
- return this._makeRequest(config, $);
693
- },
694
- /**
695
- * Searches for boards matching the specified query.
696
- *
697
- * @param {Object} opts - an object containing data for the API request
698
- * @returns {cards: array, options: object} an array with the `cards` objects matching the
699
- * specified `query`, and an object with the `options` for the search, such as `modelTypes` (in
700
- * this case "cards"), `partial` the search `terms` as included in `query`, and other
701
- * `modifiers`.
702
- */
703
- async searchBoards(opts, $) {
704
- const params = {
705
- ...opts,
706
- idOrganizations: opts.idOrganizations?.join(","),
707
- };
708
- return this.search(params, $);
709
- },
710
- /**
711
- * Searches for cards matching the specified query.
712
- *
713
- * @param {Object} opts - an object containing data for the API request
714
- * @returns {cards: array, options: object} an array with the `cards` objects matching the
715
- * specified `query`, and an object with the `options` for the search, such as `modelTypes` (in
716
- * this case "cards"), `partial` the search `terms` as included in `query`, and other
717
- * `modifiers`.
718
- */
719
- async searchCards(opts, $) {
720
- const params = {
721
- ...opts,
722
- idOrganizations: opts.idOrganizations?.join(","),
723
- idCards: opts.idCards?.join(","),
724
- };
725
- return this.search(params, $);
485
+ search(args = {}) {
486
+ return this._makeRequest({
487
+ path: "/search",
488
+ ...args,
489
+ });
726
490
  },
727
- /**
728
- * Updates a card.
729
- *
730
- * @param {string} idCard - the ID of the card to update
731
- * @param {Object} params - an object containing parameters for the API request
732
- * @returns the updated card object. See more at the API docs:
733
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
734
- */
735
- async updateCard(idCard,
736
- params, $) {
737
- const config = {
738
- path: `cards/${idCard}`,
739
- method: "PUT",
740
- params,
741
- };
742
- return this._makeRequest(config, $);
491
+ listMembers({
492
+ boardId, ...args
493
+ } = {}) {
494
+ return this._makeRequest({
495
+ path: `/boards/${boardId}/members`,
496
+ ...args,
497
+ });
743
498
  },
744
- async listMembers(board) {
499
+ listBoardChecklists({
500
+ boardId, ...args
501
+ } = {}) {
745
502
  return this._makeRequest({
746
- path: `boards/${board}/members`,
503
+ path: `/boards/${boardId}/checklists`,
504
+ ...args,
747
505
  });
748
506
  },
749
- async listBoardChecklists(board) {
507
+ listCardChecklists({
508
+ cardId, ...args
509
+ } = {}) {
750
510
  return this._makeRequest({
751
- path: `boards/${board}/checklists`,
511
+ path: `/cards/${cardId}/checklists`,
512
+ ...args,
752
513
  });
753
514
  },
754
- async listCardChecklists(card) {
515
+ listOrganizations({
516
+ memberId, ...args
517
+ } = {}) {
755
518
  return this._makeRequest({
756
- path: `cards/${card}/checklists`,
519
+ path: `/members/${memberId}/organizations`,
520
+ ...args,
757
521
  });
758
522
  },
759
- async listOrganizations(id) {
523
+ getCustomField({
524
+ customFieldId, ...args
525
+ } = {}) {
760
526
  return this._makeRequest({
761
- path: `members/${id}/organizations?fields="id,name"`,
527
+ path: `/customFields/${customFieldId}`,
528
+ ...args,
762
529
  });
763
530
  },
764
- getCustomField(customFieldId, $) {
531
+ listCustomFields({
532
+ boardId, ...args
533
+ } = {}) {
765
534
  return this._makeRequest({
766
- path: `customFields/${customFieldId}`,
767
- }, $);
535
+ path: `/boards/${boardId}/customFields`,
536
+ ...args,
537
+ });
538
+ },
539
+ updateCustomFields({
540
+ cardId, ...args
541
+ } = {}) {
542
+ return this.put({
543
+ path: `/cards/${cardId}/customFields`,
544
+ ...args,
545
+ });
768
546
  },
769
- listCustomFields(boardId, $) {
547
+ listCheckItems({
548
+ checklistId, ...args
549
+ } = {}) {
770
550
  return this._makeRequest({
771
- path: `boards/${boardId}/customFields`,
772
- }, $);
551
+ path: `/checklists/${checklistId}/checkItems`,
552
+ ...args,
553
+ });
773
554
  },
774
- updateCustomFields(cardId, data, $) {
555
+ listCardAttachments({
556
+ cardId, ...args
557
+ } = {}) {
775
558
  return this._makeRequest({
776
- method: "PUT",
777
- path: `cards/${cardId}/customFields`,
778
- data,
779
- }, $);
559
+ path: `/cards/${cardId}/attachments`,
560
+ ...args,
561
+ });
780
562
  },
781
563
  },
782
564
  };