ruby-trello 2.0.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +106 -17
- data/lib/trello.rb +47 -34
- data/lib/trello/action.rb +10 -8
- data/lib/trello/association_builder/has_many.rb +17 -0
- data/lib/trello/association_builder/has_one.rb +16 -0
- data/lib/trello/association_fetcher/has_many.rb +26 -0
- data/lib/trello/association_fetcher/has_many/fetch.rb +47 -0
- data/lib/trello/association_fetcher/has_many/params.rb +56 -0
- data/lib/trello/association_fetcher/has_one.rb +25 -0
- data/lib/trello/association_fetcher/has_one/fetch.rb +49 -0
- data/lib/trello/association_fetcher/has_one/params.rb +36 -0
- data/lib/trello/association_infer_tool.rb +13 -0
- data/lib/trello/association_proxy.rb +1 -1
- data/lib/trello/attachment.rb +13 -10
- data/lib/trello/basic_data.rb +16 -49
- data/lib/trello/board.rb +17 -3
- data/lib/trello/card.rb +103 -38
- data/lib/trello/checklist.rb +14 -13
- data/lib/trello/client.rb +1 -1
- data/lib/trello/comment.rb +4 -4
- data/lib/trello/custom_field.rb +131 -0
- data/lib/trello/custom_field_item.rb +98 -0
- data/lib/trello/custom_field_option.rb +22 -0
- data/lib/trello/error.rb +12 -0
- data/lib/trello/item.rb +7 -7
- data/lib/trello/item_state.rb +3 -3
- data/lib/trello/label.rb +30 -12
- data/lib/trello/label_name.rb +10 -10
- data/lib/trello/list.rb +6 -6
- data/lib/trello/member.rb +10 -9
- data/lib/trello/notification.rb +6 -6
- data/lib/trello/organization.rb +11 -11
- data/lib/trello/plugin_datum.rb +6 -6
- data/lib/trello/register_attributes.rb +54 -0
- data/lib/trello/token.rb +6 -5
- data/lib/trello/webhook.rb +5 -5
- data/spec/action_spec.rb +22 -1
- data/spec/basic_data_spec.rb +58 -0
- data/spec/board_spec.rb +28 -2
- data/spec/card_spec.rb +183 -8
- data/spec/cassettes/can_add_a_file_from_url_on_a_card.yml +189 -0
- data/spec/cassettes/can_add_a_file_on_a_card.yml +200 -0
- data/spec/cassettes/can_add_a_member_to_a_card.yml +190 -0
- data/spec/cassettes/can_add_label_on_a_card.yml +281 -0
- data/spec/cassettes/can_close_bong_a_card.yml +189 -0
- data/spec/cassettes/can_get_actions.yml +196 -0
- data/spec/cassettes/can_get_attachments.yml +187 -0
- data/spec/cassettes/can_get_comments.yml +193 -0
- data/spec/cassettes/can_move_a_card_to_another_board_with_specific_list.yml +373 -0
- data/spec/cassettes/can_move_a_card_to_another_board_without_specific_list.yml +281 -0
- data/spec/cassettes/can_move_a_card_to_another_list.yml +281 -0
- data/spec/cassettes/can_remove_a_member_from_a_card.yml +185 -0
- data/spec/cassettes/can_remove_an_attachment_on_a_card.yml +277 -0
- data/spec/cassettes/can_remove_an_upvote_on_a_card.yml +465 -0
- data/spec/cassettes/can_remove_label_on_a_card.yml +279 -0
- data/spec/cassettes/can_success_add_comment_to_a_card.yml +196 -0
- data/spec/cassettes/can_success_copy_checklist_to_a_card.yml +281 -0
- data/spec/cassettes/can_success_copy_checklist_to_a_card_without_name_pos.yml +281 -0
- data/spec/cassettes/can_success_create_a_card.yml +99 -0
- data/spec/cassettes/can_success_create_new_checklist_to_a_card.yml +189 -0
- data/spec/cassettes/can_success_delete_card.yml +185 -0
- data/spec/cassettes/can_success_upate_a_card.yml +189 -0
- data/spec/cassettes/can_success_update_bong_a_board.yml +283 -0
- data/spec/cassettes/can_success_update_bong_a_card.yml +191 -0
- data/spec/cassettes/can_upvote_on_a_card.yml +469 -0
- data/spec/cassettes/card_find_with_id_and_get_all_fields.yml +95 -0
- data/spec/cassettes/card_find_with_id_and_get_specific_fields.yml +96 -0
- data/spec/cassettes/custom_field_item_save_1.yml +97 -0
- data/spec/cassettes/custom_field_item_save_2.yml +281 -0
- data/spec/cassettes/get_board_of_card.yml +187 -0
- data/spec/cassettes/get_check_item_states_of_card.yml +188 -0
- data/spec/cassettes/get_checklists_of_card.yml +187 -0
- data/spec/cassettes/get_cover_image_of_card.yml +187 -0
- data/spec/cassettes/get_custom_field_items_of_card.yml +187 -0
- data/spec/cassettes/get_list_of_card.yml +188 -0
- data/spec/cassettes/get_lists.yml +187 -0
- data/spec/cassettes/get_members_of_card.yml +189 -0
- data/spec/cassettes/get_plugin_data_of_card.yml +187 -0
- data/spec/cassettes/get_voters_of_card.yml +188 -0
- data/spec/cassettes/remove_upvote_on_a_card_when_have_not_voted.yml +366 -0
- data/spec/cassettes/revote_on_a_card.yml +464 -0
- data/spec/checklist_spec.rb +39 -3
- data/spec/client_spec.rb +5 -1
- data/spec/custom_field_item_spec.rb +192 -0
- data/spec/custom_field_option_spec.rb +49 -0
- data/spec/custom_field_spec.rb +261 -0
- data/spec/integration/basic_data/many_spec.rb +123 -0
- data/spec/integration/basic_data/one_spec.rb +84 -0
- data/spec/integration/basic_data/register_attributes_spec.rb +75 -0
- data/spec/integration/board/update!_spec.rb +31 -0
- data/spec/integration/board_lists_spec.rb +21 -0
- data/spec/integration/card/add_and_remove_attachment_spec.rb +45 -0
- data/spec/integration/card/add_and_remove_label_spec.rb +35 -0
- data/spec/integration/card/add_checklist_spec.rb +32 -0
- data/spec/integration/card/add_comment_spec.rb +19 -0
- data/spec/integration/card/add_memeber_spec.rb +19 -0
- data/spec/integration/card/associations/actions_spec.rb +17 -0
- data/spec/integration/card/associations/attachments_spec.rb +18 -0
- data/spec/integration/card/associations/board_spec.rb +17 -0
- data/spec/integration/card/associations/check_item_states_spec.rb +17 -0
- data/spec/integration/card/associations/checklists_spec.rb +18 -0
- data/spec/integration/card/associations/comments_spec.rb +19 -0
- data/spec/integration/card/associations/cover_image_spec.rb +18 -0
- data/spec/integration/card/associations/custom_field_items_spec.rb +18 -0
- data/spec/integration/card/associations/list_spec.rb +16 -0
- data/spec/integration/card/associations/members_spec.rb +18 -0
- data/spec/integration/card/associations/plugin_data_spec.rb +18 -0
- data/spec/integration/card/associations/voters_spec.rb +17 -0
- data/spec/integration/card/close!_spec.rb +16 -0
- data/spec/integration/card/create_new_check_list_spec.rb +19 -0
- data/spec/integration/card/create_spec.rb +50 -0
- data/spec/integration/card/delete_spec.rb +16 -0
- data/spec/integration/card/find_spec.rb +67 -0
- data/spec/integration/card/move_to_board_spec.rb +36 -0
- data/spec/integration/card/move_to_list_spec.rb +20 -0
- data/spec/integration/card/remove_member_spec.rb +19 -0
- data/spec/integration/card/save_spec.rb +61 -0
- data/spec/integration/card/update!_spec.rb +53 -0
- data/spec/integration/card/vote_spec.rb +50 -0
- data/spec/integration/custom_field_item_spec.rb +47 -0
- data/spec/item_spec.rb +20 -0
- data/spec/label_spec.rb +99 -0
- data/spec/list_spec.rb +21 -0
- data/spec/member_spec.rb +23 -0
- data/spec/notification_spec.rb +21 -0
- data/spec/organization_spec.rb +26 -0
- data/spec/spec_helper.rb +96 -23
- data/spec/token_spec.rb +19 -0
- data/spec/unit/trello/association_builder/has_many_spec.rb +36 -0
- data/spec/unit/trello/association_builder/has_one_spec.rb +36 -0
- data/spec/unit/trello/association_fetcher/has_many/fetch_spec.rb +38 -0
- data/spec/unit/trello/association_fetcher/has_many/params_spec.rb +107 -0
- data/spec/unit/trello/association_fetcher/has_many_spec.rb +50 -0
- data/spec/unit/trello/association_fetcher/has_one/fetch_spec.rb +51 -0
- data/spec/unit/trello/association_fetcher/has_one/params_spec.rb +81 -0
- data/spec/unit/trello/association_fetcher/has_one_spec.rb +49 -0
- data/spec/unit/trello/association_infer_tool_spec.rb +41 -0
- data/spec/unit/trello/basic_data_spec.rb +54 -0
- data/spec/unit/trello/card_spec.rb +103 -0
- data/spec/webhook_spec.rb +20 -0
- metadata +224 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e7396e189c2f3b43af4bf1eacbdd78ec358ef684d2526d7c3537c1af1ca4abd
|
4
|
+
data.tar.gz: c8e2c74d10eaedb521829b3598e4500119c8fbfdd8c8cd71758254580eee1079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d441be6f124b3dd47ff332da22ccbf71eb201ff90ddf82775fc3f208eb6621dd10acc2cff21c81d30231d9b50f4aa9cf867cf66d26e9c894e16f1a1596a11fa
|
7
|
+
data.tar.gz: 647e16d5104ba1cf8dc3a7811117f168d6e132503e4b0989e8316a8abd9b30f3401cc04814da202cb4fc74846c5b9dee88a80fc36358fa0cd9c5f65340aba97b
|
data/README.md
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
# Ruby Trello API
|
2
2
|
|
3
|
-
[](http://travis-ci.org/jeremytregunna/ruby-trello)
|
4
|
+
[](https://hakiri.io/github/jeremytregunna/ruby-trello/master)
|
5
5
|
[](https://codeclimate.com/github/jeremytregunna/ruby-trello)
|
6
6
|
|
7
|
-
This library implements the [Trello](http://www.trello.com/) [API](
|
7
|
+
This library implements the [Trello](http://www.trello.com/) [API](https://developers.trello.com/).
|
8
8
|
|
9
9
|
Trello is an awesome tool for organization. Not just aimed at developers, but everybody.
|
10
10
|
Seriously, [check it out](http://www.trello.com/).
|
11
11
|
|
12
12
|
[Full API documentation](http://www.rubydoc.info/gems/ruby-trello).
|
13
13
|
|
14
|
+
Full Disclosure: This library is mostly complete, if you do find anything missing or not functioning as you expect it
|
15
|
+
to, please just [create an issue](https://github.com/jeremytregunna/ruby-trello/issues/new).
|
16
|
+
|
17
|
+
## Requirements
|
18
|
+
|
19
|
+
Use the newest version for Ruby 2.5.0 or newer support.
|
20
|
+
Use version 2.2.1 or earlier for Ruby 2.1 ~ 2.4 support.
|
21
|
+
Use version 1.3.0 or earlier for Ruby 1.9.3 support.
|
22
|
+
Use version 1.4.x or earlier for Ruby 2.0.0 support.
|
23
|
+
|
14
24
|
## Installation
|
15
25
|
|
16
26
|
```
|
17
27
|
# gem install ruby-trello
|
18
28
|
```
|
19
29
|
|
20
|
-
Full Disclosure: This library is mostly complete, if you do find anything missing or not functioning as you expect it
|
21
|
-
to, please [let us know](https://trello.com/card/spot-a-bug-report-it/4f092b2ee23cb6fe6d1aaabd/17).
|
22
|
-
|
23
|
-
Supports Ruby 2.1.0 or newer.
|
24
|
-
|
25
|
-
Use version 1.3.0 or earlier for ruby 1.9.3 support.
|
26
|
-
Use version 1.4.x or earlier for ruby 2.0.0 support.
|
27
|
-
|
28
30
|
## Configuration
|
29
31
|
|
30
|
-
####Basic authorization:
|
32
|
+
#### Basic authorization:
|
31
33
|
|
32
|
-
1. Get your API public key from Trello via the irb console:
|
34
|
+
1. Get your API public key from Trello via [trello.com/app-key/](https://trello.com/app-key/) or the irb console as follows:
|
33
35
|
|
34
36
|
```
|
35
37
|
$ gem install ruby-trello
|
@@ -50,7 +52,7 @@ Trello.configure do |config|
|
|
50
52
|
end
|
51
53
|
```
|
52
54
|
|
53
|
-
####2-legged OAuth authorization
|
55
|
+
#### 2-legged OAuth authorization
|
54
56
|
|
55
57
|
```ruby
|
56
58
|
Trello.configure do |config|
|
@@ -61,7 +63,7 @@ Trello.configure do |config|
|
|
61
63
|
end
|
62
64
|
```
|
63
65
|
|
64
|
-
####3-legged OAuth authorization
|
66
|
+
#### 3-legged OAuth authorization
|
65
67
|
|
66
68
|
```ruby
|
67
69
|
Trello.configure do |config|
|
@@ -72,18 +74,67 @@ Trello.configure do |config|
|
|
72
74
|
end
|
73
75
|
```
|
74
76
|
|
75
|
-
All the calls this library
|
77
|
+
All the calls this library makes to Trello require authentication using these keys. Be sure to protect them.
|
78
|
+
|
79
|
+
#### Usage
|
76
80
|
|
77
|
-
So
|
81
|
+
So let's say you want to get information about the user *bobtester*. We can do something like this:
|
78
82
|
|
79
83
|
```ruby
|
80
84
|
bob = Trello::Member.find("bobtester")
|
85
|
+
|
81
86
|
# Print out his name
|
82
87
|
puts bob.full_name # "Bob Tester"
|
88
|
+
|
83
89
|
# Print his bio
|
84
90
|
puts bob.bio # A wonderfully delightful test user
|
91
|
+
|
85
92
|
# How about a list of his boards?
|
86
93
|
bob.boards
|
94
|
+
|
95
|
+
# And then to read the lists of the first board do :
|
96
|
+
bob.boards.first.lists
|
97
|
+
```
|
98
|
+
|
99
|
+
##### Accessing specific items
|
100
|
+
|
101
|
+
There is no find by name method in the trello API, to access a specific item, you have to know it's ID.
|
102
|
+
The best way is to pretty print the elements and then find the id of the element you are looking for.
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
# With bob
|
106
|
+
pp bob.boards # Will pretty print all boards, allowing us to find our board id
|
107
|
+
|
108
|
+
# We can now access it's lists
|
109
|
+
pp Trello::Board.find( board_id ).lists # will pretty print all lists. Let's get the list id
|
110
|
+
|
111
|
+
# We can now access the cards of the list
|
112
|
+
pp Trello::List.find( list_id ).cards
|
113
|
+
|
114
|
+
# We can now access the checklists of the card
|
115
|
+
pp Trello::Card.find( card_id ).checklists
|
116
|
+
|
117
|
+
# and so on ...
|
118
|
+
```
|
119
|
+
|
120
|
+
##### Changing a checkbox state
|
121
|
+
```ruby
|
122
|
+
# First get your checklist id
|
123
|
+
checklist = Trello::Checklist.find( checklist_id )
|
124
|
+
|
125
|
+
# At this point, there is no more ids. To get your checklist item,
|
126
|
+
# you have to know it's position (same as in the trello interface).
|
127
|
+
# Let's take the first
|
128
|
+
checklist_item = checklist.items.first
|
129
|
+
|
130
|
+
# Then we can read the status
|
131
|
+
checklist_item.state # return 'complete' or 'incomplete'
|
132
|
+
|
133
|
+
# We can update it (note we call update_item_state from checklist, not from checklist_item)
|
134
|
+
checklist.update_item_state( checklist_item.id, 'complete' ) # or 'incomplete'
|
135
|
+
|
136
|
+
# You can also use true or false instead of 'complete' or 'incomplete'
|
137
|
+
checklist.update_item_state( checklist_item.id, true ) # or false
|
87
138
|
```
|
88
139
|
|
89
140
|
#### Multiple Users
|
@@ -131,3 +182,41 @@ Several ways you can contribute. Documentation, code, tests, feature requests, b
|
|
131
182
|
If you submit a pull request that's accepted, you'll be given commit access to this repository.
|
132
183
|
|
133
184
|
Please see the `CONTRIBUTING.md` file for more information.
|
185
|
+
|
186
|
+
## Local Development
|
187
|
+
|
188
|
+
Init all Gemfile.lock.* files
|
189
|
+
|
190
|
+
```bash
|
191
|
+
make init
|
192
|
+
```
|
193
|
+
|
194
|
+
Bundle install for all Ruby versions
|
195
|
+
|
196
|
+
```bash
|
197
|
+
make bundle:all
|
198
|
+
```
|
199
|
+
|
200
|
+
Run tests for all Ruby versions
|
201
|
+
|
202
|
+
```bash
|
203
|
+
make test:all
|
204
|
+
```
|
205
|
+
|
206
|
+
Run tests for each Ruby versions individual
|
207
|
+
|
208
|
+
```bash
|
209
|
+
make test:ruby_2_5
|
210
|
+
make test:ruby_2_6
|
211
|
+
make test:ruby_2_7
|
212
|
+
make test:jruby_9_2
|
213
|
+
```
|
214
|
+
|
215
|
+
Do development for each Ruby versions individual
|
216
|
+
|
217
|
+
```bash
|
218
|
+
make dev:ruby_2_5
|
219
|
+
make dev:ruby_2_6
|
220
|
+
make dev:ruby_2_7
|
221
|
+
make dev:jruby_9_2
|
222
|
+
```
|
data/lib/trello.rb
CHANGED
@@ -37,47 +37,60 @@ require 'addressable/uri'
|
|
37
37
|
#
|
38
38
|
# Feel free to {peruse and participate in our Trello board}[https://trello.com/board/ruby-trello/4f092b2ee23cb6fe6d1aaabd]. It's completely open to the public.
|
39
39
|
module Trello
|
40
|
-
autoload :
|
41
|
-
autoload :
|
42
|
-
autoload :
|
43
|
-
autoload :
|
44
|
-
autoload :
|
45
|
-
autoload :
|
46
|
-
autoload :
|
47
|
-
autoload :
|
48
|
-
autoload :
|
49
|
-
autoload :
|
50
|
-
autoload :
|
51
|
-
autoload :
|
52
|
-
autoload :
|
53
|
-
autoload :
|
54
|
-
autoload :
|
55
|
-
autoload :
|
56
|
-
autoload :
|
57
|
-
autoload :
|
58
|
-
autoload :
|
59
|
-
autoload :
|
60
|
-
autoload :
|
61
|
-
autoload :
|
62
|
-
autoload :
|
63
|
-
autoload :
|
64
|
-
autoload :
|
65
|
-
autoload :
|
66
|
-
autoload :
|
67
|
-
autoload :
|
40
|
+
autoload :Error, 'trello/error'
|
41
|
+
autoload :Action, 'trello/action'
|
42
|
+
autoload :Comment, 'trello/comment'
|
43
|
+
autoload :Association, 'trello/association'
|
44
|
+
autoload :AssociationProxy, 'trello/association_proxy'
|
45
|
+
autoload :Attachment, 'trello/attachment'
|
46
|
+
autoload :CoverImage, 'trello/cover_image'
|
47
|
+
autoload :BasicData, 'trello/basic_data'
|
48
|
+
autoload :Board, 'trello/board'
|
49
|
+
autoload :Card, 'trello/card'
|
50
|
+
autoload :Checklist, 'trello/checklist'
|
51
|
+
autoload :Client, 'trello/client'
|
52
|
+
autoload :Configuration, 'trello/configuration'
|
53
|
+
autoload :CustomField, 'trello/custom_field'
|
54
|
+
autoload :CustomFieldItem, 'trello/custom_field_item'
|
55
|
+
autoload :CustomFieldOption, 'trello/custom_field_option'
|
56
|
+
autoload :HasActions, 'trello/has_actions'
|
57
|
+
autoload :Item, 'trello/item'
|
58
|
+
autoload :CheckItemState, 'trello/item_state'
|
59
|
+
autoload :Label, 'trello/label'
|
60
|
+
autoload :LabelName, 'trello/label_name'
|
61
|
+
autoload :List, 'trello/list'
|
62
|
+
autoload :Member, 'trello/member'
|
63
|
+
autoload :MultiAssociation, 'trello/multi_association'
|
64
|
+
autoload :Notification, 'trello/notification'
|
65
|
+
autoload :Organization, 'trello/organization'
|
66
|
+
autoload :PluginDatum, 'trello/plugin_datum'
|
67
|
+
autoload :Request, 'trello/net'
|
68
|
+
autoload :TInternet, 'trello/net'
|
69
|
+
autoload :Token, 'trello/token'
|
70
|
+
autoload :Webhook, 'trello/webhook'
|
71
|
+
autoload :JsonUtils, 'trello/json_utils'
|
72
|
+
autoload :AssociationInferTool, 'trello/association_infer_tool'
|
73
|
+
autoload :RegisterAttributes, 'trello/register_attributes'
|
68
74
|
|
69
75
|
module Authorization
|
70
|
-
autoload :AuthPolicy,
|
71
|
-
autoload :BasicAuthPolicy,
|
72
|
-
autoload :OAuthPolicy,
|
76
|
+
autoload :AuthPolicy, 'trello/authorization'
|
77
|
+
autoload :BasicAuthPolicy, 'trello/authorization'
|
78
|
+
autoload :OAuthPolicy, 'trello/authorization'
|
79
|
+
end
|
80
|
+
|
81
|
+
module AssociationFetcher
|
82
|
+
autoload :HasMany, 'trello/association_fetcher/has_many'
|
83
|
+
autoload :HasOne, 'trello/association_fetcher/has_one'
|
84
|
+
end
|
85
|
+
|
86
|
+
module AssociationBuilder
|
87
|
+
autoload :HasMany, 'trello/association_builder/has_many'
|
88
|
+
autoload :HasOne, 'trello/association_builder/has_one'
|
73
89
|
end
|
74
90
|
|
75
91
|
# Version of the Trello API that we use by default.
|
76
92
|
API_VERSION = 1
|
77
93
|
|
78
|
-
# Raise this when we hit a Trello error.
|
79
|
-
Error = Class.new(StandardError)
|
80
|
-
|
81
94
|
# This specific error is thrown when your access token is invalid. You should get a new one.
|
82
95
|
InvalidAccessToken = Class.new(Error)
|
83
96
|
|
data/lib/trello/action.rb
CHANGED
@@ -38,12 +38,12 @@ module Trello
|
|
38
38
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
39
39
|
# an Action.
|
40
40
|
def update_fields(fields)
|
41
|
-
attributes[:id] = fields['id']
|
42
|
-
attributes[:type] = fields['type']
|
43
|
-
attributes[:data] = fields['data']
|
44
|
-
attributes[:date] = Time.iso8601(fields['date'])
|
45
|
-
attributes[:member_creator_id] = fields['idMemberCreator']
|
46
|
-
attributes[:member_participant] = fields['member']
|
41
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
42
|
+
attributes[:type] = fields['type'] || attributes[:type]
|
43
|
+
attributes[:data] = fields['data'] || attributes[:data]
|
44
|
+
attributes[:date] = Time.iso8601(fields['date']) rescue nil if fields.has_key?('date')
|
45
|
+
attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id]
|
46
|
+
attributes[:member_participant] = fields['member'] || attributes[:member_participant]
|
47
47
|
self
|
48
48
|
end
|
49
49
|
|
@@ -62,7 +62,9 @@ module Trello
|
|
62
62
|
List.from_response client.get("/actions/#{id}/list")
|
63
63
|
end
|
64
64
|
|
65
|
-
# Returns the
|
66
|
-
|
65
|
+
# Returns the list the action occurred on.
|
66
|
+
def member_creator
|
67
|
+
Member.from_response client.get("/actions/#{id}/memberCreator")
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Trello
|
2
|
+
module AssociationBuilder
|
3
|
+
class HasMany
|
4
|
+
class << self
|
5
|
+
def build(model_klass, name, options)
|
6
|
+
model_klass.class_eval do
|
7
|
+
define_method(name) do |*args|
|
8
|
+
has_many_fetcher = AssociationFetcher::HasMany.new(self, name, options)
|
9
|
+
filter_params = args[0] || {}
|
10
|
+
has_many_fetcher.fetch(filter_params)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Trello
|
2
|
+
module AssociationBuilder
|
3
|
+
class HasOne
|
4
|
+
class << self
|
5
|
+
def build(model_klass, name, options)
|
6
|
+
model_klass.class_eval do
|
7
|
+
define_method(name) do |*args|
|
8
|
+
has_one_fetcher = AssociationFetcher::HasOne.new(self, name, options)
|
9
|
+
has_one_fetcher.fetch
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Trello
|
2
|
+
module AssociationFetcher
|
3
|
+
class HasMany
|
4
|
+
autoload :Params, 'trello/association_fetcher/has_many/params'
|
5
|
+
autoload :Fetch, 'trello/association_fetcher/has_many/fetch'
|
6
|
+
|
7
|
+
attr_reader :model, :name, :options
|
8
|
+
|
9
|
+
def initialize(model, name, options)
|
10
|
+
@model = model
|
11
|
+
@name = name
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch(filter_params)
|
16
|
+
params = Params.new(
|
17
|
+
association_owner: model,
|
18
|
+
association_name: name,
|
19
|
+
association_options: options,
|
20
|
+
filter: filter_params
|
21
|
+
)
|
22
|
+
Fetch.execute(params)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Trello
|
2
|
+
module AssociationFetcher
|
3
|
+
class HasMany
|
4
|
+
class Fetch
|
5
|
+
class << self
|
6
|
+
def execute(params)
|
7
|
+
new(params).execute
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :params
|
12
|
+
|
13
|
+
def initialize(params)
|
14
|
+
@params = params
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute
|
18
|
+
resources = client.find_many(association_class, path, filter_params)
|
19
|
+
|
20
|
+
MultiAssociation.new(association_owner, resources).proxy
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def client
|
26
|
+
association_owner.client
|
27
|
+
end
|
28
|
+
|
29
|
+
def association_class
|
30
|
+
params.association_class
|
31
|
+
end
|
32
|
+
|
33
|
+
def path
|
34
|
+
params.fetch_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def filter_params
|
38
|
+
params.filter_params
|
39
|
+
end
|
40
|
+
|
41
|
+
def association_owner
|
42
|
+
params.association_owner
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Trello
|
2
|
+
module AssociationFetcher
|
3
|
+
class HasMany
|
4
|
+
class Params
|
5
|
+
attr_reader :association_owner
|
6
|
+
|
7
|
+
def initialize(association_owner:, association_name:, association_options:, filter:)
|
8
|
+
@association_owner = association_owner
|
9
|
+
@association_name = association_name
|
10
|
+
@association_options = association_options || {}
|
11
|
+
@filter = filter || {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def association_class
|
15
|
+
association_options[:via] || infer_class_on(association_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_path
|
19
|
+
"/#{parent_restful_resource}/#{parent_restful_resource_id}/#{target_restful_resource}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter_params
|
23
|
+
default_filter.merge(filter)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :association_name, :association_options, :filter
|
29
|
+
|
30
|
+
def default_filter
|
31
|
+
association_options.reject { |k, _| %w[via in path].include?(k.to_s) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def parent_restful_resource
|
35
|
+
association_options[:in] || infer_restful_resource_on(association_owner.class)
|
36
|
+
end
|
37
|
+
|
38
|
+
def parent_restful_resource_id
|
39
|
+
association_owner.id
|
40
|
+
end
|
41
|
+
|
42
|
+
def target_restful_resource
|
43
|
+
association_options[:path] || association_name
|
44
|
+
end
|
45
|
+
|
46
|
+
def infer_restful_resource_on(klass)
|
47
|
+
AssociationInferTool.infer_restful_resource_on_class(klass)
|
48
|
+
end
|
49
|
+
|
50
|
+
def infer_class_on(name)
|
51
|
+
AssociationInferTool.infer_class_on_name(name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|