trelloapi 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/trello.rb +163 -0
- data/lib/trello/.DS_Store +0 -0
- data/lib/trello/action.rb +68 -0
- data/lib/trello/association.rb +14 -0
- data/lib/trello/association_proxy.rb +42 -0
- data/lib/trello/attachment.rb +40 -0
- data/lib/trello/authorization.rb +187 -0
- data/lib/trello/basic_data.rb +132 -0
- data/lib/trello/board.rb +201 -0
- data/lib/trello/card.rb +456 -0
- data/lib/trello/checklist.rb +142 -0
- data/lib/trello/client.rb +120 -0
- data/lib/trello/comment.rb +62 -0
- data/lib/trello/configuration.rb +68 -0
- data/lib/trello/core_ext/array.rb +6 -0
- data/lib/trello/core_ext/hash.rb +6 -0
- data/lib/trello/core_ext/string.rb +6 -0
- data/lib/trello/cover_image.rb +8 -0
- data/lib/trello/has_actions.rb +9 -0
- data/lib/trello/item.rb +37 -0
- data/lib/trello/item_state.rb +30 -0
- data/lib/trello/json_utils.rb +64 -0
- data/lib/trello/label.rb +108 -0
- data/lib/trello/label_name.rb +31 -0
- data/lib/trello/list.rb +114 -0
- data/lib/trello/member.rb +112 -0
- data/lib/trello/multi_association.rb +12 -0
- data/lib/trello/net.rb +39 -0
- data/lib/trello/notification.rb +61 -0
- data/lib/trello/organization.rb +68 -0
- data/lib/trello/plugin_datum.rb +34 -0
- data/lib/trello/token.rb +36 -0
- data/lib/trello/webhook.rb +103 -0
- data/trello.gemspec +41 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a89d64837e9b2bc936cc9f3fee936cd9365971e0
|
4
|
+
data.tar.gz: a7379092b6920e501fff88cb3b1a152461519fab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0061b9a96225188842596cf08ef96c46f45166e29aa5bfbb83f0ca9f491f72e8f254d905f1d147e37298c2c645ce51cc9b8cfe1ec1344376ddcc80569082cb55
|
7
|
+
data.tar.gz: 46e91945e657a98cd2bd0a3a58c30e13017d9ea0135ec4d4daaf756c62df48cf0e8e671719e2e78bad6839181ab67309661e1d60eef9aac8a2b2bc3326557dfa
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 nuc
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Trello
|
2
|
+
|
3
|
+
This is a copy of ruby-trello gem repo with small changes (new Trello functionallty added)
|
4
|
+
WARNING this gem will be deleted on next ruby-trello update, so pleas do not use it in your project as a dependency
|
5
|
+
use https://rubygems.org/gems/ruby-trello instead
|
6
|
+
|
7
|
+
|
8
|
+
## License
|
9
|
+
|
10
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
11
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "trello"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/trello.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
require 'json'
|
3
|
+
require 'logger'
|
4
|
+
require 'active_model'
|
5
|
+
require 'addressable/uri'
|
6
|
+
|
7
|
+
# Ruby wrapper around the Trello[http://trello.com] API
|
8
|
+
#
|
9
|
+
# First, set up your key information. You can get this information by {clicking here}[https://trello.com/1/appKey/generate].
|
10
|
+
#
|
11
|
+
# You can get the key by going to this url in your browser:
|
12
|
+
# https://trello.com/1/authorize?key=TRELLO_CONSUMER_KEY_FROM_ABOVE&name=MyApp&response_type=token&scope=read,write,account&expiration=never
|
13
|
+
# Only request the permissions you need; i.e., scope=read if you only need read, or scope=write if you only need write. Comma separate scopes you need.
|
14
|
+
# If you want your token to expire after 30 days, drop the &expiration=never. Then run the following code, where KEY denotes the key returned from the
|
15
|
+
# url above:
|
16
|
+
#
|
17
|
+
# Trello.configure do |config|
|
18
|
+
# config.consumer_key = TRELLO_CONSUMER_KEY
|
19
|
+
# config.consumer_secret = TRELLO_CONSUMER_SECRET
|
20
|
+
# config.oauth_token = TRELLO_OAUTH_TOKEN
|
21
|
+
# config.oauth_token_secret = TRELLO_OAUTH_TOKEN_SECRET
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# All the calls this library make to Trello require authentication using these keys. Be sure to protect them.
|
25
|
+
#
|
26
|
+
# So lets say you want to get information about the user *bobtester*. We can do something like this:
|
27
|
+
#
|
28
|
+
# bob = Member.find("bobtester")
|
29
|
+
# # Print out his name
|
30
|
+
# puts bob.full_name # "Bob Tester"
|
31
|
+
# # Print his bio
|
32
|
+
# puts bob.bio # A wonderfully delightful test user
|
33
|
+
# # How about a list of his boards?
|
34
|
+
# bob.boards
|
35
|
+
#
|
36
|
+
# And so much more. Consult the rest of the documentation for more information.
|
37
|
+
#
|
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
|
+
module Trello
|
40
|
+
autoload :Action, 'trello/action'
|
41
|
+
autoload :Comment, 'trello/comment'
|
42
|
+
autoload :Association, 'trello/association'
|
43
|
+
autoload :AssociationProxy, 'trello/association_proxy'
|
44
|
+
autoload :Attachment, 'trello/attachment'
|
45
|
+
autoload :CoverImage, 'trello/cover_image'
|
46
|
+
autoload :BasicData, 'trello/basic_data'
|
47
|
+
autoload :Board, 'trello/board'
|
48
|
+
autoload :Card, 'trello/card'
|
49
|
+
autoload :Checklist, 'trello/checklist'
|
50
|
+
autoload :Client, 'trello/client'
|
51
|
+
autoload :Configuration, 'trello/configuration'
|
52
|
+
autoload :HasActions, 'trello/has_actions'
|
53
|
+
autoload :Item, 'trello/item'
|
54
|
+
autoload :CheckItemState, 'trello/item_state'
|
55
|
+
autoload :Label, 'trello/label'
|
56
|
+
autoload :LabelName, 'trello/label_name'
|
57
|
+
autoload :List, 'trello/list'
|
58
|
+
autoload :Member, 'trello/member'
|
59
|
+
autoload :MultiAssociation, 'trello/multi_association'
|
60
|
+
autoload :Notification, 'trello/notification'
|
61
|
+
autoload :Organization, 'trello/organization'
|
62
|
+
autoload :PluginDatum, 'trello/plugin_datum'
|
63
|
+
autoload :Request, 'trello/net'
|
64
|
+
autoload :TInternet, 'trello/net'
|
65
|
+
autoload :Token, 'trello/token'
|
66
|
+
autoload :Webhook, 'trello/webhook'
|
67
|
+
autoload :JsonUtils, 'trello/json_utils'
|
68
|
+
|
69
|
+
module Authorization
|
70
|
+
autoload :AuthPolicy, 'trello/authorization'
|
71
|
+
autoload :BasicAuthPolicy, 'trello/authorization'
|
72
|
+
autoload :OAuthPolicy, 'trello/authorization'
|
73
|
+
end
|
74
|
+
|
75
|
+
# Version of the Trello API that we use by default.
|
76
|
+
API_VERSION = 1
|
77
|
+
|
78
|
+
# Raise this when we hit a Trello error.
|
79
|
+
Error = Class.new(StandardError)
|
80
|
+
|
81
|
+
# This specific error is thrown when your access token is invalid. You should get a new one.
|
82
|
+
InvalidAccessToken = Class.new(Error)
|
83
|
+
|
84
|
+
# This error is thrown when your client has not been configured
|
85
|
+
ConfigurationError = Class.new(Error)
|
86
|
+
|
87
|
+
def self.logger
|
88
|
+
@logger ||= Logger.new(STDOUT)
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.logger=(logger)
|
92
|
+
@logger = logger
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.client
|
96
|
+
@client ||= Client.new
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.configure(&block)
|
100
|
+
reset!
|
101
|
+
client.configure(&block)
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.reset!
|
105
|
+
@client = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.auth_policy; client.auth_policy; end
|
109
|
+
def self.configuration; client.configuration; end
|
110
|
+
|
111
|
+
# Url to Trello API public key page
|
112
|
+
def self.public_key_url
|
113
|
+
'https://trello.com/app-key'
|
114
|
+
end
|
115
|
+
|
116
|
+
# Url to token for making authorized requests to the Trello API
|
117
|
+
#
|
118
|
+
# @param [String, #read] contents the contents to reverse
|
119
|
+
# @param options [Hash] Repository information to update
|
120
|
+
# @option options [String] :name Name of the application
|
121
|
+
# @option options [String] :key Application key
|
122
|
+
# @option options [String] :response_type 'token'
|
123
|
+
# @option options [String] :callback_method 'postMessage' or 'fragment'
|
124
|
+
# @option options [String] :return_url URL the token should be returned to
|
125
|
+
# @option options [String] :scope Comma-separated list of one or more of 'read', 'write', 'account'
|
126
|
+
# @option options [String] :expiration '1hour', '1day', '30days', 'never'
|
127
|
+
# @see https://developers.trello.com/authorize
|
128
|
+
def self.authorize_url(options = {})
|
129
|
+
params = options.dup
|
130
|
+
params[:key] ||= configuration.developer_public_key or
|
131
|
+
raise ArgumentError, 'Please configure your Trello public key'
|
132
|
+
params[:name] ||= 'Ruby Trello'
|
133
|
+
params[:scope] ||= 'read,write,account'
|
134
|
+
params[:expiration] ||= 'never'
|
135
|
+
params[:response_type] ||= 'token'
|
136
|
+
uri = Addressable::URI.parse 'https://trello.com/1/authorize'
|
137
|
+
uri.query_values = params
|
138
|
+
uri
|
139
|
+
end
|
140
|
+
|
141
|
+
# Visit the Trello API public key page
|
142
|
+
#
|
143
|
+
# @see https://trello.com/app-key
|
144
|
+
def self.open_public_key_url
|
145
|
+
open_url public_key_url
|
146
|
+
end
|
147
|
+
|
148
|
+
# Visit the Trello authorized token page
|
149
|
+
#
|
150
|
+
# @see https://developers.trello.com/authorize
|
151
|
+
def self.open_authorization_url(options = {})
|
152
|
+
open_url authorize_url(options)
|
153
|
+
end
|
154
|
+
|
155
|
+
# @private
|
156
|
+
def self.open_url(url)
|
157
|
+
require 'launchy'
|
158
|
+
Launchy.open(url.to_s)
|
159
|
+
rescue LoadError
|
160
|
+
warn 'Please install the launchy gem to open the url automatically.'
|
161
|
+
url
|
162
|
+
end
|
163
|
+
end
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Trello
|
2
|
+
# Action represents some event that occurred. For instance, when a card is created.
|
3
|
+
#
|
4
|
+
# @!attribute [r] id
|
5
|
+
# @return [String]
|
6
|
+
# @!attribute [r] type
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] data
|
9
|
+
# @return [Hash]
|
10
|
+
# @!attribute [r] date
|
11
|
+
# @return [Datetime]
|
12
|
+
# @!attribute [r] member_creator_id
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute [r] member_participant
|
15
|
+
# @return [Object]
|
16
|
+
class Action < BasicData
|
17
|
+
register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
|
18
|
+
readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
|
19
|
+
validates_presence_of :id, :type, :date, :member_creator_id
|
20
|
+
|
21
|
+
class << self
|
22
|
+
# Locate a specific action and return a new Action object.
|
23
|
+
def find(id, params = {})
|
24
|
+
client.find(:action, id, params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def search(query, opts = {})
|
28
|
+
response = client.get("/search/", { query: query }.merge(opts))
|
29
|
+
parse_json(response).except("options").each_with_object({}) do |(key, data), result|
|
30
|
+
klass = "Trello::#{key.singularize.capitalize}".constantize
|
31
|
+
result[key] = klass.from_json(data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Update the attributes of an action
|
37
|
+
#
|
38
|
+
# Supply a hash of string keyed data retrieved from the Trello API representing
|
39
|
+
# an Action.
|
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']
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns the board this action occurred on.
|
51
|
+
def board
|
52
|
+
Board.from_response client.get("/actions/#{id}/board")
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns the card the action occurred on.
|
56
|
+
def card
|
57
|
+
Card.from_response client.get("/actions/#{id}/card")
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the list the action occurred on.
|
61
|
+
def list
|
62
|
+
List.from_response client.get("/actions/#{id}/list")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the member who created the action.
|
66
|
+
one :member_creator, via: Member, path: :members, using: :member_creator_id
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Trello
|
2
|
+
class Association
|
3
|
+
attr_reader :owner, :target, :options, :proxy
|
4
|
+
|
5
|
+
def initialize(owner, target)
|
6
|
+
@owner = owner
|
7
|
+
@target = target
|
8
|
+
@options = {}
|
9
|
+
if target.is_a?(Array)
|
10
|
+
target.each { |array_element| array_element.client = owner.client }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
class AssociationProxy
|
5
|
+
extend Forwardable
|
6
|
+
alias :proxy_extend :extend
|
7
|
+
|
8
|
+
instance_methods.each { |m| undef_method m unless m.to_s =~ /^(?:nil\?|send|object_id|to_a)$|^__|^respond_to|proxy_/ }
|
9
|
+
|
10
|
+
def_delegators :@association, :owner, :target, :count
|
11
|
+
|
12
|
+
def initialize(association)
|
13
|
+
@association = association
|
14
|
+
Array(association.options[:extend]).each { |ext| proxy_extend(ext) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def proxy_assocation
|
18
|
+
@association
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method, *args, &block)
|
22
|
+
if target.respond_to? method
|
23
|
+
target.send(method, *args, &block)
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def ===(other)
|
30
|
+
other === target
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_ary
|
34
|
+
proxy_assocation.dup
|
35
|
+
end
|
36
|
+
alias_method :to_a, :to_ary
|
37
|
+
|
38
|
+
def <<(*records)
|
39
|
+
proxy_assocation.concat(records) && self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Trello
|
2
|
+
# A file or url that is linked to a Trello card
|
3
|
+
#
|
4
|
+
# @!attribute id
|
5
|
+
# @return [String]
|
6
|
+
# @!attribute name
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute url
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute pos
|
11
|
+
# @return [Float]
|
12
|
+
# @!attribute bytes
|
13
|
+
# @return [Fixnum]
|
14
|
+
# @!attribute date
|
15
|
+
# @return [Datetime]
|
16
|
+
# @!attribute is_upload
|
17
|
+
# @return [Boolean]
|
18
|
+
# @!attribute mime_type
|
19
|
+
# @return [String]
|
20
|
+
class Attachment < BasicData
|
21
|
+
register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
|
22
|
+
# Update the fields of an attachment.
|
23
|
+
#
|
24
|
+
# Supply a hash of stringkeyed data retrieved from the Trello API representing
|
25
|
+
# an attachment.
|
26
|
+
def update_fields(fields)
|
27
|
+
attributes[:name] = fields['name']
|
28
|
+
attributes[:id] = fields['id']
|
29
|
+
attributes[:pos] = fields['pos']
|
30
|
+
attributes[:url] = fields['url']
|
31
|
+
attributes[:bytes] = fields['bytes'].to_i
|
32
|
+
attributes[:member_id] = fields['idMember']
|
33
|
+
attributes[:date] = Time.parse(fields['date'])
|
34
|
+
attributes[:is_upload] = fields['isUpload']
|
35
|
+
attributes[:mime_type] = fields['mimeType']
|
36
|
+
attributes[:previews] = fields['previews']
|
37
|
+
self
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|