tacokit 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +4 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +2 -1
  6. data/README.md +140 -47
  7. data/Rakefile +13 -0
  8. data/bin/_guard-core +16 -0
  9. data/bin/console +14 -0
  10. data/bin/guard +16 -0
  11. data/bin/rake +16 -0
  12. data/bin/rspec +16 -0
  13. data/bin/rubocop +16 -0
  14. data/bin/setup +7 -0
  15. data/lib/tacokit/authorization.rb +8 -9
  16. data/lib/tacokit/client.rb +14 -20
  17. data/lib/tacokit/client/actions.rb +30 -14
  18. data/lib/tacokit/client/boards.rb +112 -16
  19. data/lib/tacokit/client/cards.rb +251 -72
  20. data/lib/tacokit/client/checklists.rb +25 -14
  21. data/lib/tacokit/client/labels.rb +11 -4
  22. data/lib/tacokit/client/lists.rb +66 -13
  23. data/lib/tacokit/client/members.rb +118 -42
  24. data/lib/tacokit/client/notifications.rb +29 -2
  25. data/lib/tacokit/client/organizations.rb +13 -5
  26. data/lib/tacokit/client/searches.rb +17 -2
  27. data/lib/tacokit/client/tokens.rb +8 -2
  28. data/lib/tacokit/client/types.rb +4 -2
  29. data/lib/tacokit/client/webhooks.rb +17 -4
  30. data/lib/tacokit/collection.rb +6 -5
  31. data/lib/tacokit/configuration.rb +10 -2
  32. data/lib/tacokit/middleware.rb +16 -0
  33. data/lib/tacokit/resource.rb +7 -6
  34. data/lib/tacokit/transform.rb +2 -4
  35. data/lib/tacokit/utils.rb +7 -4
  36. data/lib/tacokit/version.rb +2 -1
  37. data/tacokit.gemspec +4 -4
  38. metadata +17 -273
  39. data/spec/cassettes/Tacokit_Client/_connection/authorized_GET_request_with_app_key_and_token_params.json +0 -1
  40. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_a_token_authorized_action.json +0 -1
  41. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_oauth_authorized_board.json +0 -1
  42. data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +0 -1
  43. data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +0 -1
  44. data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +0 -1
  45. data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +0 -1
  46. data/spec/cassettes/Tacokit_Client_Actions/_delete_action/deletes_an_action.json +0 -1
  47. data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_an_action.json +0 -1
  48. data/spec/cassettes/Tacokit_Client_Actions/_update_action_text/updates_an_action.json +0 -1
  49. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +0 -1
  50. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_a_token_authorized_board.json +0 -1
  51. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_oauth_authorized_board.json +0 -1
  52. data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +0 -1
  53. data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +0 -1
  54. data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +0 -1
  55. data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +0 -1
  56. data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +0 -1
  57. data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +0 -1
  58. data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +0 -1
  59. data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +0 -1
  60. data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +0 -1
  61. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_a_board.json +0 -1
  62. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_nested_resource.json +0 -1
  63. data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +0 -1
  64. data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +0 -1
  65. data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +0 -1
  66. data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +0 -1
  67. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +0 -1
  68. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +0 -1
  69. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +0 -1
  70. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +0 -1
  71. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +0 -1
  72. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +0 -1
  73. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +0 -1
  74. data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +0 -1
  75. data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +0 -1
  76. data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +0 -1
  77. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +0 -1
  78. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +0 -1
  79. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +0 -1
  80. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +0 -1
  81. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +0 -1
  82. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +0 -1
  83. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +0 -1
  84. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +0 -1
  85. data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +0 -1
  86. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +0 -1
  87. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +0 -1
  88. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +0 -1
  89. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +0 -1
  90. data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +0 -1
  91. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +0 -1
  92. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +0 -1
  93. data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +0 -1
  94. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +0 -1
  95. data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +0 -1
  96. data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +0 -1
  97. data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +0 -1
  98. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +0 -1
  99. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +0 -1
  100. data/spec/cassettes/Tacokit_Client_Checklists/_checklist/returns_a_checklist_by_id.json +0 -1
  101. data/spec/cassettes/Tacokit_Client_Checklists/_create_checklist/creates_a_checklist.json +0 -1
  102. data/spec/cassettes/Tacokit_Client_Checklists/_delete_checklist/deletes_a_checklist.json +0 -1
  103. data/spec/cassettes/Tacokit_Client_Checklists/_update_checklist/updates_a_checklist.json +0 -1
  104. data/spec/cassettes/Tacokit_Client_Labels/_create_label/creates_a_label.json +0 -1
  105. data/spec/cassettes/Tacokit_Client_Labels/_delete_label/deletes_a_label.json +0 -1
  106. data/spec/cassettes/Tacokit_Client_Labels/_label/returns_a_label_by_id.json +0 -1
  107. data/spec/cassettes/Tacokit_Client_Labels/_update_label/updates_a_label.json +0 -1
  108. data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +0 -1
  109. data/spec/cassettes/Tacokit_Client_Lists/_create_list/creates_a_list.json +0 -1
  110. data/spec/cassettes/Tacokit_Client_Lists/_list/returns_a_list_by_id.json +0 -1
  111. data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +0 -1
  112. data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +0 -1
  113. data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +0 -1
  114. data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +0 -1
  115. data/spec/cassettes/Tacokit_Client_Lists/_update_list/updates_a_list.json +0 -1
  116. data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +0 -1
  117. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_for_me_with_options_as_first_arg.json +0 -1
  118. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +0 -1
  119. data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +0 -1
  120. data/spec/cassettes/Tacokit_Client_Members/_member/accepts_a_resource.json +0 -1
  121. data/spec/cassettes/Tacokit_Client_Members/_member/authenticated/returns_self.json +0 -1
  122. data/spec/cassettes/Tacokit_Client_Members/_member/returns_a_member.json +0 -1
  123. data/spec/cassettes/Tacokit_Client_Members/_member/returns_self.json +0 -1
  124. data/spec/cassettes/Tacokit_Client_Members/_member/supports_query_fields_as_string_or_array.json +0 -1
  125. data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +0 -1
  126. data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +0 -1
  127. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +0 -1
  128. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_a_member.json +0 -1
  129. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_nested_resource.json +0 -1
  130. data/spec/cassettes/Tacokit_Client_Notifications/_notification/returns_a_notification_by_id.json +0 -1
  131. data/spec/cassettes/Tacokit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
  132. data/spec/cassettes/Tacokit_Client_Organizations/_create_organization/creates_a_organization.json +0 -1
  133. data/spec/cassettes/Tacokit_Client_Organizations/_delete_organization/deletes_a_organization.json +0 -1
  134. data/spec/cassettes/Tacokit_Client_Organizations/_organization/returns_an_organization_by_id.json +0 -1
  135. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_actions.json +0 -1
  136. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_boards.json +0 -1
  137. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_members.json +0 -1
  138. data/spec/cassettes/Tacokit_Client_Organizations/_update_organization/updates_a_organization.json +0 -1
  139. data/spec/cassettes/Tacokit_Client_Searches/_search/returns_search_result.json +0 -1
  140. data/spec/cassettes/Tacokit_Client_Tokens/_delete_token/deletes_a_token.json +0 -1
  141. data/spec/cassettes/Tacokit_Client_Tokens/_token/returns_a_token_for_token_string.json +0 -1
  142. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_member.json +0 -1
  143. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_webhooks.json +0 -1
  144. data/spec/cassettes/Tacokit_Client_Types/_type/returns_a_type_by_id.json +0 -1
  145. data/spec/cassettes/Tacokit_Client_Webhooks/_create_webhook/creates_a_webhook.json +0 -1
  146. data/spec/cassettes/Tacokit_Client_Webhooks/_delete_webhook/deletes_a_webhook.json +0 -1
  147. data/spec/cassettes/Tacokit_Client_Webhooks/_update_webhook/updates_a_webhook.json +0 -1
  148. data/spec/cassettes/Tacokit_Client_Webhooks/_webhook/returns_a_webhook_by_short_link.json +0 -1
  149. data/spec/fixtures/taco.png +0 -0
  150. data/spec/spec_helper.rb +0 -171
  151. data/spec/tacokit/authorization_spec.rb +0 -47
  152. data/spec/tacokit/client/actions_spec.rb +0 -137
  153. data/spec/tacokit/client/boards_spec.rb +0 -171
  154. data/spec/tacokit/client/cards_spec.rb +0 -446
  155. data/spec/tacokit/client/checklists_spec.rb +0 -89
  156. data/spec/tacokit/client/labels_spec.rb +0 -62
  157. data/spec/tacokit/client/lists_spec.rb +0 -131
  158. data/spec/tacokit/client/members_spec.rb +0 -145
  159. data/spec/tacokit/client/notifications_spec.rb +0 -25
  160. data/spec/tacokit/client/organizations_spec.rb +0 -79
  161. data/spec/tacokit/client/searches_spec.rb +0 -11
  162. data/spec/tacokit/client/tokens_spec.rb +0 -33
  163. data/spec/tacokit/client/types_spec.rb +0 -11
  164. data/spec/tacokit/client/webhooks_spec.rb +0 -61
  165. data/spec/tacokit/client_spec.rb +0 -28
  166. data/spec/tacokit/configuration_spec.rb +0 -50
  167. data/spec/tacokit/middleware/raise_error_spec.rb +0 -34
  168. data/spec/tacokit/resource_spec.rb +0 -151
  169. data/spec/tacokit/transform_spec.rb +0 -133
  170. data/spec/tacokit_spec.rb +0 -14
@@ -2,67 +2,78 @@ module Tacokit
2
2
  class Client
3
3
  module Checklists
4
4
  # Retrieve a checklist
5
- #
5
+ # @param checklist_id [String] the checklist identifier
6
+ # @param options [Hash] options to fetch the checklist with
7
+ # @return [Tacokit::Resource] the checklist resource
6
8
  # @see https://developers.trello.com/advanced-reference/checklist#get-1-checklists-idchecklist
7
9
  def checklist(checklist_id, options = nil)
8
10
  get checklist_path(checklist_id), options
9
11
  end
10
12
 
11
13
  # Retrieve the checklist's board
12
- #
14
+ # @param checklist_id [String] the checklist identifier
15
+ # @param options [Hash] the options to fetch the board with
16
+ # @return [Tacokit::Resource] the board resource
13
17
  # @see https://developers.trello.com/advanced-reference/checklist#get-1-checklists-idchecklist-board
14
18
  def checklist_board(checklist_id, options = {})
15
19
  checklist_resource checklist_list_id, "board", options
16
20
  end
17
21
 
18
22
  # Retrieve a checklist's card
19
- #
23
+ # @param checklist_id [String] the checklist identifier
24
+ # @param options [Hash] the options to fetch the card with
25
+ # @return [Tacokit::Resource] the card resource
20
26
  # @see https://developers.trello.com/advanced-reference/checklist#get-1-checklists-idchecklist-cards
21
27
  def checklist_card(checklist_id, options = {})
22
28
  checklist_resource checklist_id, "card", options
23
29
  end
24
30
 
25
31
  # Retrieve a checklist's check items
26
- #
32
+ # @param checklist_id [String] the checklist identifier
33
+ # @param options [Hash] the options to fetch the checklist with
34
+ # @return [Array] the check items collection
27
35
  # @see https://developers.trello.com/advanced-reference/checklist#get-1-checklists-idchecklist-checkitems
28
36
  def check_items(checklist_id, options = {})
29
37
  checklist_resource checklist_id, "check_items", options
30
38
  end
31
- alias_method :checklist_check_items, :check_items
39
+ alias checklist_check_items check_items
32
40
 
33
41
  # Updates a checklist
34
- #
42
+ # @param checklist_id [String] the checklist identifier
43
+ # @param options [Hash] the options to update the checklist with
35
44
  # @see https://developers.trello.com/advanced-reference/checklist#put-1-checklists-idchecklist
36
45
  def update_checklist(checklist_id, options = {})
37
46
  put checklist_path(checklist_id), options
38
47
  end
39
- alias_method :checklist_update, :update_checklist
48
+ alias checklist_update update_checklist
40
49
 
41
50
  # Create a checklist
42
- #
51
+ # @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
52
+ # @param name [String] name for the checklist
43
53
  # @see https://developers.trello.com/advanced-reference/checklist#post-1-checklists
44
54
  def create_checklist(card_id, name, options = {})
45
55
  options.update card_id: card_id, name: name
46
56
  post "checklists", options
47
57
  end
48
- alias_method :checklist_create, :create_checklist
58
+ alias checklist_create create_checklist
49
59
 
50
60
  # Add a checklist item to a checklist
51
- #
61
+ # @param checklist_id [String] the checklist identifier
62
+ # @param name [String] name for the check item
52
63
  # @see https://developers.trello.com/advanced-reference/checklist#post-1-checklists-idchecklist-checkitems
53
64
  def add_checklist_check_item(checklist_id, name, options = {})
54
65
  post checklist_path(checklist_id, "checkItems"), options.merge(name: name)
55
66
  end
56
- alias_method :checklist_check_item_create, :add_checklist_check_item
57
- alias_method :add_checklist_item, :add_checklist_check_item
67
+ alias checklist_check_item_create add_checklist_check_item
68
+ alias add_checklist_item add_checklist_check_item
58
69
 
59
70
  # Delete a checklist
60
- #
71
+ # @param checklist_id [String] the checklist identifier
61
72
  # @see https://developers.trello.com/advanced-reference/checklist#delete-1-checklists-idchecklist
62
73
  def delete_checklist(checklist_id)
63
74
  delete checklist_path(checklist_id)
64
75
  end
65
- alias_method :checklist_delete, :delete_checklist
76
+ alias checklist_delete delete_checklist
66
77
 
67
78
  private
68
79
 
@@ -2,21 +2,28 @@ module Tacokit
2
2
  class Client
3
3
  module Labels
4
4
  # Retrieve a label
5
- #
5
+ # @param label_id [String] the label identifier
6
+ # @param options [Hash] options to fetch the label with
7
+ # @return [Tacokit::Resource] the label resource
6
8
  # @see https://developers.trello.com/advanced-reference/label#get-1-labels-idlabel
7
9
  def label(label_id, options = nil)
8
10
  get label_path(label_id), options
9
11
  end
10
12
 
11
13
  # Update a label
12
- #
14
+ # @param label_id [String] the label identifier
15
+ # @param options [Hash] the options to update the label with
16
+ # @return [Tacokit::Resource] the label resource
13
17
  # @see https://developers.trello.com/advanced-reference/label#put-1-labels-idlabel
14
18
  def update_label(label_id, options = {})
15
19
  put label_path(label_id), options
16
20
  end
17
21
 
18
22
  # Create a label
19
- #
23
+ # @param board_id [String] the board identifier
24
+ # @param name [String] the label name
25
+ # @param color [String] the label color
26
+ # @return [Tacokit::Resource] the label resource
20
27
  # @see https://developers.trello.com/advanced-reference/label#post-1-labels
21
28
  def create_label(board_id, name, color)
22
29
  post "labels",
@@ -26,7 +33,7 @@ module Tacokit
26
33
  end
27
34
 
28
35
  # Delete a label
29
- #
36
+ # @param label_id [String] the label identifier
30
37
  # @see https://developers.trello.com/advanced-reference/label#delete-1-labels-idlabel
31
38
  def delete_label(label_id)
32
39
  delete label_path(label_id)
@@ -1,65 +1,118 @@
1
1
  module Tacokit
2
2
  class Client
3
+ # Methods for the Lists API
4
+ # @see https://developers.trello.com/advanced-reference/list
3
5
  module Lists
4
6
  # Retrieve a list by id
5
- #
7
+ # @param list_id [String] the list identifier or shortlink
8
+ # @return [Tacokit::Resource<List>] the list resource
9
+ # @example Retrieve a list by its id with its open cards
10
+ # Tacokit.list("aListId", cards: "open") #=> Tacokit::Resource<List>
6
11
  # @see https://developers.trello.com/advanced-reference/list#get-1-labels-idlabel-board
7
12
  def list(list_id, options = nil)
8
13
  get list_path(list_id), options
9
14
  end
10
15
 
11
- # Retrive a list's actions
12
- #
16
+ # Retrieve list's actions
17
+ # @param list_id [String, Tacokit::Resource<List>] the list identifier, shortlink, or list
18
+ # @param options [Hash] the options to fetch the actions with
19
+ # @return [Tacokit::Collection<Action>] the action resources
20
+ # @example fetch "comment" actions for a given list
21
+ # list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
22
+ # Tacokit.list_actions(list, filter: "comment_card") #=> Tacokit::Collection<Action>
13
23
  # @see https://developers.trello.com/advanced-reference/list#get-1-lists-idlist-actions
14
24
  def list_actions(list_id, options = {})
15
25
  paginated_list_resource list_id, "actions", options
16
26
  end
17
27
 
18
- # Retrive a list's board
19
- #
28
+ # Retrieve a list's board
29
+ # @param list_id [String, Tacokit::Resource<List>] the list identifier, shortlink, or list
30
+ # @param options [Hash] the options to fetch the board with
31
+ # @return [Tacokit::Resource<Board>] the board resource
32
+ # @example fetch a list's board
33
+ # list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
34
+ # Tacokit.list_board(list) #=> Tacokit::Resource<Board>
20
35
  # @see https://developers.trello.com/advanced-reference/list#get-1-lists-idlist-board
21
36
  def list_board(list_id, options = {})
22
37
  list_resource list_id, "board", options
23
38
  end
24
39
 
25
40
  # Retrive a list's cards
26
- #
41
+ # @param list_id [String, Tacokit::Resource<List>] the list identifier or list
42
+ # @param options [Hash] the options to fetch the cards with
43
+ # @return [Tacokit::Collection<Card>] the card resources
44
+ # @example fetch list cards
45
+ # list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
46
+ # Tacokit.list_cards(list) #=> Tacokit::Collection<Card>
47
+ # @example fetch list cards with attachments, members, stickers
48
+ # Tacokit.list_cards(list, attachments: true, members: true, stickers: true) #=> Tacokit::Collection<Card>
49
+ # @example configure a local client, fetch a list"s cards with a subset of attributes
50
+ # client = Tacokit::Client.new app_key: "another-app-key"
51
+ # client.list_cards(list) #=> Tacokit::Collection<Card>
27
52
  # @see https://developers.trello.com/advanced-reference/list#get-1-lists-idlist-cards
28
53
  def list_cards(list_id, options = {})
29
54
  paginated_list_resource list_id, "cards", options
30
55
  end
31
56
 
32
57
  # Update a list's attributes
33
- #
58
+ # @param list_id [String, Tacokit::Resource<List>] the list identifier, shortlink, or list
59
+ # @param options [Hash] the attributes to update on the list
60
+ # @return [Tacokit::Resource<List>] the list resource
61
+ # @example Change a list's name and position
62
+ # list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
63
+ # Tacokit.update_list(list, name: "New Name", pos: "top") #=> Tacokit::Resource<List>
34
64
  # @see https://developers.trello.com/advanced-reference/list#put-1-lists-idlis
35
65
  def update_list(list_id, options = {})
36
66
  put list_path(list_id), options
37
67
  end
38
68
 
39
69
  # Create a new list
40
- #
70
+ # @param board_id [String] the board identifier
71
+ # @param name [String] a name for the list
72
+ # @param options [Hash] options to create the list with
73
+ # @return [Tacokit::Resource<List>] the list resource
74
+ # @example Create a new list on the top
75
+ # board = Tacokit.board("aBoardId")
76
+ # Tacokit.create_list(board, "New List", pos: "top") #=> Tacokit::Resource<List>
41
77
  # @see https://developers.trello.com/advanced-reference/list#post-1-lists
42
78
  def create_list(board_id, name, options = {})
43
- post "lists", options.merge(name: name, board_id: board_id)
79
+ post "lists", options.merge(name: name, board_id: resource_id(board_id))
44
80
  end
45
81
 
46
82
  # Archive all cards in a list
47
- #
83
+ # @param list_id [String, Tacokit::Resource<Card>] the list identifier, shortlink, or list
84
+ # @example Archive cards
85
+ # list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
86
+ # Tacokit.archive_all_cards(list)
48
87
  # @see https://developers.trello.com/advanced-reference/list#post-1-lists-idlist-moveallcards
49
88
  def archive_list_cards(list_id)
50
89
  post list_path(list_id, camp("archive_all_cards"))
51
90
  end
52
91
 
53
92
  # Move cards from one list to another
54
- #
93
+ # @param list_id [String, Tacokit::Resource<List>] the source list identifier or list
94
+ # @param destination_list_id [String, Tacokit::Resource<List>] the destination list identifier
95
+ # @param board_id [String] the board identifier
96
+ # @example Move cards from list A to B
97
+ # listA = Tacokit.list("aListId") #=> Tacokit::Resource<List>
98
+ # listB = Tacokit.list("bListId") #=> Tacokit::Resource<List>
99
+ # Tacokit.move_all_cards(listA, listB)
55
100
  # @see https://developers.trello.com/advanced-reference/list#post-1-lists-idlist-moveallcards
56
- def move_list_cards(list_id, destination_list_id, board_id)
101
+ def move_list_cards(list_id, destination_list_id, board_id = nil)
102
+ board_id ||= resolve_board_id(destination_list_id)
57
103
  post list_path(list_id, camp("move_all_cards")),
58
- list_id: destination_list_id, board_id: board_id
104
+ list_id: resource_id(destination_list_id), board_id: resource_id(board_id)
59
105
  end
60
106
 
61
107
  private
62
108
 
109
+ def resolve_board_id(list_id)
110
+ return list_id.board_id if list_id.respond_to?(:board_id)
111
+ return list_id.board.id if list_id.respond_to?(:board)
112
+
113
+ raise ArgumentError, "Required option :board_i"
114
+ end
115
+
63
116
  def list_resource(list_id, resource, *paths)
64
117
  paths, options = extract_options(camp(resource), *paths)
65
118
  get list_path(list_id, *paths), options
@@ -1,94 +1,170 @@
1
1
  module Tacokit
2
2
  class Client
3
+ # Methods for the Members API
4
+ # @see https://developers.trello.com/advanced-reference/member
3
5
  module Members
4
- # Retrieve a Trello member
5
- #
6
+ # @overload member(username = "me", options = nil)
7
+ # Retrieve a Trello member by username
8
+ # @param username [String] the member's username
9
+ # @param options [Hash] the options to fetch the member with
10
+ # @return [Tacokit::Resource<Member>] the member resource
11
+ # @example fetch the member named 'rossta'
12
+ # Tacokit.member("tacokit") #=> Tacokit::Resource<Member>
13
+ # @overload member(options)
14
+ # Retrieve the current member
15
+ # @param options [Hash] the options to fetch the member with
16
+ # @return [Tacokit::Resource<Member>] the member resource
17
+ # @example fetch the current member
18
+ # Tacokit.member #=> Tacokit::Resource<Member>
19
+ # @example fetch the current member with all boards
20
+ # Tacokit.member(boards: "all") #=> Tacokit::Resource<Member>
21
+ # @example configure a local client and fetch different current member
22
+ # client = Tacokit::Client.new app_key: "another-app-key"
23
+ # client.member #=> Tacokit::Resource<Member>
6
24
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username
7
25
  def member(username = "me", options = nil)
8
26
  username, options = extract_member_args(username, options)
9
27
  get member_path(username), options
10
28
  end
11
29
 
12
- # Retrieve a member's actions
13
- #
30
+ # @overload actions(username = "me", options = nil)
31
+ # Retrieve a member's actions
32
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
33
+ # @param options [Hash] the options to fetch the actions with
34
+ # @return [Tacokit::Collection<Action>] the actions collection
35
+ # @example fetch the actions for the member named 'tacokit'
36
+ # Tacokit.actions("tacokit") #=> Tacokit::Collection<Member>
37
+ # @overload actions(options = nil)
38
+ # Retrieve the current member's actions
39
+ # @param options [Hash] the options to fetch the actions with
40
+ # @return [Tacokit::Collection] the action resources
41
+ # @example fetch the current member's actions
42
+ # Tacokit.actions #=> Tacokit::Collection<Action>
43
+ # @example fetch the current member's card comment actions only
44
+ # Tacokit.actions(filter: "comment_card") #=> Tacokit::Collection<Action>
14
45
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-actions
15
46
  def actions(username = "me", options = {})
16
47
  username, options = extract_member_args(username, options)
17
48
  paginated_get member_path(username, "actions"), options
18
49
  end
19
- alias_method :member_actions, :actions
50
+ alias member_actions actions
20
51
 
21
- # Retrieve a member's boards
22
- #
52
+ # @overload boards(username = "me", options = {})
53
+ # Retrieve a member's boards
54
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
55
+ # @param options [Hash] the options to fetch the boards with
56
+ # @return [Tacokit::Collection<Board>] the boards collection
57
+ # @example fetch the boards for the member named 'tacokit'
58
+ # Tacokit.boards("tacokit") #=> Tacokit::Collection<Board>
59
+ # @overload boards(options = {})
60
+ # Retrieve current member's boards
61
+ # @param options [Hash] the options to fetch the boards with
62
+ # @return [Tacokit::Resource] the boards collection
63
+ # @example fetch the current member's boards
64
+ # Tacokit.boards #=> Tacokit::Collection<Board>
65
+ # @example fetch the current member's open boards only
66
+ # Tacokit.boards(filter: "all") #=> Tacokit::Collection<Board>
23
67
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-boards
24
68
  def boards(username = "me", options = {})
25
69
  username, options = extract_member_args(username, options)
26
70
  get member_path(username, "boards"), options
27
71
  end
28
72
 
29
- # Retrieve a member's cards
30
- #
73
+ # @overload cards(username = "me", options = {})
74
+ # Retrieve a member's cards
75
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
76
+ # @param options [Hash] the options to fetch the cards with
77
+ # @return [Tacokit::Collection<Card>] the cards collection
78
+ # @example fetch the cards for the member named 'tacokit'
79
+ # Tacokit.cards("tacokit") #=> Tacokit::Collection<Card>
80
+ # @overload cards(options = {})
81
+ # Retrieve current member's cards
82
+ # @param options [Hash] the options to fetch the cards with
83
+ # @return [Tacokit::Collection<Card>] the cards collection
84
+ # @example fetch the current member's boards
85
+ # Tacokit.cards #=> Tacokit::Collection<Card>
86
+ # @example fetch the current member's closed cards only
87
+ # Tacokit.cards(filter: "closed") #=> Tacokit::Collection<Card>
31
88
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-cards
32
89
  def cards(username = "me", options = {})
33
90
  username, options = extract_member_args(username, options)
34
91
  get member_path(username, "cards"), options
35
92
  end
36
93
 
37
- # Retrieve a member's notifications
38
- #
94
+ # @overload notifications(username = "me", options = {})
95
+ # Retrieve a member's notifications
96
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
97
+ # @param options [Hash] the options to fetch the notifications with
98
+ # @return [Tacokit::Collection<Notification>] the notifications collection
99
+ # @example fetch the notifications for the member named 'tacokit'
100
+ # Tacokit.notifications("tacokit") #=> Tacokit::Collection<Notification>
101
+ # @overload notifications(options = {})
102
+ # Retrieve current member's notifications
103
+ # @param options [Hash] the options to fetch the notifications with
104
+ # @return [Tacokit::Collection<Notification>] the notifications collection
105
+ # @example fetch the current member's boards
106
+ # Tacokit.notifications #=> Tacokit::Collection<Notification>
107
+ # @example fetch the current member's closed notifications only
108
+ # Tacokit.notifications(filter: "closed") #=> Tacokit::Collection<Notification>
39
109
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-notifications
40
110
  def notifications(username = "me", options = {})
41
111
  username, options = extract_member_args(username, options)
42
112
  paginated_get member_path(username, "notifications"), options
43
113
  end
44
114
 
45
- # Retrieve a member's organizations
46
- #
115
+ # @overload organizations(username = "me", options = {})
116
+ # Retrieve a member's organizations
117
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
118
+ # @param options [Hash] the options to fetch the organizations with
119
+ # @return [Tacokit::Collection<Organization>] the organizations collection
120
+ # @example fetch the current member's boards
121
+ # Tacokit.organizations #=> Tacokit::Collection<Organization>
122
+ # @example fetch the current member's closed organizations only
123
+ # Tacokit.organizations(filter: "closed") #=> Tacokit::Collection<Organization>
124
+ # @overload organizations(options = {})
125
+ # Retrieve current member's organizations
126
+ # @param options [Hash] the options to fetch the organizations with
127
+ # @return [Tacokit::Collection<Organization>] the organizations collection
128
+ # @example fetch the organizations for the member named 'tacokit'
129
+ # Tacokit.organizations("tacokit") #=> Tacokit::Collection<Organization>
47
130
  # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-organizations
48
131
  def organizations(username = "me", options = {})
49
132
  username, options = extract_member_args(username, options)
50
133
  get member_path(username, "organizations"), options
51
134
  end
52
135
 
53
- # Retrieve a member's tokens
54
- #
55
- # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-tokens
136
+ # @overload tokens(username = "me", options = {})
137
+ # Retrieve a member's tokens
138
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
139
+ # @param options [Hash] the options to fetch the tokens with
140
+ # @return [Tacokit::Collection<Token>] the tokens collection
141
+ # @example fetch the current member's boards
142
+ # Tacokit.tokens #=> Tacokit::Collection<Token>
143
+ # @example fetch the current member's closed tokens only
144
+ # Tacokit.tokens(filter: "closed") #=> Tacokit::Collection<Token>
145
+ # @overload tokens(options = {})
146
+ # Retrieve current member's tokens
147
+ # @param options [Hash] the options to fetch the tokens with
148
+ # @return [Tacokit::Collection<Token>] the tokens collection
149
+ # @example fetch the tokens for the member named 'tacokit'
150
+ # Tacokit.tokens("tacokit") #=> Tacokit::Collection<Token>
151
+ # @see https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-organizations
56
152
  def tokens(username = "me", options = {})
57
153
  username, options = extract_member_args(username, options)
58
154
  get member_path(username, "tokens"), options
59
155
  end
60
156
 
61
157
  # Update a member
62
- #
158
+ # @param username [String, Tacokit::Resource<Member>] the username or member resource
159
+ # @param options [Hash] the attributes to update on the list
160
+ # @example update current member's name
161
+ # Tacokit.update_member(name: "Moonriver") #=> Tacokit::Resource<Member>
63
162
  # @see https://developers.trello.com/advanced-reference/member#put-1-members-idmember-or-username
64
- def update_member(username, options = {})
163
+ def update_member(username = "me", options = {})
164
+ username, options = extract_member_args(username, options)
65
165
  put member_path(username), options
66
166
  end
67
167
 
68
- # PUT /1/members/[idMember or username]/[field]
69
- # avatarSource
70
- # fullName
71
- # initials
72
- # username
73
- # boardBackgrounds/[idBoardBackground]
74
- # boardStars/[idBoardStar]
75
- # boardStars/[idBoardStar]/idBoard
76
- # boardStars/[idBoardStar]/pos
77
- # customBoardBackgrounds/[idBoardBackground]
78
- # prefs/colorBlind
79
- # prefs/minutesBetweenSummaries
80
- # savedSearches/[idSavedSearch]
81
- # savedSearches/[idSavedSearch]/name
82
- # savedSearches/[idSavedSearch]/pos
83
- # savedSearches/[idSavedSearch]/query
84
-
85
- # DELETE /1/members/[idMember or username]/[resource]/[resource_id]
86
- # boardBackgrounds/[idBoardBackground]
87
- # boardStars/[idBoardStar]
88
- # customBoardBackgrounds/[idBoardBackground]
89
- # customStickers/[idCustomSticker]
90
- # savedSearches/[idSavedSearch]
91
-
92
168
  private
93
169
 
94
170
  def member_resource(username, resource, *paths)