tacokit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +86 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +16 -25
  5. data/Guardfile +1 -1
  6. data/README.md +61 -17
  7. data/Rakefile +10 -5
  8. data/lib/tacokit/authorization.rb +14 -13
  9. data/lib/tacokit/client/actions.rb +68 -28
  10. data/lib/tacokit/client/boards.rb +92 -85
  11. data/lib/tacokit/client/cards.rb +285 -92
  12. data/lib/tacokit/client/checklists.rb +48 -28
  13. data/lib/tacokit/client/labels.rb +14 -16
  14. data/lib/tacokit/client/lists.rb +52 -28
  15. data/lib/tacokit/client/members.rb +56 -46
  16. data/lib/tacokit/client/notifications.rb +13 -27
  17. data/lib/tacokit/client/organizations.rb +0 -6
  18. data/lib/tacokit/client/searches.rb +0 -1
  19. data/lib/tacokit/client/tokens.rb +0 -6
  20. data/lib/tacokit/client/types.rb +0 -1
  21. data/lib/tacokit/client/webhooks.rb +3 -8
  22. data/lib/tacokit/client.rb +48 -75
  23. data/lib/tacokit/collection.rb +49 -0
  24. data/lib/tacokit/configuration.rb +4 -6
  25. data/lib/tacokit/error.rb +0 -2
  26. data/lib/tacokit/middleware/boom.rb +6 -7
  27. data/lib/tacokit/middleware.rb +2 -10
  28. data/lib/tacokit/resource.rb +84 -57
  29. data/lib/tacokit/response.rb +3 -3
  30. data/lib/tacokit/transform.rb +35 -13
  31. data/lib/tacokit/utils.rb +40 -8
  32. data/lib/tacokit/version.rb +1 -1
  33. data/lib/tacokit.rb +0 -2
  34. data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +1 -0
  35. data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +1 -0
  36. data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +1 -0
  37. data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +1 -0
  38. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -1
  39. data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +1 -0
  40. data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +1 -0
  41. data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +1 -0
  42. data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +1 -0
  43. data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +1 -0
  44. data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +1 -0
  45. data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +1 -0
  46. data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +1 -0
  47. data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +1 -0
  48. data/spec/cassettes/Tacokit_Client_Boards/_member_board_stars/returns_board_stars.json +1 -0
  49. data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +1 -0
  50. data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +1 -0
  51. data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +1 -0
  52. data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +1 -0
  53. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +1 -0
  54. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +1 -0
  55. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +1 -0
  56. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachment.json +1 -0
  57. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +1 -0
  58. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +1 -0
  59. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -1
  60. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -1
  61. data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +1 -0
  62. data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +1 -0
  63. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -1
  64. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -1
  65. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -1
  66. data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +1 -0
  67. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +1 -0
  68. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +1 -0
  69. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -1
  70. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -1
  71. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -1
  72. data/spec/cassettes/Tacokit_Client_Cards/_card_stickers/returns_.json +1 -0
  73. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +1 -0
  74. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +1 -0
  75. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -1
  76. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -1
  77. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -1
  78. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -1
  79. data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -1
  80. data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +1 -0
  81. data/spec/cassettes/Tacokit_Client_Cards/_list/returns_list.json +1 -0
  82. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +1 -0
  83. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +1 -0
  84. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +1 -0
  85. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +1 -0
  86. data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +1 -0
  87. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_a_checklist_item.json +1 -0
  88. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +1 -0
  89. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +1 -0
  90. data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +1 -0
  91. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -1
  92. data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +1 -0
  93. data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +1 -0
  94. data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +1 -0
  95. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +1 -0
  96. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +1 -0
  97. data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +1 -0
  98. data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +1 -0
  99. data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +1 -0
  100. data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +1 -0
  101. data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +1 -0
  102. data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +1 -0
  103. data/spec/cassettes/Tacokit_Client_Members/_board_stars/returns_member_board_stars.json +1 -0
  104. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +1 -0
  105. data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +1 -0
  106. data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +1 -0
  107. data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +1 -0
  108. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_organizations.json +1 -0
  109. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +1 -0
  110. data/spec/spec_helper.rb +39 -29
  111. data/spec/tacokit/authorization_spec.rb +11 -11
  112. data/spec/tacokit/client/actions_spec.rb +56 -19
  113. data/spec/tacokit/client/boards_spec.rb +81 -78
  114. data/spec/tacokit/client/cards_spec.rb +322 -68
  115. data/spec/tacokit/client/checklists_spec.rb +29 -27
  116. data/spec/tacokit/client/labels_spec.rb +8 -16
  117. data/spec/tacokit/client/lists_spec.rb +74 -27
  118. data/spec/tacokit/client/members_spec.rb +55 -41
  119. data/spec/tacokit/client/notifications_spec.rb +3 -31
  120. data/spec/tacokit/client/organizations_spec.rb +6 -27
  121. data/spec/tacokit/client/searches_spec.rb +1 -3
  122. data/spec/tacokit/client/tokens_spec.rb +2 -18
  123. data/spec/tacokit/client/types_spec.rb +2 -3
  124. data/spec/tacokit/client/webhooks_spec.rb +6 -14
  125. data/spec/tacokit/client_spec.rb +3 -3
  126. data/spec/tacokit/configuration_spec.rb +30 -31
  127. data/spec/tacokit/middleware/boom_spec.rb +6 -7
  128. data/spec/tacokit/resource_spec.rb +142 -17
  129. data/spec/tacokit/transform_spec.rb +37 -35
  130. data/spec/tacokit_spec.rb +3 -5
  131. data/tacokit.gemspec +6 -6
  132. metadata +132 -15
  133. data/config.ru +0 -7
  134. data/lib/tacokit/middleware/debug.rb +0 -22
  135. data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +0 -1
  136. data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +0 -1
@@ -1,55 +1,75 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Checklists
4
-
5
- # GET /1/checklists/[idChecklist]
4
+ # Retrieve a checklist
5
+ #
6
+ # @see https://trello.com/docs/api/checklist/index.html#get-1-checklists-idchecklist
6
7
  def checklist(checklist_id, options = nil)
7
8
  get checklist_path(checklist_id), options
8
9
  end
9
10
 
10
- # GET /1/checklists/[idChecklist]/[field]
11
- def checklist_field(checklist_id, field)
12
- get checklist_path(checklist_id, camp(field))
11
+ # Retrieve the checklist's board
12
+ #
13
+ # @see https://trello.com/docs/api/checklist/index.html#get-1-checklists-idchecklist-board
14
+ def checklist_board(checklist_id, options = {})
15
+ checklist_resource "board", options
13
16
  end
14
17
 
15
- # GET /1/checklists/[idChecklist]/[resource]
16
- # board
17
- # board/[field]
18
- # checklists
19
- # checklists/[filter]
20
- # checkItems
21
- # checkItems/[idCheckItem]
22
- def checklist_resource(checklist_id, resource, *paths)
23
- paths, options = extract_options(camp(resource), *paths)
24
- get checklist_path(checklist_id, *paths), options
18
+ # Retrieve a checklist's card
19
+ #
20
+ # @see https://trello.com/docs/api/checklist/index.html#get-1-checklists-idchecklist-cards
21
+ def checklist_card(checklist_id, options = {})
22
+ checklist_resource "card", options
25
23
  end
26
24
 
27
- # PUT /1/checklists/[idChecklist]
25
+ # Retrieve a checklist's check items
26
+ #
27
+ # @see https://trello.com/docs/api/checklist/index.html#get-1-checklists-idchecklist-checkitems
28
+ def check_items(checklist_id, options = {})
29
+ checklist_resource checklist_id, "check_items", options
30
+ end
31
+ alias_method :checklist_check_items, :check_items
32
+
33
+ # Updates a checklist
34
+ #
35
+ # @see https://trello.com/docs/api/checklist/index.html#put-1-checklists-idchecklist
28
36
  def update_checklist(checklist_id, options = {})
29
37
  put checklist_path(checklist_id), options
30
38
  end
39
+ alias_method :checklist_update, :update_checklist
31
40
 
32
- # PUT /1/checklists/[idChecklist]/[field]
33
- # idCard
34
- # name
35
- # pos
36
-
37
- # POST /1/checklists
41
+ # Create a checklist
42
+ #
43
+ # @see https://trello.com/docs/api/checklist/index.html#post-1-checklists
38
44
  def create_checklist(card_id, name, options = {})
39
- options.update \
40
- card_id: card_id,
41
- name: name
45
+ options.update card_id: card_id, name: name
42
46
  post checklist_path, options
43
47
  end
48
+ alias_method :checklist_create, :create_checklist
44
49
 
45
- # POST /1/checklists/[idChecklist]/checkItems
50
+ # Add a checklist item to a checklist
51
+ #
52
+ # @see https://trello.com/docs/api/checklist/index.html#post-1-checklists-idchecklist-checkitems
53
+ def add_checklist_check_item(checklist_id, name, options = {})
54
+ post checklist_path(checklist_id, "checkItems"), options.merge(name: name)
55
+ end
56
+ alias_method :checklist_check_item_create, :add_checklist_check_item
57
+ alias_method :add_checklist_item, :add_checklist_check_item
46
58
 
47
- # DELETE /1/checklists/[idChecklist]
59
+ # Delete a checklist
60
+ #
61
+ # @see https://trello.com/docs/api/checklist/index.html#delete-1-checklists-idchecklist
48
62
  def delete_checklist(checklist_id)
49
63
  delete checklist_path(checklist_id)
50
64
  end
65
+ alias_method :checklist_delete, :delete_checklist
66
+
67
+ private
51
68
 
52
- # DELETE /1/checklists/[idChecklist]/checkItems/[idCheckItem]
69
+ def checklist_resource(checklist_id, resource, *paths)
70
+ paths, options = extract_options(camp(resource), *paths)
71
+ get checklist_path(checklist_id, *paths), options
72
+ end
53
73
 
54
74
  def checklist_path(*paths)
55
75
  path_join("checklists", *paths)
@@ -1,29 +1,23 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Labels
4
-
5
- # GET /1/labels/[idLabel]
4
+ # Retrieve a label
5
+ #
6
+ # @see https://trello.com/docs/api/label/index.html#get-1-labels-idlabel
6
7
  def label(label_id, options = nil)
7
8
  get label_path(label_id), options
8
9
  end
9
10
 
10
- # GET /1/labels/[idLabel]/[resource]
11
- # board
12
- # board/[field]
13
- def label_resource(label_id, resource, *paths)
14
- paths, options = extract_options(camp(resource), *paths)
15
- get label_path(label_id, *paths), options
16
- end
17
-
18
- # PUT /1/labels/[idLabel]
11
+ # Update a label
12
+ #
13
+ # @see https://trello.com/docs/api/label/index.html#put-1-labels-idlabel
19
14
  def update_label(label_id, options = {})
20
15
  put label_path(label_id), options
21
16
  end
22
17
 
23
- # PUT /1/labels/[idLabel]/color
24
- # PUT /1/labels/[idLabel]/name
25
-
26
- # POST /1/labels
18
+ # Create a label
19
+ #
20
+ # @see https://trello.com/docs/api/label/index.html#post-1-labels
27
21
  def create_label(board_id, name, color)
28
22
  post label_path,
29
23
  board_id: board_id,
@@ -31,11 +25,15 @@ module Tacokit
31
25
  color: color
32
26
  end
33
27
 
34
- # DELETE /1/labels/[idLabel]
28
+ # Delete a label
29
+ #
30
+ # @see https://trello.com/docs/api/label/index.html#delete-1-labels-idlabel
35
31
  def delete_label(label_id)
36
32
  delete label_path(label_id)
37
33
  end
38
34
 
35
+ private
36
+
39
37
  def label_path(*paths)
40
38
  path_join "labels", *paths
41
39
  end
@@ -1,54 +1,78 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Lists
4
-
5
- # GET /1/lists/[idList]
4
+ # Retrieve a list by id
5
+ #
6
+ # @see https://trello.com/docs/api/label/index.html#get-1-labels-idlabel-board
6
7
  def list(list_id, options = nil)
7
8
  get list_path(list_id), options
8
9
  end
9
10
 
10
- # GET /1/lists/[idList]/[field]
11
- def list_field(list_id, field, options = nil)
12
- get list_path(list_id, camp(field)), options
11
+ # Retrive a list's actions
12
+ #
13
+ # @see https://trello.com/docs/api/list/index.html#get-1-lists-idlist-actions
14
+ def list_actions(list_id, options = {})
15
+ paginated_list_resource list_id, "actions", options
13
16
  end
14
17
 
15
- # GET /1/lists/[idList]/[resource]
16
- # actions
17
- # board
18
- # board/[field]
19
- # lists
20
- # lists/[filter]
21
- def list_resource(list_id, resource, *paths)
22
- paths, options = extract_options(camp(resource), *paths)
23
- get list_path(list_id, *paths), options
18
+ # Retrive a list's board
19
+ #
20
+ # @see https://trello.com/docs/api/list/index.html#get-1-lists-idlist-board
21
+ def list_board(list_id, options = {})
22
+ list_resource list_id, "board", options
23
+ end
24
+
25
+ # Retrive a list's cards
26
+ #
27
+ # @see https://trello.com/docs/api/list/index.html#get-1-lists-idlist-cards
28
+ def list_cards(list_id, options = {})
29
+ paginated_list_resource list_id, "cards", options
24
30
  end
25
31
 
26
- # PUT /1/lists/[idList]
32
+ # Update a list's attributes
33
+ #
34
+ # @see https://trello.com/docs/api/list/index.html#put-1-lists-idlis
27
35
  def update_list(list_id, options = {})
28
36
  put list_path(list_id), options
29
37
  end
30
38
 
31
- # PUT /1/lists/[idList]/[field]
32
- # closed
33
- # idBoard
34
- # name
35
- # pos
36
- # subscribed
37
-
38
- # POST /1/lists
39
+ # Create a new list
40
+ #
41
+ # @see https://trello.com/docs/api/list/index.html#post-1-lists
39
42
  def create_list(board_id, name, options = {})
40
43
  post list_path, options.merge(name: name, board_id: board_id)
41
44
  end
42
45
 
43
- # POST /1/lists/[idList]/[resource]
44
- # archiveAllCards
45
- # cards
46
- # moveAllCards
46
+ # Archive all cards in a list
47
+ #
48
+ # @see https://trello.com/docs/api/list/index.html#post-1-lists-idlist-moveallcards
49
+ def archive_list_cards(list_id)
50
+ post list_path(list_id, camp("archive_all_cards"))
51
+ end
52
+
53
+ # Move cards from one list to another
54
+ #
55
+ # @see https://trello.com/docs/api/list/index.html#post-1-lists-idlist-moveallcards
56
+ def move_list_cards(list_id, destination_list_id, board_id)
57
+ post list_path(list_id, camp("move_all_cards")),
58
+ list_id: destination_list_id, board_id: board_id
59
+ end
60
+
61
+ private
62
+
63
+ def list_resource(list_id, resource, *paths)
64
+ paths, options = extract_options(camp(resource), *paths)
65
+ get list_path(list_id, *paths), options
66
+ end
67
+
68
+ def paginated_list_resource(list_id, resource, *paths)
69
+ paths, options = extract_options(camp(resource), *paths)
70
+ paginated_get list_path(list_id, *paths), options
71
+ end
47
72
 
48
73
  def list_path(*paths)
49
74
  path_join("lists", *paths)
50
75
  end
51
-
52
76
  end
53
77
  end
54
78
  end
@@ -1,60 +1,63 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Members
4
-
5
- # GET /1/members/[idMember or username]
6
- def member(username = 'me', options = nil)
4
+ # Retrieve a Trello member
5
+ #
6
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username
7
+ def member(username = "me", options = nil)
7
8
  get member_path(username), options
8
9
  end
9
10
 
10
- # GET /1/members/[idMember or username]/[field]
11
- def member_field(username, field, options = nil)
12
- get member_path(username, camp(field)), options
11
+ # Retrieve a member's actions
12
+ #
13
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-actions
14
+ def actions(username = "me", options = {})
15
+ if username.is_a?(Hash)
16
+ username = "me"
17
+ options = username
18
+ end
19
+ paginated_get member_path(username, "actions"), options
13
20
  end
21
+ alias_method :member_actions, :actions
14
22
 
15
- # GET /1/members/[idMember or username]/[resource]
16
- # actions
17
- # boardBackgrounds
18
- # boardBackgrounds/[idBoardBackground]
19
- # boardStars
20
- # boardStars/[idBoardStar]
21
- # boards/[filter]
22
- # boardsInvited
23
- # boardsInvited/[field]
24
- # cards
25
- # cards/[filter]
26
- # customBoardBackgrounds
27
- # customBoardBackgrounds/[idBoardBackground]
28
- # customEmoji
29
- # customEmoji/[idCustomEmoji]
30
- # customStickers
31
- # customStickers/[idCustomSticker]
32
- # deltas
33
- # notifications
34
- # notifications/[filter]
35
- # organizations
36
- # organizations/[filter]
37
- # organizationsInvited
38
- # organizationsInvited/[field]
39
- # savedSearches
40
- # savedSearches/[idSavedSearch]
41
- # tokens
42
- def member_resource(username, resource, *paths)
43
- paths, options = extract_options(camp(resource), *paths)
44
- get member_path(username, *paths), options
23
+ # Retrieve a member's boards
24
+ #
25
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-boards
26
+ def boards(username = "me", options = {})
27
+ get member_path(username, "boards"), options
28
+ end
29
+
30
+ # Retrieve a member's cards
31
+ #
32
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-cards
33
+ def cards(username = "me", options = {})
34
+ get member_path(username, "cards"), options
45
35
  end
46
36
 
47
- # POST /1/members/[idMember or username]/[resource]
48
- # avatar
49
- # boardBackgrounds
50
- # boardStars
51
- # customBoardBackgrounds
52
- # customEmoji
53
- # customStickers
54
- # oneTimeMessagesDismissed
55
- # savedSearches
37
+ # Retrieve a member's notifications
38
+ #
39
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-notifications
40
+ def notifications(username = "me", options = {})
41
+ paginated_get member_path(username, "notifications"), options
42
+ end
43
+
44
+ # Retrieve a member's organizations
45
+ #
46
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-organizations
47
+ def organizations(username = "me", options = {})
48
+ get member_path(username, "organizations"), options
49
+ end
50
+
51
+ # Retrieve a member's tokens
52
+ #
53
+ # @see https://trello.com/docs/api/member/index.html#get-1-members-idmember-or-username-tokens
54
+ def tokens(username = "me", options = {})
55
+ get member_path(username, "tokens"), options
56
+ end
56
57
 
57
- # PUT /1/members/[idMember or username]
58
+ # Update a member
59
+ #
60
+ # @see https://trello.com/docs/api/member/index.html#put-1-members-idmember-or-username
58
61
  def update_member(username, options = {})
59
62
  put member_path(username), options
60
63
  end
@@ -83,6 +86,13 @@ module Tacokit
83
86
  # customStickers/[idCustomSticker]
84
87
  # savedSearches/[idSavedSearch]
85
88
 
89
+ private
90
+
91
+ def member_resource(username, resource, *paths)
92
+ paths, options = extract_options(camp(resource), *paths)
93
+ get(member_path(username, *paths), options)
94
+ end
95
+
86
96
  def member_path(*paths)
87
97
  path_join "members", *paths
88
98
  end
@@ -1,37 +1,16 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Notifications
4
-
5
- # GET /1/notifications/[idNotification]
4
+ # Retrieve a notification
5
+ #
6
+ # @see https://trello.com/docs/api/notification/index.html#get-1-notifications-idnotification
6
7
  def notification(notification_id, options = nil)
7
8
  get notification_path(notification_id), options
8
9
  end
9
10
 
10
- # GET /1/notifications/[idNotification]/[field]
11
- def notification_field(notification_id, field)
12
- get notification_path(notification_id, camp(field))
13
- end
14
-
15
- # GET /1/notifications/[idNotification]/[resource]
16
- # board
17
- # board/[field]
18
- # notification
19
- # notification/[field]
20
- # entities
21
- # list
22
- # list/[field]
23
- # member
24
- # member/[field]
25
- # memberCreator
26
- # memberCreator/[field]
27
- # organization
28
- # organization/[field]
29
- def notification_resource(notification_id, resource, *paths)
30
- paths, options = extract_options(camp(resource), *paths)
31
- get notification_path(notification_id, *paths), options
32
- end
33
-
34
- # PUT /1/notifications/[idNotification]
11
+ # Update read/unread status of notification
12
+ #
13
+ # @see https://trello.com/docs/api/notification/index.html#put-1-notifications-idnotification
35
14
  def update_notification(notification_id, options = {})
36
15
  put notification_path(notification_id), options
37
16
  end
@@ -40,6 +19,13 @@ module Tacokit
40
19
 
41
20
  # POST /1/notifications/all/read
42
21
 
22
+ private
23
+
24
+ def notification_resource(notification_id, resource, *paths)
25
+ paths, options = extract_options(camp(resource), *paths)
26
+ get notification_path(notification_id, *paths), options
27
+ end
28
+
43
29
  def notification_path(*paths)
44
30
  path_join "notifications", *paths
45
31
  end
@@ -1,17 +1,11 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Organizations
4
-
5
4
  # GET /1/organizations/[idOrg or name]
6
5
  def organization(org_id, options = nil)
7
6
  get organization_path(org_id), options
8
7
  end
9
8
 
10
- # GET /1/organizations/[idOrg or name]/[field]
11
- def organization_field(org_id, field, options = nil)
12
- get organization_path(org_id, camp(field)), options
13
- end
14
-
15
9
  # GET /1/organizations/[idOrg or name]/[resource]
16
10
  # actions
17
11
  # boards
@@ -1,7 +1,6 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Searches
4
-
5
4
  # GET /1/search
6
5
  def search(query, options = {})
7
6
  get search_path, options.merge(query: query)
@@ -1,17 +1,11 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Tokens
4
-
5
4
  # GET /1/tokens/[token]
6
5
  def token(token, options = nil)
7
6
  get token_path(token), options
8
7
  end
9
8
 
10
- # GET /1/tokens/[token]/[field]
11
- def token_field(token, field, options = nil)
12
- get token_path(token, camp(field)), options
13
- end
14
-
15
9
  # GET /1/tokens/[token]/[resource]
16
10
  # member
17
11
  # webhooks
@@ -1,7 +1,6 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Types
4
-
5
4
  # GET /1/types/[id]
6
5
  def type(model_id)
7
6
  get path_join "types", model_id
@@ -1,17 +1,11 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Webhooks
4
-
5
4
  # GET /1/webhooks/[idWebhook]
6
5
  def webhook(webhook_id)
7
6
  get webhook_path(webhook_id)
8
7
  end
9
8
 
10
- # GET /1/webhooks/[idWebhook]/[field]
11
- def webhook_field(webhook_id, field, options = nil)
12
- get webhook_path(webhook_id, camp(field)), options
13
- end
14
-
15
9
  # PUT /1/webhooks/[idWebhook]
16
10
  def update_webhook(webhook_id, options = {})
17
11
  put webhook_path(webhook_id), options
@@ -25,9 +19,10 @@ module Tacokit
25
19
 
26
20
  # POST /1/webhooks
27
21
  def create_webhook(token, model_id, callback_url, options = {})
28
- post webhook_path, options.merge(
22
+ options.update \
29
23
  model_id: model_id,
30
- callback_url: callback_url)
24
+ callback_url: callback_url
25
+ post webhook_path, options
31
26
  end
32
27
 
33
28
  # DELETE /1/webhooks/[idWebhook]