Class: WhenIWork::Authentication
- Defined in:
- lib/when-i-work/authentication.rb
Class Method Summary collapse
Methods inherited from Resource
Class Method Details
.login(username, password, api_key) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/when-i-work/authentication.rb', line 6 def login(username, password, api_key) 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'] else raise Error::AuthenticationFailedError end end |