Method: BooticCli::Session#client

Defined in:
lib/bootic_cli/session.rb

#clientObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/bootic_cli/session.rb', line 91

def client
  @client ||= begin
    raise "First setup credentials and log in" unless ready?
    BooticClient.configure do |c|
      c.auth_host = config[:auth_host] if config[:auth_host]
      c.api_root = config[:api_root] if config[:api_root]
      c.client_id = config[:client_id]
      c.client_secret = config[:client_secret]
      c.logger = Logger.new(STDOUT)
      c.logging = false
      c.cache_store = NullCacheStore.new
    end

    BooticClient.client(:authorized, access_token: config[:access_token]) do |new_token|
      store.transaction{ store['access_token'] = new_token }
    end
  end
end