Module: Trello
- Defined in:
- lib/trello.rb,
lib/trello/net.rb,
lib/trello/card.rb,
lib/trello/item.rb,
lib/trello/list.rb,
lib/trello/board.rb,
lib/trello/error.rb,
lib/trello/label.rb,
lib/trello/token.rb,
lib/trello/action.rb,
lib/trello/client.rb,
lib/trello/member.rb,
lib/trello/comment.rb,
lib/trello/webhook.rb,
lib/trello/checklist.rb,
lib/trello/attachment.rb,
lib/trello/basic_data.rb,
lib/trello/item_state.rb,
lib/trello/json_utils.rb,
lib/trello/label_name.rb,
lib/trello/association.rb,
lib/trello/cover_image.rb,
lib/trello/has_actions.rb,
lib/trello/notification.rb,
lib/trello/organization.rb,
lib/trello/plugin_datum.rb,
lib/trello/authorization.rb,
lib/trello/configuration.rb,
lib/trello/association_proxy.rb,
lib/trello/multi_association.rb
Overview
Ruby wrapper around the Trello API
First, set up your key information. You can get this information by clicking here.
You can get the key by going to this url in your browser: trello.com/1/authorize?key=TRELLO_CONSUMER_KEY_FROM_ABOVE&name=MyApp&response_type=token&scope=read,write,account&expiration=never 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. 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 url above:
Trello.configure do |config|
config.consumer_key = TRELLO_CONSUMER_KEY
config.consumer_secret = TRELLO_CONSUMER_SECRET
config.oauth_token = TRELLO_OAUTH_TOKEN
config.oauth_token_secret = TRELLO_OAUTH_TOKEN_SECRET
end
All the calls this library make to Trello require authentication using these keys. Be sure to protect them.
So lets say you want to get information about the user bobtester. We can do something like this:
bob = Member.find("bobtester")
# Print out his name
puts bob.full_name # "Bob Tester"
# Print his bio
puts bob.bio # A wonderfully delightful test user
# How about a list of his boards?
bob.boards
And so much more. Consult the rest of the documentation for more information.
Feel free to peruse and participate in our Trello board. It’s completely open to the public.
Defined Under Namespace
Modules: Authorization, HasActions, JsonUtils Classes: Action, Association, AssociationProxy, Attachment, BasicData, Board, Card, CheckItemState, Checklist, Client, Comment, Configuration, CoverImage, Error, Item, Label, LabelName, List, Member, MultiAssociation, Notification, Organization, PluginDatum, Request, Response, TInternet, Token, Webhook
Constant Summary collapse
- API_VERSION =
Version of the Trello API that we use by default.
1
- InvalidAccessToken =
This specific error is thrown when your access token is invalid. You should get a new one.
Class.new(Error)
- ConfigurationError =
This error is thrown when your client has not been configured
Class.new(Error)
Class Method Summary collapse
- .auth_policy ⇒ Object
-
.authorize_url(options = {}) ⇒ Object
Url to token for making authorized requests to the Trello API.
- .client ⇒ Object
- .configuration ⇒ Object
- .configure(&block) ⇒ Object
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
-
.open_authorization_url(options = {}) ⇒ Object
Visit the Trello authorized token page.
-
.open_public_key_url ⇒ Object
Visit the Trello API public key page.
- .open_url(url) ⇒ Object
-
.public_key_url ⇒ Object
Url to Trello API public key page.
- .reset! ⇒ Object
Class Method Details
.auth_policy ⇒ Object
106 |
# File 'lib/trello.rb', line 106 def self.auth_policy; client.auth_policy; end |
.authorize_url(options = {}) ⇒ Object
Url to token for making authorized requests to the Trello API
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/trello.rb', line 126 def self.( = {}) params = .dup params[:key] ||= configuration.developer_public_key or raise ArgumentError, 'Please configure your Trello public key' params[:name] ||= 'Ruby Trello' params[:scope] ||= 'read,write,account' params[:expiration] ||= 'never' params[:response_type] ||= 'token' uri = Addressable::URI.parse 'https://trello.com/1/authorize' uri.query_values = params uri end |
.client ⇒ Object
93 94 95 |
# File 'lib/trello.rb', line 93 def self.client @client ||= Client.new end |
.configuration ⇒ Object
107 |
# File 'lib/trello.rb', line 107 def self.configuration; client.configuration; end |
.configure(&block) ⇒ Object
97 98 99 100 |
# File 'lib/trello.rb', line 97 def self.configure(&block) reset! client.configure(&block) end |
.logger ⇒ Object
85 86 87 |
# File 'lib/trello.rb', line 85 def self.logger @logger ||= Logger.new(STDOUT) end |
.logger=(logger) ⇒ Object
89 90 91 |
# File 'lib/trello.rb', line 89 def self.logger=(logger) @logger = logger end |
.open_authorization_url(options = {}) ⇒ Object
Visit the Trello authorized token page
149 150 151 |
# File 'lib/trello.rb', line 149 def self.( = {}) open_url () end |
.open_public_key_url ⇒ Object
Visit the Trello API public key page
142 143 144 |
# File 'lib/trello.rb', line 142 def self.open_public_key_url open_url public_key_url end |
.open_url(url) ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/trello.rb', line 154 def self.open_url(url) require 'launchy' Launchy.open(url.to_s) rescue LoadError warn 'Please install the launchy gem to open the url automatically.' url end |
.public_key_url ⇒ Object
Url to Trello API public key page
110 111 112 |
# File 'lib/trello.rb', line 110 def self.public_key_url 'https://trello.com/app-key' end |
.reset! ⇒ Object
102 103 104 |
# File 'lib/trello.rb', line 102 def self.reset! @client = nil end |