tacokit 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +86 -0
- data/.travis.yml +6 -0
- data/Gemfile +16 -25
- data/Guardfile +1 -1
- data/README.md +61 -17
- data/Rakefile +10 -5
- data/lib/tacokit/authorization.rb +14 -13
- data/lib/tacokit/client/actions.rb +68 -28
- data/lib/tacokit/client/boards.rb +92 -85
- data/lib/tacokit/client/cards.rb +285 -92
- data/lib/tacokit/client/checklists.rb +48 -28
- data/lib/tacokit/client/labels.rb +14 -16
- data/lib/tacokit/client/lists.rb +52 -28
- data/lib/tacokit/client/members.rb +56 -46
- data/lib/tacokit/client/notifications.rb +13 -27
- data/lib/tacokit/client/organizations.rb +0 -6
- data/lib/tacokit/client/searches.rb +0 -1
- data/lib/tacokit/client/tokens.rb +0 -6
- data/lib/tacokit/client/types.rb +0 -1
- data/lib/tacokit/client/webhooks.rb +3 -8
- data/lib/tacokit/client.rb +48 -75
- data/lib/tacokit/collection.rb +49 -0
- data/lib/tacokit/configuration.rb +4 -6
- data/lib/tacokit/error.rb +0 -2
- data/lib/tacokit/middleware/boom.rb +6 -7
- data/lib/tacokit/middleware.rb +2 -10
- data/lib/tacokit/resource.rb +84 -57
- data/lib/tacokit/response.rb +3 -3
- data/lib/tacokit/transform.rb +35 -13
- data/lib/tacokit/utils.rb +40 -8
- data/lib/tacokit/version.rb +1 -1
- data/lib/tacokit.rb +0 -2
- data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_member_board_stars/returns_board_stars.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_stickers/returns_.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_list/returns_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_a_checklist_item.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -1
- data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_board_stars/returns_member_board_stars.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_organizations.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +1 -0
- data/spec/spec_helper.rb +39 -29
- data/spec/tacokit/authorization_spec.rb +11 -11
- data/spec/tacokit/client/actions_spec.rb +56 -19
- data/spec/tacokit/client/boards_spec.rb +81 -78
- data/spec/tacokit/client/cards_spec.rb +322 -68
- data/spec/tacokit/client/checklists_spec.rb +29 -27
- data/spec/tacokit/client/labels_spec.rb +8 -16
- data/spec/tacokit/client/lists_spec.rb +74 -27
- data/spec/tacokit/client/members_spec.rb +55 -41
- data/spec/tacokit/client/notifications_spec.rb +3 -31
- data/spec/tacokit/client/organizations_spec.rb +6 -27
- data/spec/tacokit/client/searches_spec.rb +1 -3
- data/spec/tacokit/client/tokens_spec.rb +2 -18
- data/spec/tacokit/client/types_spec.rb +2 -3
- data/spec/tacokit/client/webhooks_spec.rb +6 -14
- data/spec/tacokit/client_spec.rb +3 -3
- data/spec/tacokit/configuration_spec.rb +30 -31
- data/spec/tacokit/middleware/boom_spec.rb +6 -7
- data/spec/tacokit/resource_spec.rb +142 -17
- data/spec/tacokit/transform_spec.rb +37 -35
- data/spec/tacokit_spec.rb +3 -5
- data/tacokit.gemspec +6 -6
- metadata +132 -15
- data/config.ru +0 -7
- data/lib/tacokit/middleware/debug.rb +0 -22
- data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +0 -1
@@ -1,83 +1,87 @@
|
|
1
1
|
module Tacokit
|
2
2
|
class Client
|
3
3
|
module Boards
|
4
|
-
|
5
|
-
#
|
4
|
+
# Retrieve a board
|
5
|
+
#
|
6
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id
|
6
7
|
def board(board_id, options = nil)
|
7
8
|
get board_path(board_id), options
|
8
9
|
end
|
9
10
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
11
|
+
# Retrieve a board's actions
|
12
|
+
#
|
13
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-actions
|
14
|
+
def board_actions(board_id, options = {})
|
15
|
+
paginated_board_resource(board_id, "actions", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Retrieve a board's stars
|
19
|
+
#
|
20
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-boardstars
|
21
|
+
def board_stars(board_id, options = {})
|
22
|
+
board_resource(board_id, "board_stars", options)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve a board's cards
|
26
|
+
#
|
27
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-cards
|
28
|
+
def board_cards(board_id, options = {})
|
29
|
+
paginated_board_resource(board_id, "cards", options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieve a board's checklists
|
33
|
+
#
|
34
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-checklists
|
35
|
+
def board_checklists(board_id, options = {})
|
36
|
+
board_resource(board_id, "checklists", options)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Retrieve a board's labels
|
40
|
+
#
|
41
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-labels
|
42
|
+
def board_labels(board_id, options = {})
|
43
|
+
board_resource(board_id, "labels", options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieve a board's lists
|
47
|
+
#
|
48
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-lists
|
49
|
+
def lists(board_id, options = {})
|
50
|
+
board_resource(board_id, "lists", options)
|
51
|
+
end
|
52
|
+
alias_method :board_lists, :lists
|
53
|
+
|
54
|
+
# Retrieve a board's members
|
55
|
+
#
|
56
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-members
|
57
|
+
def board_members(board_id, options = {})
|
58
|
+
board_resource(board_id, "members", options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Retrieve your preferences for a board
|
62
|
+
#
|
63
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-myprefs
|
64
|
+
def board_preferences(board_id, options = {})
|
65
|
+
board_resource(board_id, "my_prefs", options)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Retrieve a board's organization
|
69
|
+
#
|
70
|
+
# @see https://trello.com/docs/api/board/index.html#get-1-boards-board-id-organization
|
71
|
+
def board_organization(board_id, options = {})
|
72
|
+
board_resource(board_id, "organization", options)
|
40
73
|
end
|
41
74
|
|
42
|
-
#
|
75
|
+
# Update board attributes
|
76
|
+
#
|
77
|
+
# @see https://trello.com/docs/api/board/index.html#put-1-boards-board-id
|
43
78
|
def update_board(board_id, options = {})
|
44
79
|
put board_path(board_id), options
|
45
80
|
end
|
46
81
|
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# idOrganization
|
51
|
-
# labelNames/blue
|
52
|
-
# labelNames/green
|
53
|
-
# labelNames/orange
|
54
|
-
# labelNames/purple
|
55
|
-
# labelNames/red
|
56
|
-
# labelNames/yellow
|
57
|
-
# myPrefs/emailPosition
|
58
|
-
# myPrefs/idEmailList
|
59
|
-
# myPrefs/showListGuide
|
60
|
-
# myPrefs/showSidebar
|
61
|
-
# myPrefs/showSidebarActivity
|
62
|
-
# myPrefs/showSidebarBoardActions
|
63
|
-
# myPrefs/showSidebarMembers
|
64
|
-
# name
|
65
|
-
# prefs/background
|
66
|
-
# prefs/calendarFeedEnabled
|
67
|
-
# prefs/cardAging
|
68
|
-
# prefs/cardCovers
|
69
|
-
# prefs/comments
|
70
|
-
# prefs/invitations
|
71
|
-
# prefs/permissionLevel
|
72
|
-
# prefs/selfJoin
|
73
|
-
# prefs/voting
|
74
|
-
# subscribed
|
75
|
-
def update_board_field(board_id, *paths)
|
76
|
-
value = paths.pop
|
77
|
-
put board_path(board_id, camel_join(*paths)), value: value
|
78
|
-
end
|
79
|
-
|
80
|
-
# PUT /1/boards/[board_id]/members
|
82
|
+
# Add a member to a board
|
83
|
+
#
|
84
|
+
# @see https://trello.com/docs/api/board/index.html#put-1-boards-board-id-members-idmember
|
81
85
|
def add_board_member(board_id, email, full_name, options = {})
|
82
86
|
options.update \
|
83
87
|
email: email,
|
@@ -85,11 +89,11 @@ module Tacokit
|
|
85
89
|
put board_path(board_id, "members"), options
|
86
90
|
end
|
87
91
|
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
def
|
92
|
-
|
92
|
+
# Update a board member's type
|
93
|
+
#
|
94
|
+
# @see https://trello.com/docs/api/board/index.html#put-1-boards-board-id-members-idmember
|
95
|
+
def update_board_member(board_id, member_id, type)
|
96
|
+
update_board_resource(board_id, "members", member_id, type: type)
|
93
97
|
end
|
94
98
|
|
95
99
|
# POST /1/boards
|
@@ -97,28 +101,31 @@ module Tacokit
|
|
97
101
|
post board_path, options.merge(name: name)
|
98
102
|
end
|
99
103
|
|
100
|
-
|
101
|
-
|
102
|
-
# checklists
|
103
|
-
# emailKey/generate
|
104
|
-
# labels
|
105
|
-
# lists
|
106
|
-
# markAsViewed
|
107
|
-
# powerUps
|
104
|
+
private
|
105
|
+
|
108
106
|
def create_board_resource(board_id, resource, *paths)
|
109
107
|
paths, options = extract_options(camp(resource), *paths)
|
110
108
|
post board_path(board_id, *paths), options
|
111
109
|
end
|
112
110
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
def update_board_resource(board_id, resource, *paths)
|
112
|
+
paths, options = extract_options(camp(resource), *paths)
|
113
|
+
put board_path(board_id, *paths), options
|
114
|
+
end
|
115
|
+
|
116
|
+
def board_resource(board_id, resource, *paths)
|
117
|
+
paths, options = extract_options(camp(resource), *paths)
|
118
|
+
get board_path(board_id, *paths), options
|
119
|
+
end
|
120
|
+
|
121
|
+
def paginated_board_resource(board_id, resource, *paths)
|
122
|
+
paths, options = extract_options(camp(resource), *paths)
|
123
|
+
paginated_get board_path(board_id, *paths), options
|
124
|
+
end
|
117
125
|
|
118
126
|
def board_path(*paths)
|
119
127
|
path_join("boards", *paths)
|
120
128
|
end
|
121
|
-
|
122
129
|
end
|
123
130
|
end
|
124
131
|
end
|
data/lib/tacokit/client/cards.rb
CHANGED
@@ -1,96 +1,183 @@
|
|
1
1
|
module Tacokit
|
2
2
|
class Client
|
3
|
+
# Methods for the Cards API
|
4
|
+
#
|
5
|
+
# @see https://trello.com/docs/api/card/index.html
|
3
6
|
module Cards
|
4
|
-
|
5
|
-
#
|
7
|
+
# Retrieve a card by id or shortlink
|
8
|
+
#
|
9
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink
|
6
10
|
def card(card_id, options = nil)
|
7
11
|
get card_path(card_id), options
|
8
12
|
end
|
9
13
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
def
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# checklists
|
47
|
-
#
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
14
|
+
# Retrieve card actions
|
15
|
+
#
|
16
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-actions
|
17
|
+
def card_actions(card_id, options = {})
|
18
|
+
paginated_card_resource(card_id, "actions", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve card attachments
|
22
|
+
#
|
23
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-attachments
|
24
|
+
def attachments(card_id, options = {})
|
25
|
+
card_resource(card_id, "attachments", options)
|
26
|
+
end
|
27
|
+
alias_method :card_attachments, :attachments
|
28
|
+
|
29
|
+
# Retrieve a card attachment
|
30
|
+
#
|
31
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-attachments-idattachment
|
32
|
+
def attachment(card_id, attachment_id, options = {})
|
33
|
+
card_resource(card_id, "attachments/#{attachment_id}", options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Retrieve a card board
|
37
|
+
#
|
38
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-board
|
39
|
+
def card_board(card_id, options = {})
|
40
|
+
card_resource(card_id, "board", options)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Retrieve card checklist item states
|
44
|
+
#
|
45
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-board
|
46
|
+
def check_item_states(card_id, options = {})
|
47
|
+
card_resource(card_id, "check_item_states", options)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Retrieve card checklists
|
51
|
+
#
|
52
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-board
|
53
|
+
def checklists(card_id, options = {})
|
54
|
+
card_resource(card_id, "checklists", options)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Retrive a card list
|
58
|
+
#
|
59
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-list
|
60
|
+
def card_list(card_id, options = {})
|
61
|
+
card_resource(card_id, "list", options)
|
55
62
|
end
|
56
63
|
|
57
|
-
#
|
64
|
+
# Retrieve card members
|
65
|
+
#
|
66
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-members
|
67
|
+
def card_members(card_id, options = {})
|
68
|
+
card_resource(card_id, "members", options)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Retrieve members who voted on a card
|
72
|
+
#
|
73
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-membersvoted
|
74
|
+
def card_members_voted(card_id, options = {})
|
75
|
+
card_resource(card_id, "members_voted", options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Retrieve card stickers
|
79
|
+
#
|
80
|
+
# @see https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-stickers
|
81
|
+
def stickers(card_id, options = {})
|
82
|
+
card_resource(card_id, "stickers", options)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Update card attributes
|
86
|
+
#
|
87
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink
|
58
88
|
def update_card(card_id, options = {})
|
59
89
|
put card_path(card_id), options
|
60
90
|
end
|
61
91
|
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
|
81
|
-
|
92
|
+
# Update comment text
|
93
|
+
#
|
94
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-actions-idaction-comments
|
95
|
+
def update_comment(card_id, comment_id, text, options = {})
|
96
|
+
update_card_resource(card_id, "actions", comment_id, "comments", options.merge(text: text))
|
97
|
+
end
|
98
|
+
alias_method :edit_comment, :update_comment
|
99
|
+
|
100
|
+
# Update checklist item text, position or state
|
101
|
+
#
|
102
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-checklist-idchecklistcurrent-checkitem-idcheckitem
|
103
|
+
def update_check_item(card_id, checklist_id, check_item_id, options = {})
|
104
|
+
update_card_resource(card_id, "checklist", checklist_id, "checkItem", check_item_id, options)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Archive a card
|
108
|
+
#
|
109
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-closed
|
110
|
+
def archive_card(card_id)
|
111
|
+
update_card(card_id, closed: true)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Restore an archived card
|
115
|
+
#
|
116
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-closed
|
117
|
+
def restore_card(card_id)
|
118
|
+
update_card(card_id, closed: false)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Move card to another position, board and/or list
|
122
|
+
#
|
123
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-idboard
|
124
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-idlist
|
125
|
+
def move_card(card_id, options)
|
126
|
+
unless options.is_a?(Hash) && ([:board_id, :list_id, :pos].any? { |key| options.key? key })
|
127
|
+
raise ArgumentError, "Required option: :pos, :board_id and/or :list_id"
|
128
|
+
end
|
129
|
+
update_card(card_id, options)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Update card name
|
133
|
+
#
|
134
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-name
|
135
|
+
def update_card_name(card_id, name)
|
136
|
+
put card_path(card_id, "name"), value: name
|
137
|
+
end
|
138
|
+
|
139
|
+
# Subscribe to card
|
140
|
+
#
|
141
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-subscribed
|
142
|
+
def subscribe_to_card(card_id)
|
143
|
+
put card_path(card_id, "subscribed"), value: true
|
144
|
+
end
|
145
|
+
|
146
|
+
# Unubscribe from card
|
147
|
+
#
|
148
|
+
# @see https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-subscribed
|
149
|
+
def unsubscribe_from_card(card_id)
|
150
|
+
put card_path(card_id, "subscribed"), value: false
|
151
|
+
end
|
152
|
+
|
153
|
+
# Update any card resource
|
154
|
+
def update_card_resource(card_id, resource, *paths)
|
155
|
+
paths, options = extract_options(camp(resource), *paths)
|
156
|
+
put card_path(card_id, *paths), options
|
157
|
+
end
|
158
|
+
|
159
|
+
# Create a card
|
160
|
+
#
|
161
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards
|
82
162
|
def create_card(list_id, name = nil, options = {})
|
83
163
|
post card_path, options.merge(name: name, list_id: list_id)
|
84
164
|
end
|
85
165
|
|
86
|
-
#
|
87
|
-
|
166
|
+
# Add a comment to a card
|
167
|
+
#
|
168
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-actions-comments
|
169
|
+
def add_comment(card_id, text, options = {})
|
88
170
|
options.update text: text
|
89
171
|
create_card_resource card_id, "actions", "comments", options
|
90
172
|
end
|
173
|
+
alias_method :create_card_comment, :add_comment
|
174
|
+
|
175
|
+
# Attach a file to a card
|
176
|
+
#
|
177
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-attachments
|
178
|
+
def attach_file(card_id, url, mime_type = nil, options = {})
|
179
|
+
options = mime_type if mime_type.is_a?(Hash)
|
91
180
|
|
92
|
-
# POST cards/[card id or shortlink]/attachments
|
93
|
-
def create_card_attachment(card_id, url, mime_type = nil, options = {})
|
94
181
|
uri = Addressable::URI.parse(url)
|
95
182
|
|
96
183
|
if uri.scheme =~ %r{https?}
|
@@ -100,43 +187,149 @@ module Tacokit
|
|
100
187
|
options.update file: file, mime_type: file.content_type
|
101
188
|
end
|
102
189
|
|
103
|
-
create_card_resource card_id,
|
190
|
+
create_card_resource card_id, "attachments", options
|
191
|
+
end
|
192
|
+
alias_method :create_card_attachment, :attach_file
|
193
|
+
|
194
|
+
# Convert a checklist item to a card
|
195
|
+
#
|
196
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-converttocard
|
197
|
+
def convert_to_card(card_id, checklist_id, check_item_id)
|
198
|
+
create_card_resource(card_id, "checklist", checklist_id, "checkItem", check_item_id, "convertToCard")
|
104
199
|
end
|
105
200
|
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
201
|
+
# Start a new checklist on card
|
202
|
+
#
|
203
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-checklists
|
204
|
+
def add_checklist(card_id, name)
|
205
|
+
create_card_resource(card_id, "checklists", name: name)
|
206
|
+
end
|
207
|
+
alias_method :start_checklist, :add_checklist
|
208
|
+
|
209
|
+
# Copy another checklist to card
|
210
|
+
#
|
211
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-checklists
|
212
|
+
def copy_checklist(card_id, checklist_id)
|
213
|
+
create_card_resource(card_id, "checklists", checklist_source_id: checklist_id)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Add a member to a card
|
217
|
+
#
|
218
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-idmembers
|
219
|
+
def add_member_to_card(card_id, member_id)
|
220
|
+
create_card_resource(card_id, "idMembers", value: member_id)
|
221
|
+
end
|
222
|
+
|
223
|
+
# Add label to card
|
224
|
+
#
|
225
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-labels
|
226
|
+
def add_label(card_id, color, options = {})
|
227
|
+
create_card_resource(card_id, "labels", options.merge(color: color))
|
228
|
+
end
|
229
|
+
|
230
|
+
# Cast vote for card
|
231
|
+
#
|
232
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-membersvoted
|
233
|
+
def vote(card_id, member_id)
|
234
|
+
create_card_resource(card_id, "membersVoted", value: member_id)
|
235
|
+
end
|
236
|
+
alias_method :create_vote, :vote
|
237
|
+
|
238
|
+
# Add sticker to card
|
239
|
+
#
|
240
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-stickers
|
241
|
+
def add_sticker(card_id, image_name, options = {})
|
242
|
+
defaults = { top: 0, left: 0, z_index: 1 }
|
243
|
+
create_card_resource(card_id, "stickers", defaults.merge(options.merge(image: image_name)))
|
244
|
+
end
|
245
|
+
alias_method :create_sticker, :add_sticker
|
246
|
+
|
247
|
+
# Create a card resource
|
248
|
+
#
|
115
249
|
def create_card_resource(card_id, resource, *paths)
|
116
250
|
paths, options = extract_options(camp(resource), *paths)
|
117
251
|
post card_path(card_id, *paths), options
|
118
252
|
end
|
119
253
|
|
120
254
|
# DELETE cards/[card id or shortlink]
|
255
|
+
#
|
256
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink
|
121
257
|
def delete_card(card_id)
|
122
258
|
delete card_path(card_id)
|
123
259
|
end
|
124
260
|
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
#
|
261
|
+
# Remove a comment
|
262
|
+
#
|
263
|
+
# @see https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-labels
|
264
|
+
def remove_comment(card_id, comment_id)
|
265
|
+
delete_card_resource card_id, "actions", comment_id, "comments"
|
266
|
+
end
|
267
|
+
alias_method :delete_comment, :remove_comment
|
268
|
+
|
269
|
+
# Remove an attachment
|
270
|
+
#
|
271
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-attachments-idattachment
|
272
|
+
def remove_attachment(card_id, attachment_id)
|
273
|
+
delete_card_resource card_id, "attachments", attachment_id
|
274
|
+
end
|
275
|
+
alias_method :delete_attachement, :remove_attachment
|
276
|
+
|
277
|
+
# Remove checklist
|
278
|
+
#
|
279
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-checklists-idchecklist
|
280
|
+
def remove_checklist(card_id, checklist_id)
|
281
|
+
delete_card_resource card_id, "checklists", checklist_id
|
282
|
+
end
|
283
|
+
alias_method :delete_checklist, :remove_checklist
|
284
|
+
|
285
|
+
# Remove a member from a card
|
286
|
+
#
|
287
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-idmembers-idmember
|
288
|
+
def remove_card_member(card_id, member_id)
|
289
|
+
delete_card_resource card_id, "idMembers", member_id
|
290
|
+
end
|
291
|
+
alias_method :delete_card_member, :remove_card_member
|
292
|
+
|
293
|
+
# Remove label from card
|
294
|
+
#
|
295
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-labels-color
|
296
|
+
def remove_label(card_id, color)
|
297
|
+
delete_card_resource card_id, "labels", color
|
298
|
+
end
|
299
|
+
alias_method :delete_label, :remove_label
|
300
|
+
|
301
|
+
# Remove a vote from a card
|
302
|
+
#
|
303
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-membersvoted-idmember
|
304
|
+
def remove_vote(card_id, member_id)
|
305
|
+
delete_card_resource card_id, "membersVoted", member_id
|
306
|
+
end
|
307
|
+
alias_method :delete_vote, :remove_vote
|
308
|
+
|
309
|
+
# Remove a sticker from a card
|
310
|
+
#
|
311
|
+
# @see https://trello.com/docs/api/card/index.html#delete-1-cards-card-id-or-shortlink-membersvoted-idmember
|
312
|
+
def remove_sticker(card_id, sticker_id)
|
313
|
+
delete_card_resource card_id, "stickers", sticker_id
|
314
|
+
end
|
315
|
+
alias_method :delete_sticker, :remove_sticker
|
316
|
+
|
317
|
+
private
|
318
|
+
|
319
|
+
def card_resource(card_id, resource, options = {})
|
320
|
+
get card_path(card_id, camp(resource)), options
|
321
|
+
end
|
322
|
+
|
323
|
+
def paginated_card_resource(card_id, resource, options = {})
|
324
|
+
paginated_get card_path(card_id, camp(resource)), options
|
325
|
+
end
|
326
|
+
|
134
327
|
def delete_card_resource(card_id, resource, *paths)
|
135
328
|
delete card_path(card_id, camp(resource), *paths)
|
136
329
|
end
|
137
330
|
|
138
331
|
def card_path(*paths)
|
139
|
-
|
332
|
+
base_path "cards", *paths
|
140
333
|
end
|
141
334
|
end
|
142
335
|
end
|