Class: WhenIWork::Authentication

Inherits:
Resource
  • Object
show all
Defined in:
lib/when-i-work/authentication.rb

Class Method Summary collapse

Methods inherited from Resource

client

Class Method Details

.login(username, password, api_key) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/when-i-work/authentication.rb', line 6

def (username, password, api_key)
  client = client(skip_authentication: true)
  response = client.post 'login' do |request|
    request.body = { username: username, password: password, key: api_key }
  end    

  if response.success? && response.body['token']
    response.body['token']
  end
end