Class: Brightbox::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/brightbox-cli/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Token

Returns a new instance of Token.



11
12
13
14
# File 'lib/brightbox-cli/token.rb', line 11

def initialize(config, options = {})
  @config = config
  @options = options
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



9
10
11
# File 'lib/brightbox-cli/token.rb', line 9

def config
  @config
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/brightbox-cli/token.rb', line 9

def options
  @options
end

Class Method Details

.show(config, options) ⇒ Object



5
6
7
# File 'lib/brightbox-cli/token.rb', line 5

def self.show(config, options)
  new(config, options)
end

Instance Method Details

#access_tokenObject



16
17
18
# File 'lib/brightbox-cli/token.rb', line 16

def access_token
  config.access_token
end

#format(output = :text) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/brightbox-cli/token.rb', line 20

def format(output = :text)
  output = output.to_sym

  case output
  when :curl
    curl_output
  when :json
    json_output
  when :token
    token_output
  else
    text_output
  end
end

#refresh_tokenObject



35
36
37
# File 'lib/brightbox-cli/token.rb', line 35

def refresh_token
  config.refresh_token
end