module Tacokit::Authorization

Public Instance Methods

authorize(params = {}) click to toggle source

Get a token for making authorized requests to the Trello API

@param params [Hash] Repository information to update @option params [String] :name Name of the application @option params [String] :key Application key @option params [String] :callback_method “postMessage” or “fragment” @option params [String] :return_url URL the token should be returned to @option params [String] :scope Comma-separated list of one or more of “read”, “write”, “account” @option params [String] :expiration “1hour”, “1day”, “30days”, “never” @see developers.trello.com/authorize

# File lib/tacokit/authorization.rb, line 17
def authorize(params = {})
  open_url authorize_url(params)
end
authorize_url(params = {}) click to toggle source
# File lib/tacokit/authorization.rb, line 21
def authorize_url(params = {})
  params[:key] ||= app_key
  params[:name] ||= "Tacokit"
  params[:response_type] ||= "token"
  web_url "authorize", params
end
get_app_key() click to toggle source
# File lib/tacokit/authorization.rb, line 3
def get_app_key # rubocop:disable Style/AccessorMethodName
  open_url web_url("app-key")
end

Private Instance Methods

open_url(url) click to toggle source
# File lib/tacokit/authorization.rb, line 30
def open_url(url)
  require "launchy"
  Launchy.open(url)
rescue LoadError
  warn "Visit #{url}"
  warn "Please install the launchy gem to open the url automatically."
end
web_connection() click to toggle source
# File lib/tacokit/authorization.rb, line 42
def web_connection
  Faraday::Connection.new(web_endpoint)
end
web_url(path, params = {}) click to toggle source
# File lib/tacokit/authorization.rb, line 38
def web_url(path, params = {})
  web_connection.build_url(path, params).to_s
end