Class: Tacokit::Configuration

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

Constant Summary

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

- (Configuration) initialize(opts = {})

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

+ (Object) keys



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

- (Boolean) app_authenticated?

Returns:

  • (Boolean)


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

def app_authenticated?
  app_key && app_token
end

- (Object) app_credentials



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

- (Object) options=(opts)



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

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

- (Object) stack {|@stack| ... }

Yields:

  • (@stack)


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

- (Boolean) user_authenticated?

Returns:

  • (Boolean)


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

def user_authenticated?
  app_key && oauth_token
end

- (Object) user_credentials



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