Tacokit
Ruby toolkit for the Trello API... a work-in-progress. Design and philosophy inspired by ocktokit.rb
This is Taco.
Quick Start
Add this line to your application"s Gemfile:
gem "tacokit"
... or install it yourself as:
$ gem install tacokit
Configure the client with public-read application credentials:
# View an app key and secret on Trello
Tacokit.get_app_key
# Configure the client
Tacokit.configure do |c|
c.app_key = "4ppk3y"
end
Make requests to Trello API methods using module-level configuration or as client instance methods.
# Fetch the current member
Tacokit.member
# Fetch another member
Tacokit.member "tacokit"
# Configure a separate client
client = Tacokit::Client.new app_key: "4ppk3y"
# Fetch a member
client.member "tacokit"
Authentication
Application Authorization
Trello supports application-level client authorization via an application key and application token.
Tacokit provides a simple way to retrieve your application key:
# Install the `launchy` gem to load the Trello page automatically
Tacokit.get_app_key
Your application key are available by logging into Trello and visiting the app key page. This page also provides your application secret that can be used to generate OAuth token access (see below).
The application token, generated separately from the app key, can be associated with a scope
and expiration
. See the Trello authorization docs for more info on token params.
Tacokit provides a simple way to generate a new app token:
# Full permissions for 30 days
Tacokit. scope: %w[ read write account ], expiration: "30days"
# Authorize a custom application and a different app key
Tacokit. name: "My Trello App", key: "4ppk3y2"
# Read only permissions for custom app forever
Tacokit. scope: "read", expiration: "never", name: "My Trello App"
Your Tacokit client can now be configured to make requests:
# Configure the client
Tacokit.configure do |c|
c.app_key = "4ppk3y"
c.app_token = "4ppt0k3n"
end
More information is available in the Trello docs.
OAuth Authorization
The Trello API provides OAuth 1.0 credentials through the typical OAuth web flow. Tacokit clients can therefore be configured separately to make requests on behalf of different members:
client = Tacokit::Client.new app_key: "4ppk3y", oauth_token: "04utht0k3n"
To experiment with OAuth tokens for development, visit the Tacokit Sandbox and enter your Trello app key and app secret.
Resources
For more information on setting up Trello OAuth for your web application
- Using OmniAuth? Try adding omniauth-trello
- To roll your own, see how the sandbox works: Tacokit sandbox source
- Check out the Trello OAuth docs
Using ENV variables
Default Tacokit client values can be set by values in ENV:
TRELLO_APP_KEY=4ppk3y
TRELLO_APP_SECRET=4pps3cr3t
TRELLO_APP_TOKEN=4ppt0k3n
Usage
Working with boards
client.boards
client.boards("rossta")
board_id = "swezQ9XS" # short link to "Test Board" for Tacokit
board = client.board(board_id)
board.name = "Ice Box"
client.update_board(board.id, name: "TODO")
Working with cards
client.cards
client.cards("rossta")
client.board_cards(board_id)
card_id = "SpbauOpX" # short link to card on "Test Board"
card.name = "Shopping List"
client.update_card(card.id, name: "Wish List")
client.move_card(card.id, list_id: list_id)
Working with lists
client.lists(board_id)
list = client.list(list_id)
list.name = "Work in Progress"
client.update_list(list.id, name: "Done")
Contributing
- Fork it ( https://github.com/[my-github-username]/tacokit/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am "Add some feature"
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request