Class: Neura::Client::Authenticator
- Inherits:
-
Object
- Object
- Neura::Client::Authenticator
- Defined in:
- lib/neura-client/authenticator.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #fetch_token(params) ⇒ Object
-
#initialize(params = {}) ⇒ Authenticator
constructor
A new instance of Authenticator.
Constructor Details
#initialize(params = {}) ⇒ Authenticator
Returns a new instance of Authenticator.
9 10 11 12 13 14 |
# File 'lib/neura-client/authenticator.rb', line 9 def initialize(params = {}) @access_token = params[:token] unless @access_token @access_token = fetch_token(params) end end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
7 8 9 |
# File 'lib/neura-client/authenticator.rb', line 7 def access_token @access_token end |
Instance Method Details
#fetch_token(params) ⇒ Object
16 17 18 19 |
# File 'lib/neura-client/authenticator.rb', line 16 def fetch_token(params) result = HTTParty.post("#{Neura::Client::HOST}/external_api/v1/auth.json", body: params) result["token"] end |