Method: Teamlab.configure

Defined in:
lib/teamlab/config.rb

.configure {|@config| ... } ⇒ Object

Yields:



8
9
10
11
12
13
14
15
# File 'lib/teamlab/config.rb', line 8

def self.configure(&_block)
  @config ||= Config.new
  yield @config if block_given?
  auth_response = Teamlab::Request.new('authentication').post('', userName: @config.username, password: @config.password).body
  fail "Cannot get response token for #{auth_response}" if auth_response['response'].nil? || auth_response['response']['token'].nil?
  @config.token = auth_response['response']['token']
  @config.headers = { 'authorization' => @config.token }
end