Class: Tacokit::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/tacokit/configuration.rb

Constant Summary collapse

API_URL =
"https://api.trello.com".freeze
WEB_URL =
"https://trello.com".freeze
API_VERSION =
"1".freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Configuration

Returns a new instance of Configuration.



24
25
26
# File 'lib/tacokit/configuration.rb', line 24

def initialize(opts = {})
  self.options = defaults.merge(opts)
end

Class Method Details

.keysObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tacokit/configuration.rb', line 9

def self.keys
  [
    :app_key,
    :app_secret,
    :app_token,
    :oauth_token,
    :oauth_secret,
    :api_endpoint,
    :web_endpoint,
    :stack
  ]
end

Instance Method Details

#app_authenticated?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/tacokit/configuration.rb', line 40

def app_authenticated?
  app_key && app_token
end

#app_credentialsObject



44
45
46
# File 'lib/tacokit/configuration.rb', line 44

def app_credentials
  { key: app_key, token: app_token }.delete_if { |k, v| v.nil? }
end

#options=(opts) ⇒ Object



28
29
30
# File 'lib/tacokit/configuration.rb', line 28

def options=(opts)
  opts.each { |key, value| instance_variable_set("@#{key}", value) }
end

#stack {|@stack| ... } ⇒ Object

Yields:



48
49
50
51
52
# File 'lib/tacokit/configuration.rb', line 48

def stack
  @stack ||= Faraday::RackBuilder.new(&Middleware.default_stack(self))
  yield @stack if block_given?
  @stack
end

#user_authenticated?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tacokit/configuration.rb', line 32

def user_authenticated?
  app_key && oauth_token
end

#user_credentialsObject



36
37
38
# File 'lib/tacokit/configuration.rb', line 36

def user_credentials
  { consumer_key: app_key, consumer_secret: app_secret, token: oauth_token }.delete_if { |k, v| v.nil? }
end