tacokit 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -1
- data/README.md +140 -47
- data/Rakefile +13 -0
- data/bin/_guard-core +16 -0
- data/bin/console +14 -0
- data/bin/guard +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/setup +7 -0
- data/lib/tacokit/authorization.rb +8 -9
- data/lib/tacokit/client.rb +14 -20
- data/lib/tacokit/client/actions.rb +30 -14
- data/lib/tacokit/client/boards.rb +112 -16
- data/lib/tacokit/client/cards.rb +251 -72
- data/lib/tacokit/client/checklists.rb +25 -14
- data/lib/tacokit/client/labels.rb +11 -4
- data/lib/tacokit/client/lists.rb +66 -13
- data/lib/tacokit/client/members.rb +118 -42
- data/lib/tacokit/client/notifications.rb +29 -2
- data/lib/tacokit/client/organizations.rb +13 -5
- data/lib/tacokit/client/searches.rb +17 -2
- data/lib/tacokit/client/tokens.rb +8 -2
- data/lib/tacokit/client/types.rb +4 -2
- data/lib/tacokit/client/webhooks.rb +17 -4
- data/lib/tacokit/collection.rb +6 -5
- data/lib/tacokit/configuration.rb +10 -2
- data/lib/tacokit/middleware.rb +16 -0
- data/lib/tacokit/resource.rb +7 -6
- data/lib/tacokit/transform.rb +2 -4
- data/lib/tacokit/utils.rb +7 -4
- data/lib/tacokit/version.rb +2 -1
- data/tacokit.gemspec +4 -4
- metadata +17 -273
- data/spec/cassettes/Tacokit_Client/_connection/authorized_GET_request_with_app_key_and_token_params.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action/returns_a_token_authorized_action.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action/returns_oauth_authorized_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_delete_action/deletes_an_action.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_an_action.json +0 -1
- data/spec/cassettes/Tacokit_Client_Actions/_update_action_text/updates_an_action.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board/returns_a_token_authorized_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board/returns_oauth_authorized_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_a_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_nested_resource.json +0 -1
- data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +0 -1
- data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist/returns_a_checklist_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_create_checklist/creates_a_checklist.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_delete_checklist/deletes_a_checklist.json +0 -1
- data/spec/cassettes/Tacokit_Client_Checklists/_update_checklist/updates_a_checklist.json +0 -1
- data/spec/cassettes/Tacokit_Client_Labels/_create_label/creates_a_label.json +0 -1
- data/spec/cassettes/Tacokit_Client_Labels/_delete_label/deletes_a_label.json +0 -1
- data/spec/cassettes/Tacokit_Client_Labels/_label/returns_a_label_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Labels/_update_label/updates_a_label.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_create_list/creates_a_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_list/returns_a_list_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Lists/_update_list/updates_a_list.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_boards/returns_for_me_with_options_as_first_arg.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/accepts_a_resource.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/authenticated/returns_self.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/returns_a_member.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/returns_self.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_member/supports_query_fields_as_string_or_array.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_a_member.json +0 -1
- data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_nested_resource.json +0 -1
- data/spec/cassettes/Tacokit_Client_Notifications/_notification/returns_a_notification_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_create_organization/creates_a_organization.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_delete_organization/deletes_a_organization.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_organization/returns_an_organization_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_actions.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_boards.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_members.json +0 -1
- data/spec/cassettes/Tacokit_Client_Organizations/_update_organization/updates_a_organization.json +0 -1
- data/spec/cassettes/Tacokit_Client_Searches/_search/returns_search_result.json +0 -1
- data/spec/cassettes/Tacokit_Client_Tokens/_delete_token/deletes_a_token.json +0 -1
- data/spec/cassettes/Tacokit_Client_Tokens/_token/returns_a_token_for_token_string.json +0 -1
- data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_member.json +0 -1
- data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_webhooks.json +0 -1
- data/spec/cassettes/Tacokit_Client_Types/_type/returns_a_type_by_id.json +0 -1
- data/spec/cassettes/Tacokit_Client_Webhooks/_create_webhook/creates_a_webhook.json +0 -1
- data/spec/cassettes/Tacokit_Client_Webhooks/_delete_webhook/deletes_a_webhook.json +0 -1
- data/spec/cassettes/Tacokit_Client_Webhooks/_update_webhook/updates_a_webhook.json +0 -1
- data/spec/cassettes/Tacokit_Client_Webhooks/_webhook/returns_a_webhook_by_short_link.json +0 -1
- data/spec/fixtures/taco.png +0 -0
- data/spec/spec_helper.rb +0 -171
- data/spec/tacokit/authorization_spec.rb +0 -47
- data/spec/tacokit/client/actions_spec.rb +0 -137
- data/spec/tacokit/client/boards_spec.rb +0 -171
- data/spec/tacokit/client/cards_spec.rb +0 -446
- data/spec/tacokit/client/checklists_spec.rb +0 -89
- data/spec/tacokit/client/labels_spec.rb +0 -62
- data/spec/tacokit/client/lists_spec.rb +0 -131
- data/spec/tacokit/client/members_spec.rb +0 -145
- data/spec/tacokit/client/notifications_spec.rb +0 -25
- data/spec/tacokit/client/organizations_spec.rb +0 -79
- data/spec/tacokit/client/searches_spec.rb +0 -11
- data/spec/tacokit/client/tokens_spec.rb +0 -33
- data/spec/tacokit/client/types_spec.rb +0 -11
- data/spec/tacokit/client/webhooks_spec.rb +0 -61
- data/spec/tacokit/client_spec.rb +0 -28
- data/spec/tacokit/configuration_spec.rb +0 -50
- data/spec/tacokit/middleware/raise_error_spec.rb +0 -34
- data/spec/tacokit/resource_spec.rb +0 -151
- data/spec/tacokit/transform_spec.rb +0 -133
- data/spec/tacokit_spec.rb +0 -14
data/bin/setup
ADDED
@@ -1,19 +1,18 @@
|
|
1
1
|
module Tacokit
|
2
2
|
module Authorization
|
3
3
|
def get_app_key # rubocop:disable Style/AccessorMethodName
|
4
|
-
open_url web_url("
|
4
|
+
open_url web_url("app-key")
|
5
5
|
end
|
6
6
|
|
7
7
|
# Get a token for making authorized requests to the Trello API
|
8
8
|
#
|
9
|
-
# @param [
|
10
|
-
# @
|
11
|
-
# @option
|
12
|
-
# @option
|
13
|
-
# @option
|
14
|
-
# @option
|
15
|
-
# @option
|
16
|
-
# @option options [String] :expiration "1hour", "1day", "30days", "never"
|
9
|
+
# @param params [Hash] Repository information to update
|
10
|
+
# @option params [String] :name Name of the application
|
11
|
+
# @option params [String] :key Application key
|
12
|
+
# @option params [String] :callback_method "postMessage" or "fragment"
|
13
|
+
# @option params [String] :return_url URL the token should be returned to
|
14
|
+
# @option params [String] :scope Comma-separated list of one or more of "read", "write", "account"
|
15
|
+
# @option params [String] :expiration "1hour", "1day", "30days", "never"
|
17
16
|
# @see https://developers.trello.com/authorize
|
18
17
|
def authorize(params = {})
|
19
18
|
open_url authorize_url(params)
|
data/lib/tacokit/client.rb
CHANGED
@@ -48,8 +48,6 @@ module Tacokit
|
|
48
48
|
include Tacokit::Client::Webhooks
|
49
49
|
|
50
50
|
def_delegators :configuration, *Configuration.keys
|
51
|
-
def_delegators :configuration, :user_authenticated?, :user_credentials
|
52
|
-
def_delegators :configuration, :app_authenticated?, :app_credentials
|
53
51
|
def_delegators :transform, :serialize, :deserialize, :serialize_params
|
54
52
|
|
55
53
|
attr_accessor :last_response
|
@@ -109,7 +107,7 @@ module Tacokit
|
|
109
107
|
def to_s
|
110
108
|
"<#{self.class}:#{object_id}>"
|
111
109
|
end
|
112
|
-
|
110
|
+
alias inspect to_s
|
113
111
|
|
114
112
|
private
|
115
113
|
|
@@ -117,25 +115,21 @@ module Tacokit
|
|
117
115
|
@transform ||= Transform.new
|
118
116
|
end
|
119
117
|
|
120
|
-
def
|
121
|
-
|
122
|
-
|
118
|
+
def connection_options
|
119
|
+
{
|
120
|
+
url: api_endpoint,
|
121
|
+
builder: configuration.stack,
|
122
|
+
headers: { user_agent: "Tacokit #{Tacokit::VERSION}" }
|
123
|
+
}
|
124
|
+
end
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
http.
|
126
|
+
def connection
|
127
|
+
@connection ||= Faraday.new(connection_options) do |http|
|
128
|
+
if configuration.user_authenticated?
|
129
|
+
http.request :oauth, configuration.user_credentials
|
130
|
+
elsif configuration.app_authenticated?
|
131
|
+
http.params.update configuration.app_credentials
|
128
132
|
end
|
129
|
-
|
130
|
-
http.request :json
|
131
|
-
http.request :multipart
|
132
|
-
http.request :url_encoded
|
133
|
-
|
134
|
-
http.response :json, content_type: /\bjson$/
|
135
|
-
http.response :raise_error
|
136
|
-
http.response :logger if ENV["DEBUG"]
|
137
|
-
|
138
|
-
http.adapter Faraday.default_adapter
|
139
133
|
end
|
140
134
|
end
|
141
135
|
end
|
@@ -2,78 +2,94 @@ module Tacokit
|
|
2
2
|
class Client
|
3
3
|
module Actions
|
4
4
|
# Retrieve an action
|
5
|
-
#
|
5
|
+
# @param action_id [String] the action identifier
|
6
|
+
# @return [Tacokit::Resource] the action resource
|
6
7
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction
|
7
8
|
def action(action_id, options = nil)
|
8
9
|
get action_path(action_id), options
|
9
10
|
end
|
10
11
|
|
11
12
|
# Retrieve an action's board
|
12
|
-
#
|
13
|
+
# @param action_id [String] the action identifier
|
14
|
+
# @param fields [String, Array<String>] a list of board attributes to fetch
|
15
|
+
# @return [Tacokit::Resource] the board resource
|
13
16
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-field
|
14
17
|
def action_board(action_id, fields = "all")
|
15
18
|
action_resource action_id, "board", fields: fields
|
16
19
|
end
|
17
20
|
|
18
21
|
# Retrieve an actions" card
|
19
|
-
#
|
22
|
+
# @param action_id [String] the action identifier
|
23
|
+
# @param fields [String, Array<String>] a list of card attributes to fetch
|
24
|
+
# @return [Tacokit::Resource] the card resource
|
20
25
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-card
|
21
26
|
def action_card(action_id, fields = "all")
|
22
27
|
action_resource action_id, "card", fields: fields
|
23
28
|
end
|
24
29
|
|
25
30
|
# Retrive an action's entities
|
26
|
-
#
|
31
|
+
# @param action_id [String] the action identifier
|
32
|
+
# @return [Array] list of entity attributes involved in the action
|
27
33
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-entities
|
28
34
|
def action_entities(action_id)
|
29
35
|
action_resource action_id, "entities"
|
30
36
|
end
|
31
37
|
|
32
38
|
# Retrieve an action's list
|
33
|
-
#
|
39
|
+
# @param action_id [String] the action identifier
|
40
|
+
# @param fields [String, Array<String>] a list of list attributes to fetch
|
41
|
+
# @return [Tacokit::Resource] the list resource
|
34
42
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-list
|
35
43
|
def action_list(action_id, fields = "all")
|
36
44
|
action_resource action_id, "list", fields: fields
|
37
45
|
end
|
38
46
|
|
39
|
-
# Retrieve an
|
40
|
-
#
|
47
|
+
# Retrieve an action's member
|
48
|
+
# @param action_id [String] the action identifier
|
49
|
+
# @param fields [String, Array<String>] a list of member attributes to fetch
|
50
|
+
# @return [Tacokit::Resource] the member resource
|
41
51
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-member
|
42
52
|
def action_member(action_id, fields = "all")
|
43
53
|
action_resource action_id, "member", fields: fields
|
44
54
|
end
|
45
55
|
|
46
56
|
# Retrieve an action's creator
|
47
|
-
#
|
57
|
+
# @param action_id [String] the action identifier
|
58
|
+
# @param fields [String, Array<String>] a list of member attributes to fetch
|
59
|
+
# @return [Tacokit::Resource] the member resource
|
48
60
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-membercreator
|
49
61
|
def action_member_creator(action_id, fields = "all")
|
50
62
|
action_resource action_id, "memberCreator", fields: fields
|
51
63
|
end
|
52
64
|
|
53
|
-
# Retrieve an action's
|
54
|
-
#
|
65
|
+
# Retrieve an action's organization
|
66
|
+
# @param action_id [String] the action identifier
|
67
|
+
# @param fields [String, Array<String>] a list of organization attributes to fetch
|
68
|
+
# @return [Tacokit::Resource] the organization resource
|
55
69
|
# @see https://developers.trello.com/advanced-reference/action#get-1-actions-idaction-organization
|
56
70
|
def action_organization(action_id, fields = "all")
|
57
71
|
action_resource action_id, "organization", fields: fields
|
58
72
|
end
|
59
73
|
|
60
74
|
# Update an action
|
61
|
-
#
|
75
|
+
# @param action_id [String] the action identifier
|
76
|
+
# @param options [Hash] a hash of attributes to update
|
62
77
|
# @see https://developers.trello.com/advanced-reference/action#put-1-actions-idaction
|
63
78
|
def update_action(action_id, options = {})
|
64
79
|
put action_path(action_id), options
|
65
80
|
end
|
66
81
|
|
67
82
|
# Set new text for an action
|
68
|
-
#
|
83
|
+
# @param action_id [String] the action identifier
|
84
|
+
# @param text [String] the new text
|
69
85
|
# @see https://developers.trello.com/advanced-reference/action#put-1-actions-idaction-text
|
70
86
|
def update_action_text(action_id, text)
|
71
87
|
put action_path(action_id, "text"), value: text
|
72
88
|
end
|
73
|
-
|
89
|
+
alias edit_action_text update_action_text
|
74
90
|
|
75
91
|
# Delete an action
|
76
|
-
#
|
92
|
+
# @param action_id [String] the action identifier
|
77
93
|
# @see https://developers.trello.com/advanced-reference/action#delete-1-actions-idaction
|
78
94
|
def delete_action(action_id)
|
79
95
|
delete action_path(action_id)
|
@@ -1,86 +1,169 @@
|
|
1
1
|
module Tacokit
|
2
2
|
class Client
|
3
|
+
# Methods for the Boards API
|
4
|
+
# @see https://developers.trello.com/advanced-reference/board
|
3
5
|
module Boards
|
4
6
|
# Retrieve a board
|
5
|
-
#
|
7
|
+
# @param board_id [String] the board identifier
|
8
|
+
# @return [Tacokit::Resource<Board>] the board resource
|
9
|
+
# @example fetch a board
|
10
|
+
# Tacokit.board("aBoardId") #=> Tacokit::Resource<Board>
|
11
|
+
# @example fetch a board with all its cards
|
12
|
+
# Tacokit.member("aBoardId", cards: "all") #=> Tacokit::Resource<Board>
|
13
|
+
# @example configure a local client, fetch a board with a subset of attributes
|
14
|
+
# client = Tacokit::Client.new app_key: "another-app-key"
|
15
|
+
# client.board('aBoardId', fields: %w[name shortUrl desc]) #=> Tacokit::Resource<Board>
|
6
16
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id
|
7
17
|
def board(board_id, options = nil)
|
8
18
|
get board_path(board_id), options
|
9
19
|
end
|
10
20
|
|
11
21
|
# Retrieve a board's actions
|
12
|
-
#
|
22
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
23
|
+
# @param options [Hash] the options to fetch the actions with
|
24
|
+
# @return [Tacokit::Collection<Action>] the action resources
|
25
|
+
# @example fetch "create card" actions for a given board
|
26
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
27
|
+
# Tacokit.board_actions(board, filter: "create_card") #=> Tacokit::Collection<Action>
|
13
28
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-actions
|
14
29
|
def board_actions(board_id, options = {})
|
15
30
|
paginated_board_resource(board_id, "actions", options)
|
16
31
|
end
|
17
32
|
|
18
33
|
# Retrieve a board's stars
|
19
|
-
#
|
34
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
35
|
+
# @param options [Hash] the options to fetch the stars with
|
36
|
+
# @return [Tacokit::Collection<Star>] the star resources
|
37
|
+
# @example fetch board stars
|
38
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
39
|
+
# Tacokit.board_stars(board) #=> Tacokit::Collection<Star>
|
20
40
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-boardstars
|
21
41
|
def board_stars(board_id, options = {})
|
22
42
|
board_resource(board_id, "board_stars", options)
|
23
43
|
end
|
24
44
|
|
25
45
|
# Retrieve a board's cards
|
26
|
-
#
|
46
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
47
|
+
# @param options [Hash] the options to fetch the cards with
|
48
|
+
# @return [Tacokit::Collection<Card>] the card resources
|
49
|
+
# @example fetch board cards
|
50
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
51
|
+
# Tacokit.board_cards(board) #=> Tacokit::Collection<Card>
|
52
|
+
# @example fetch board cards with attachments, members, stickers
|
53
|
+
# Tacokit.board_cards(board, attachments: true, members: true, stickers: true) #=> Tacokit::Collection<Card>
|
54
|
+
# @example configure a local client, fetch a board"s cards with a subset of attributes
|
55
|
+
# client = Tacokit::Client.new app_key: "another-app-key"
|
56
|
+
# client.board_cards("aBoardId") #=> Tacokit::Collection<Card>
|
27
57
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-cards
|
28
58
|
def board_cards(board_id, options = {})
|
29
59
|
paginated_board_resource(board_id, "cards", options)
|
30
60
|
end
|
31
61
|
|
32
62
|
# Retrieve a board's checklists
|
33
|
-
#
|
63
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
64
|
+
# @param options [Hash] the options to fetch the checklists with
|
65
|
+
# @return [Tacokit::Collection<Checklist>] the checklist resources
|
66
|
+
# @example fetch board checklists
|
67
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
68
|
+
# Tacokit.board_checklists(board) #=> Tacokit::Collection<Checklist>
|
34
69
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-checklists
|
35
70
|
def board_checklists(board_id, options = {})
|
36
71
|
board_resource(board_id, "checklists", options)
|
37
72
|
end
|
38
73
|
|
39
74
|
# Retrieve a board's labels
|
40
|
-
#
|
75
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
76
|
+
# @param options [Hash] the options to fetch the labels with
|
77
|
+
# @return [Tacokit::Collection<Label>] the label resources
|
78
|
+
# @example fetch board's first 50 (default) labels
|
79
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
80
|
+
# Tacokit.board_labels(board) #=> Tacokit::Collection<Label>
|
81
|
+
# @example fetch board's first 100 labels
|
82
|
+
# Tacokit.board_labels(board, limit: 100) #=> Tacokit::Collection<Label>
|
41
83
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-labels
|
42
84
|
def board_labels(board_id, options = {})
|
43
85
|
board_resource(board_id, "labels", options)
|
44
86
|
end
|
45
87
|
|
46
88
|
# Retrieve a board's lists
|
47
|
-
#
|
89
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
90
|
+
# @param options [Hash] the options to fetch the lists with
|
91
|
+
# @return [Tacokit::Collection<List>] the list resources
|
92
|
+
# @example fetch open board lists
|
93
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
94
|
+
# Tacokit.board_lists(board) #=> Tacokit::Collection<List>
|
95
|
+
# @example fetch all board lists with open cards
|
96
|
+
# Tacokit.board_lists(board, filter: "all", cards: "open") #=> Tacokit::Collection<List>
|
97
|
+
# @example configure a local client, fetch a board's open lists with lists names and pos
|
98
|
+
# client = Tacokit::Client.new app_key: "another-app-key"
|
99
|
+
# client.board_lists(board, fields: %w[name pos]) #=> Tacokit::Resource<List>
|
48
100
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-lists
|
49
101
|
def lists(board_id, options = {})
|
50
102
|
board_resource(board_id, "lists", options)
|
51
103
|
end
|
52
|
-
|
104
|
+
alias board_lists lists
|
53
105
|
|
54
106
|
# Retrieve a board's members
|
55
|
-
#
|
107
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
108
|
+
# @param options [Hash] the options to fetch the members with
|
109
|
+
# @return [Tacokit::Collection<Member>] the member resources
|
110
|
+
# @example fetch board's members
|
111
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
112
|
+
# Tacokit.board_members(board) #=> Tacokit::Collection<Member>
|
113
|
+
# @example fetch board's members with selected attributes
|
114
|
+
# Tacokit.board_members(board, fields: %w[username url avatar_hash]) #=> Tacokit::Collection<Member>
|
56
115
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-members
|
57
116
|
def board_members(board_id, options = {})
|
58
117
|
board_resource(board_id, "members", options)
|
59
118
|
end
|
60
119
|
|
61
120
|
# Retrieve your preferences for a board
|
62
|
-
#
|
121
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
122
|
+
# @param options [Hash] the options to fetch the preferences with
|
123
|
+
# @return [Tacokit::Collection] the preference resources
|
124
|
+
# @example fetch board's preferences
|
125
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
126
|
+
# Tacokit.board_preferences(board) #=> Tacokit::Collection<Preference>
|
63
127
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-myprefs
|
64
128
|
def board_preferences(board_id, options = {})
|
65
129
|
board_resource(board_id, "my_prefs", options)
|
66
130
|
end
|
67
131
|
|
68
132
|
# Retrieve a board's organization
|
69
|
-
#
|
133
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
134
|
+
# @param options [Hash] the options to fetch the organizations with
|
135
|
+
# @return [Tacokit::Collection] the organization resources
|
136
|
+
# @example fetch board's organization
|
137
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
138
|
+
# Tacokit.board_organization(board) #=> Tacokit::Resource<Organization>
|
139
|
+
# @example fetch board's organization with selected attributes
|
140
|
+
# Tacokit.board_organization(board, fields: %w[name url website]) #=> Tacokit::Resource<Organization>
|
70
141
|
# @see https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-organization
|
71
142
|
def board_organization(board_id, options = {})
|
72
143
|
board_resource(board_id, "organization", options)
|
73
144
|
end
|
74
145
|
|
75
146
|
# Update board attributes
|
76
|
-
#
|
147
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
148
|
+
# @param options [Hash] the attributes to update on the board
|
149
|
+
# @example Update a board's name and description
|
150
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
151
|
+
# Tacokit.update_board(board, name: "New Board Name", desc: "For realz this time")
|
152
|
+
# @example Open a closed board
|
153
|
+
# Tacokit.update_board(board, closed: false)
|
77
154
|
# @see https://developers.trello.com/advanced-reference/board#put-1-boards-board-id
|
78
155
|
def update_board(board_id, options = {})
|
79
156
|
put board_path(board_id), options
|
80
157
|
end
|
81
158
|
|
82
159
|
# Add a member to a board
|
83
|
-
#
|
160
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
161
|
+
# @param email [String] an email address of the member to add
|
162
|
+
# @param full_name [String] the full name of the member to add
|
163
|
+
# @param options [Hash] options to modify the membership with
|
164
|
+
# @example Add your friend Susan as an admin to your board
|
165
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
166
|
+
# Tacokit.add_board_member(board, "susan@example.com", "Susan Example", type: "admin")
|
84
167
|
# @see https://developers.trello.com/advanced-reference/board#put-1-boards-board-id-members-idmember
|
85
168
|
def add_board_member(board_id, email, full_name, options = {})
|
86
169
|
options.update \
|
@@ -90,13 +173,26 @@ module Tacokit
|
|
90
173
|
end
|
91
174
|
|
92
175
|
# Update a board member's type
|
93
|
-
#
|
176
|
+
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
|
177
|
+
# @param member_id [String] the member identifier
|
178
|
+
# @param type [String] the membership type to change to
|
179
|
+
# @example Demote your friend Larry to a member with "normal" membership privileges
|
180
|
+
# board = Tacokit.client("aBoardId") #=> Tacokit::Resource<Board>
|
181
|
+
# larry = Tacokit.member("someMemberNamedLarry") #=> Tacokit::Resource<Member>
|
182
|
+
# Tacokit.update_board_member(board, larry, "normal")
|
94
183
|
# @see https://developers.trello.com/advanced-reference/board#put-1-boards-board-id-members-idmember
|
95
184
|
def update_board_member(board_id, member_id, type)
|
96
|
-
update_board_resource(board_id, "members", member_id, type: type)
|
185
|
+
update_board_resource(board_id, "members", resource_id(member_id), type: type)
|
97
186
|
end
|
98
187
|
|
99
|
-
#
|
188
|
+
# Create a board
|
189
|
+
# @param name [String] the new board name
|
190
|
+
# @param options [Hash] options to create the board with
|
191
|
+
# @example Create a board named "Holiday Shopping"
|
192
|
+
# Tacokit.create_board("Holiday Shopping")
|
193
|
+
# @example Create a board named "Project B" copied from another board with a new organization and description
|
194
|
+
# Tacokit.create_board("Project B", board_source_id: "projectASourceIdentifier", organization_id: "anOrgId", desc: "A cloned board!")
|
195
|
+
# @see https://developers.trello.com/advanced-reference/board#post-1-boards
|
100
196
|
def create_board(name, options = {})
|
101
197
|
post "boards", options.merge(name: name)
|
102
198
|
end
|
data/lib/tacokit/client/cards.rb
CHANGED
@@ -3,126 +3,209 @@ require "uri"
|
|
3
3
|
module Tacokit
|
4
4
|
class Client
|
5
5
|
# Methods for the Cards API
|
6
|
-
#
|
7
6
|
# @see https://developers.trello.com/advanced-reference/card
|
8
7
|
module Cards
|
9
8
|
# Retrieve a card by id or shortlink
|
10
|
-
#
|
9
|
+
# @param card_id [String] the card identifier or shortlink
|
10
|
+
# @return [Tacokit::Resource<Card>] the card resource
|
11
|
+
# @example Retrieve a card by its id
|
12
|
+
# Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
13
|
+
# @example Retrieve a card by its short link with its members
|
14
|
+
# Tacokit.card("aCardShortLink", members: true) #=> Tacokit::Resource<Card>
|
11
15
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink
|
12
16
|
def card(card_id, options = nil)
|
13
17
|
get card_path(card_id), options
|
14
18
|
end
|
15
19
|
|
16
20
|
# Retrieve card actions
|
17
|
-
#
|
21
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
22
|
+
# @param options [Hash] the options to fetch the actions with
|
23
|
+
# @return [Tacokit::Collection<Action>] the action resources
|
24
|
+
# @example Retrieve a card's comments
|
25
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
26
|
+
# Tacokit.card_actions(card, filter: "comment_card") #=> Tacokit::Collection<Action>
|
18
27
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-actions
|
19
28
|
def card_actions(card_id, options = {})
|
20
29
|
paginated_card_resource(card_id, "actions", options)
|
21
30
|
end
|
22
31
|
|
23
32
|
# Retrieve card attachments
|
24
|
-
#
|
33
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
34
|
+
# @param options [Hash] the options to fetch the attachments with
|
35
|
+
# @return [Tacokit::Collection<Attachment>] the attachment resources
|
36
|
+
# @example Retrieve attachments for a card
|
37
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
38
|
+
# Tacokit.attachments(card) #=> Tacokit::Collection<Attachment>
|
25
39
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments
|
26
40
|
def attachments(card_id, options = {})
|
27
41
|
card_resource(card_id, "attachments", options)
|
28
42
|
end
|
29
|
-
|
43
|
+
alias card_attachments attachments
|
30
44
|
|
31
45
|
# Retrieve a card attachment
|
32
|
-
#
|
46
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
47
|
+
# @param attachment_id [String] the attachment id
|
48
|
+
# @param options [Hash] the options to fetch the attachments with
|
49
|
+
# @return [Tacokit::Resource<Attachment>] the attachment resource
|
50
|
+
# @example Retrieve a single card attachment
|
51
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
52
|
+
# Tacokit.attachment(card, "anAttachmentId") #=> Tacokit::Resource<Attachment>
|
33
53
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments-idattachment
|
34
54
|
def attachment(card_id, attachment_id, options = {})
|
35
|
-
card_resource(card_id, "attachments/#{attachment_id}", options)
|
55
|
+
card_resource(card_id, "attachments/#{resource_id(attachment_id)}", options)
|
36
56
|
end
|
37
57
|
|
38
58
|
# Retrieve a card board
|
39
|
-
#
|
59
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
60
|
+
# @param options [Hash] the options to fetch the board with
|
61
|
+
# @return [Tacokit::Resource<Board>] the board resource
|
62
|
+
# @example Retrieve a card board
|
63
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
64
|
+
# Tacokit.card_board(card) #=> Tacokit::Resource<Board>
|
40
65
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-board
|
41
66
|
def card_board(card_id, options = {})
|
42
67
|
card_resource(card_id, "board", options)
|
43
68
|
end
|
44
69
|
|
45
70
|
# Retrieve card checklist item states
|
46
|
-
#
|
71
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
72
|
+
# @param options [Hash] the options to fetch the states with
|
73
|
+
# @return [Tacokit::Collection] the check item state resources
|
74
|
+
# @example Retrieve states of checked items
|
75
|
+
# Tacokit.check_item_states("aCardId") #=> Tacokit::Collection
|
47
76
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-board
|
48
77
|
def check_item_states(card_id, options = {})
|
49
78
|
card_resource(card_id, "check_item_states", options)
|
50
79
|
end
|
51
80
|
|
52
81
|
# Retrieve card checklists
|
53
|
-
#
|
82
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
83
|
+
# @param options [Hash] the options to fetch the checklists with
|
84
|
+
# @return [Tacokit::Collection<Checklist>] the checklist resources
|
85
|
+
# @example Retrieve checklists
|
86
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
87
|
+
# Tacokit.checklists(card) #=> Tacokit::Collection<Checklist>
|
54
88
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-board
|
55
89
|
def checklists(card_id, options = {})
|
56
90
|
card_resource(card_id, "checklists", options)
|
57
91
|
end
|
58
92
|
|
59
93
|
# Retrive a card list
|
60
|
-
#
|
61
|
-
# @
|
62
|
-
#
|
94
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
95
|
+
# @param options [Hash] the options to fetch the list with
|
96
|
+
# @return [Tacokit::Resource<List>] the list resource
|
97
|
+
# @example Retrieve a card list
|
98
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
99
|
+
# Tacokit.card_list(card) #=> Tacokit::Resource<List>
|
100
|
+
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-list
|
63
101
|
def card_list(card_id, options = {})
|
64
102
|
card_resource(card_id, "list", options)
|
65
103
|
end
|
66
104
|
|
67
105
|
# Retrieve card members
|
68
|
-
#
|
106
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
107
|
+
# @param options [Hash] the options to fetch the members with
|
108
|
+
# @return [Tacokit::Collection] the member resources
|
109
|
+
# @example Retrieve a card's members
|
110
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
111
|
+
# Tacokit.card_members(card) #=> Tacokit::Collection<Member>
|
69
112
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-members
|
70
113
|
def card_members(card_id, options = {})
|
71
114
|
card_resource(card_id, "members", options)
|
72
115
|
end
|
73
116
|
|
74
117
|
# Retrieve members who voted on a card
|
75
|
-
#
|
118
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
119
|
+
# @param options [Hash] the options to fetch the members with
|
120
|
+
# @return [Tacokit::Collection] the member resources
|
121
|
+
# @example Retrieve members who voted for card
|
122
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
123
|
+
# Tacokit.card_members_voted(card) #=> Tacokit::Collection<Member>
|
76
124
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-membersvoted
|
77
125
|
def card_members_voted(card_id, options = {})
|
78
126
|
card_resource(card_id, "members_voted", options)
|
79
127
|
end
|
80
128
|
|
81
129
|
# Retrieve card stickers
|
82
|
-
#
|
130
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
131
|
+
# @param options [Hash] the options to fetch the stickers with
|
132
|
+
# @return [Tacokit::Collection] the sticker resources
|
133
|
+
# @example Retrieve stickers on card
|
134
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
135
|
+
# Tacokit.stickers(card) #=> Tacokit::Collection<Stickers>
|
83
136
|
# @see https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-stickers
|
84
137
|
def stickers(card_id, options = {})
|
85
138
|
card_resource(card_id, "stickers", options)
|
86
139
|
end
|
87
140
|
|
88
141
|
# Update card attributes
|
89
|
-
#
|
142
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
143
|
+
# @param options [Hash] the attributes to update on the card
|
144
|
+
# @example Update name of card
|
145
|
+
# card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
|
146
|
+
# Tacokit.update_card(card, name: "New card") #=> Tacokit::Resource<Card>
|
90
147
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink
|
91
148
|
def update_card(card_id, options = {})
|
92
149
|
put card_path(card_id), options
|
93
150
|
end
|
94
151
|
|
95
152
|
# Update comment text
|
96
|
-
#
|
153
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
154
|
+
# @param comment_id [String] the comment identifier
|
155
|
+
# @param text [String] the updated comment text
|
156
|
+
# @param options [Hash] the attributes to update on the comment
|
157
|
+
# @example Change text of existing comment
|
158
|
+
# card = Tacokit.card("aCardId", action: "commentCard")
|
159
|
+
# comment = card.actions.first
|
160
|
+
# Tacokit.update_comment(card, comment, "New comment text")
|
97
161
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-actions-idaction-comments
|
98
162
|
def update_comment(card_id, comment_id, text, options = {})
|
99
|
-
update_card_resource(card_id, "actions", comment_id, "comments", options.merge(text: text))
|
163
|
+
update_card_resource(card_id, "actions", resource_id(comment_id), "comments", options.merge(text: text))
|
100
164
|
end
|
101
|
-
|
165
|
+
alias edit_comment update_comment
|
102
166
|
|
103
167
|
# Update checklist item text, position or state
|
104
|
-
#
|
168
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
169
|
+
# @param checklist_id [String] the checklist identifier
|
170
|
+
# @param check_item_id [String] the check item identifier
|
171
|
+
# @param options [Hash] the attributes to update on the check item
|
105
172
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-checklist-idchecklistcurrent-checkitem-idcheckitem
|
106
173
|
def update_check_item(card_id, checklist_id, check_item_id, options = {})
|
107
|
-
update_card_resource
|
174
|
+
update_card_resource card_id,
|
175
|
+
"checklist",
|
176
|
+
resource_id(checklist_id),
|
177
|
+
"checkItem",
|
178
|
+
resource_id(check_item_id),
|
179
|
+
options
|
108
180
|
end
|
109
181
|
|
110
182
|
# Archive a card
|
111
|
-
#
|
183
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
184
|
+
# @example Archive a card
|
185
|
+
# Tacokit.archive_card("aCardId")
|
112
186
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-closed
|
113
187
|
def archive_card(card_id)
|
114
188
|
update_card(card_id, closed: true)
|
115
189
|
end
|
116
190
|
|
117
191
|
# Restore an archived card
|
118
|
-
#
|
192
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
193
|
+
# @example Restore a card
|
194
|
+
# Tacokit.restore_card("aCardId")
|
119
195
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-closed
|
120
196
|
def restore_card(card_id)
|
121
197
|
update_card(card_id, closed: false)
|
122
198
|
end
|
123
199
|
|
124
200
|
# Move card to another position, board and/or list
|
125
|
-
#
|
201
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
202
|
+
# @param options [Hash] the options for moving the card
|
203
|
+
# @option options [String] :board_id another board location
|
204
|
+
# @option options [String] :list_id another list location
|
205
|
+
# @option options [String] :pos new position in current list
|
206
|
+
# @example Move card to the top of a new list
|
207
|
+
# card = Tacokit.card("aCardId")
|
208
|
+
# Tacokit.move_card(card, list_id: "aListId", pos: "top")
|
126
209
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-idboard
|
127
210
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-idlist
|
128
211
|
def move_card(card_id, options)
|
@@ -133,50 +216,75 @@ module Tacokit
|
|
133
216
|
end
|
134
217
|
|
135
218
|
# Update card name
|
136
|
-
#
|
219
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
220
|
+
# @param name [String] a name for the card
|
221
|
+
# @example Change card name
|
222
|
+
# Tacokit.update_card_name("aCardId", "New card name")
|
137
223
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-name
|
138
224
|
def update_card_name(card_id, name)
|
139
225
|
put card_path(card_id, "name"), value: name
|
140
226
|
end
|
141
227
|
|
142
228
|
# Subscribe to card
|
143
|
-
#
|
229
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
230
|
+
# @example Subscribe to card
|
231
|
+
# Tacokit.subscribe_to_card("aCardId")
|
144
232
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-subscribed
|
145
233
|
def subscribe_to_card(card_id)
|
146
234
|
put card_path(card_id, "subscribed"), value: true
|
147
235
|
end
|
148
236
|
|
149
237
|
# Unubscribe from card
|
150
|
-
#
|
238
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
239
|
+
# @example Unubscribe from card
|
240
|
+
# Tacokit.unsubscribe_from_card("aCardId")
|
151
241
|
# @see https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-subscribed
|
152
242
|
def unsubscribe_from_card(card_id)
|
153
243
|
put card_path(card_id, "subscribed"), value: false
|
154
244
|
end
|
155
245
|
|
156
246
|
# Update any card resource
|
247
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
248
|
+
# @param resource [String] a resource name, like board, list, attachment
|
249
|
+
# @param paths [Hash, String] nested paths and/or options for updating the card's nested resource
|
157
250
|
def update_card_resource(card_id, resource, *paths)
|
158
251
|
paths, options = extract_options(camp(resource), *paths)
|
159
252
|
put card_path(card_id, *paths), options
|
160
253
|
end
|
161
254
|
|
162
|
-
# Create a card
|
163
|
-
#
|
255
|
+
# Create a new card
|
256
|
+
# @param list_id [String, Tacokit::Resource<List>] the list identifier or list
|
257
|
+
# @param name [String] a name for the card
|
258
|
+
# @param options [Hash] options to create the card with
|
259
|
+
# @example Create a new card at bottom of a given list
|
260
|
+
# Tacokit.create_card("aListId", "Card name", pos: "bottom")
|
164
261
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards
|
165
262
|
def create_card(list_id, name = nil, options = {})
|
166
|
-
post "cards", options.merge(name: name, list_id: list_id)
|
263
|
+
post "cards", options.merge(name: name, list_id: resource_id(list_id))
|
167
264
|
end
|
168
265
|
|
169
266
|
# Add a comment to a card
|
170
|
-
#
|
267
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
268
|
+
# @param text [String] comment text
|
269
|
+
# @param options [Hash] options to create the comment with
|
270
|
+
# @example Add comment to a card
|
271
|
+
# Tacokit.add_comment("aCardId", "@bob What do you mean?")
|
171
272
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-actions-comments
|
172
273
|
def add_comment(card_id, text, options = {})
|
173
274
|
options.update text: text
|
174
275
|
create_card_resource card_id, "actions", "comments", options
|
175
276
|
end
|
176
|
-
|
277
|
+
alias create_card_comment add_comment
|
177
278
|
|
178
279
|
# Attach a file to a card
|
179
|
-
#
|
280
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
281
|
+
# @param url [String] a local file path of http url to a file
|
282
|
+
# @param mime_type [String] a mime type for http url
|
283
|
+
# @param options [Hash] additional options to attach the file with
|
284
|
+
# @example Attach a file from the file system
|
285
|
+
# Tacokit.attach_file("aCardId", "/path/to/local/file.png")
|
286
|
+
# @example Attach a file the "Internet" with mime type
|
287
|
+
# Tacokit.attach_file("aCardId", "https://imgur.com/giphy.gif", "image/gif")
|
180
288
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-attachments
|
181
289
|
def attach_file(card_id, url, mime_type = nil, options = {})
|
182
290
|
options = mime_type if mime_type.is_a?(Hash)
|
@@ -192,130 +300,201 @@ module Tacokit
|
|
192
300
|
|
193
301
|
create_card_resource card_id, "attachments", options
|
194
302
|
end
|
195
|
-
|
303
|
+
alias create_card_attachment attach_file
|
196
304
|
|
197
305
|
# Convert a checklist item to a card
|
198
|
-
#
|
306
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
307
|
+
# @param checklist_id [String] the checklist identifier
|
308
|
+
# @param check_item_id [String] the check item identifier to convert to a card
|
309
|
+
# @example Convert a checklist item to a card
|
310
|
+
# card = Tacokit.card("aCardId", checklists: :all)
|
311
|
+
# checklist = card.checklists.first
|
312
|
+
# check_item = checklist.check_items.first
|
313
|
+
# Tacokit.convert_to_card(card, checklist, check_item)
|
199
314
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-converttocard
|
200
315
|
def convert_to_card(card_id, checklist_id, check_item_id)
|
201
|
-
create_card_resource
|
316
|
+
create_card_resource card_id, "checklist", resource_id(checklist_id),
|
317
|
+
"checkItem", resource_id(check_item_id), "convertToCard"
|
202
318
|
end
|
203
319
|
|
204
320
|
# Start a new checklist on card
|
205
|
-
#
|
321
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
322
|
+
# @param name [String] the new checklist name
|
323
|
+
# @example Add checklist to card
|
324
|
+
# card = Tacokit.card("aCardId")
|
325
|
+
# checklist = Tacokit.add_checklist(card, "Tasks")
|
206
326
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-checklists
|
207
327
|
def add_checklist(card_id, name)
|
208
328
|
create_card_resource(card_id, "checklists", name: name)
|
209
329
|
end
|
210
|
-
|
330
|
+
alias start_checklist add_checklist
|
211
331
|
|
212
332
|
# Copy another checklist to card
|
213
|
-
#
|
333
|
+
# @param card_id [String, Tacokit::Resource<Card>] the destination card identifier, shortlink, or card
|
334
|
+
# @param checklist_id [String] the checklist identifier
|
335
|
+
# card_1 = Tacokit.card("aCardId")
|
336
|
+
# checklist = card.add_checklist(card_1, "Tasks")
|
337
|
+
# card_2 = Tacokit.card("bCardId")
|
338
|
+
# Tacokit.copy_checklist(card_2, checklist)
|
214
339
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-checklists
|
215
340
|
def copy_checklist(card_id, checklist_id)
|
216
|
-
create_card_resource(card_id, "checklists", checklist_source_id: checklist_id)
|
341
|
+
create_card_resource(card_id, "checklists", checklist_source_id: resource_id(checklist_id))
|
217
342
|
end
|
218
343
|
|
219
344
|
# Add a member to a card
|
220
|
-
#
|
345
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
346
|
+
# @param member_id [String] the member identifier
|
347
|
+
# @example Add a member to a card
|
348
|
+
# card = Tacokit.card("aCardId")
|
349
|
+
# member = Tacokit.member("nickname")
|
350
|
+
# Tacokit.add_member_to_card(card, member)
|
351
|
+
# @example Add a member by id to a card
|
352
|
+
# Tacokit.add_member_to_card("aCardId", "aMemberId")
|
221
353
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-idmembers
|
222
354
|
def add_member_to_card(card_id, member_id)
|
223
|
-
create_card_resource(card_id, "idMembers", value: member_id)
|
355
|
+
create_card_resource(card_id, "idMembers", value: resource_id(member_id))
|
224
356
|
end
|
225
357
|
|
226
358
|
# Add label to card
|
227
|
-
#
|
359
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
360
|
+
# @param color [String] a color name or hex value
|
361
|
+
# @param options [Hash] options to add the label with
|
362
|
+
# @example Add label to card
|
363
|
+
# Tacokit.add_label("aCardId", "red", name: "Overdue")
|
228
364
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-labels
|
229
365
|
def add_label(card_id, color, options = {})
|
230
366
|
create_card_resource(card_id, "labels", options.merge(color: color))
|
231
367
|
end
|
232
368
|
|
233
369
|
# Cast vote for card
|
234
|
-
#
|
370
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
371
|
+
# @param member_id [String] the voter member identifier
|
372
|
+
# @example Vote on card for given member
|
373
|
+
# member = Tacokit.member("rossta")
|
374
|
+
# Tacokit.vote("aCardId", member)
|
235
375
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-membersvoted
|
236
376
|
def vote(card_id, member_id)
|
237
|
-
create_card_resource(card_id, "membersVoted", value: member_id)
|
377
|
+
create_card_resource(card_id, "membersVoted", value: resource_id(member_id))
|
238
378
|
end
|
239
|
-
|
379
|
+
alias create_vote vote
|
240
380
|
|
241
381
|
# Add sticker to card
|
242
|
-
#
|
382
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
383
|
+
# @param image_name [String] the sticker name
|
384
|
+
# @param options [Hash] options to add the sticker with, such as position arguments
|
385
|
+
# @example Add sticker to card with optional positioning
|
386
|
+
# Tacokit.add_sticker("aCardId", "star", top: 100, left: 200, z_index: 50)
|
243
387
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-stickers
|
244
388
|
def add_sticker(card_id, image_name, options = {})
|
245
389
|
defaults = { top: 0, left: 0, z_index: 1 }
|
246
390
|
create_card_resource(card_id, "stickers", defaults.merge(options.merge(image: image_name)))
|
247
391
|
end
|
248
|
-
|
392
|
+
alias create_sticker add_sticker
|
249
393
|
|
394
|
+
# @private
|
250
395
|
# Create a card resource
|
251
|
-
#
|
252
396
|
def create_card_resource(card_id, resource, *paths)
|
253
397
|
paths, options = extract_options(camp(resource), *paths)
|
254
398
|
post card_path(card_id, *paths), options
|
255
399
|
end
|
256
400
|
|
257
|
-
#
|
258
|
-
#
|
401
|
+
# Delete a card
|
402
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
403
|
+
# @example Delete a card
|
404
|
+
# card = Tacokit.card("aCardId")
|
405
|
+
# Tacokit.delete_card(card)
|
259
406
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink
|
260
407
|
def delete_card(card_id)
|
261
|
-
delete card_path(card_id)
|
408
|
+
delete card_path(resource_id(card_id))
|
262
409
|
end
|
263
410
|
|
264
411
|
# Remove a comment
|
265
|
-
#
|
412
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
413
|
+
# @param comment_id [String] the comment identifier
|
414
|
+
# @example Remove a comment
|
415
|
+
# card = Tacokit.card("aCardId")
|
416
|
+
# comment = Tacokit.add_comment(card, "This message will be deleted")
|
417
|
+
# Tacokit.remove_comment(comment)
|
266
418
|
# @see https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-labels
|
267
419
|
def remove_comment(card_id, comment_id)
|
268
|
-
delete_card_resource card_id, "actions", comment_id, "comments"
|
420
|
+
delete_card_resource card_id, "actions", resource_id(comment_id), "comments"
|
269
421
|
end
|
270
|
-
|
422
|
+
alias delete_comment remove_comment
|
271
423
|
|
272
424
|
# Remove an attachment
|
273
|
-
#
|
425
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
426
|
+
# @param attachment_id [String] the attachment identifier
|
427
|
+
# @example Remove an attachment
|
428
|
+
# card = Tacokit.card("aCardId")
|
429
|
+
# attachment = Tacokit.attach_file(card, "/path/to/local/file.png")
|
430
|
+
# Tacokit.remove_attachment(card, attachment)
|
274
431
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-attachments-idattachment
|
275
432
|
def remove_attachment(card_id, attachment_id)
|
276
|
-
delete_card_resource card_id, "attachments", attachment_id
|
433
|
+
delete_card_resource card_id, "attachments", resource_id(attachment_id)
|
277
434
|
end
|
278
|
-
|
435
|
+
alias delete_attachement remove_attachment
|
279
436
|
|
280
437
|
# Remove checklist
|
281
|
-
#
|
438
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
439
|
+
# @param checklist_id [String] the checklist identifier
|
440
|
+
# card = Tacokit.card("aCardId")
|
441
|
+
# checklist = Tacokit.create_checklist(card, "Things")
|
442
|
+
# Tacokit.remove_checklist(card, checklist)
|
282
443
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-checklists-idchecklist
|
283
444
|
def remove_checklist(card_id, checklist_id)
|
284
445
|
delete_card_resource card_id, "checklists", checklist_id
|
285
446
|
end
|
286
|
-
|
447
|
+
alias delete_checklist remove_checklist
|
287
448
|
|
288
449
|
# Remove a member from a card
|
289
|
-
#
|
450
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
451
|
+
# @param member_id [String] the member identifier
|
452
|
+
# @example Remove a member from a card
|
453
|
+
# card = Tacokit.card("aCardId")
|
454
|
+
# member = Tacokit.member("nickname")
|
455
|
+
# Tacokit.remove_card_member(card, member)
|
456
|
+
# @example Remove member by id from a card
|
457
|
+
# Tacokit.remove_card_member("aCardId", "aMemberId")
|
290
458
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-idmembers-idmember
|
291
459
|
def remove_card_member(card_id, member_id)
|
292
|
-
delete_card_resource card_id, "idMembers", member_id
|
460
|
+
delete_card_resource card_id, "idMembers", resource_id(member_id)
|
293
461
|
end
|
294
|
-
|
462
|
+
alias delete_card_member remove_card_member
|
295
463
|
|
296
464
|
# Remove label from card
|
297
|
-
#
|
465
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
466
|
+
# @param color [String] color of label to remove
|
467
|
+
# @example Remove label from card
|
468
|
+
# Tacokit.remove_label("aCardId", "red", name: "Overdue")
|
298
469
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-labels-color
|
299
470
|
def remove_label(card_id, color)
|
300
471
|
delete_card_resource card_id, "labels", color
|
301
472
|
end
|
302
|
-
|
473
|
+
alias delete_label remove_label
|
303
474
|
|
304
475
|
# Remove a vote from a card
|
305
|
-
#
|
476
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
477
|
+
# @param member_id [String] the member identifier
|
478
|
+
# @example Remove member's vote from a card
|
479
|
+
# member = Tacokit.member("rossta")
|
480
|
+
# Tacokit.remove_vote("aCardId", member)
|
306
481
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-membersvoted-idmember
|
307
482
|
def remove_vote(card_id, member_id)
|
308
|
-
delete_card_resource card_id, "membersVoted", member_id
|
483
|
+
delete_card_resource card_id, "membersVoted", resource_id(member_id)
|
309
484
|
end
|
310
|
-
|
485
|
+
alias delete_vote remove_vote
|
311
486
|
|
312
487
|
# Remove a sticker from a card
|
313
|
-
#
|
488
|
+
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
|
489
|
+
# @param sticker_id [String] the sticker identifier
|
490
|
+
# @example Remove sticker from card with optional positioning
|
491
|
+
# sticker = Tacokit.add_sticker("aCardId", "star")
|
492
|
+
# Tacokit.remove_sticker("aCardId", sticker)
|
314
493
|
# @see https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-membersvoted-idmember
|
315
494
|
def remove_sticker(card_id, sticker_id)
|
316
|
-
delete_card_resource card_id, "stickers", sticker_id
|
495
|
+
delete_card_resource card_id, "stickers", resource_id(sticker_id)
|
317
496
|
end
|
318
|
-
|
497
|
+
alias delete_sticker remove_sticker
|
319
498
|
|
320
499
|
private
|
321
500
|
|