Class: Callstacking::Rails::Client::Authenticate

Inherits:
Base
  • Object
show all
Defined in:
lib/callstacking/rails/client/authenticate.rb

Constant Summary collapse

URL =
"/api/v1/auth.json"

Instance Attribute Summary

Attributes inherited from Base

#async, #auth_token, #threads, #url

Instance Method Summary collapse

Methods inherited from Base

#connection, #get, #initialize, #patch, #post, #r

Constructor Details

This class inherits a constructor from Callstacking::Rails::Client::Base

Instance Method Details

#login(email, password) ⇒ Object

Raises:

  • (Faraday::UnauthorizedError)


11
12
13
14
15
16
17
18
# File 'lib/callstacking/rails/client/authenticate.rb', line 11

def (email, password)
  resp = post(URL, email: email, password: password)

  raise Faraday::UnauthorizedError if resp&.body.nil?

  body = resp&.body || {}
  body["token"]
end