Class: HaveAPI::Client::Authentication::Token

Inherits:
Base
  • Object
show all
Defined in:
lib/haveapi/client/authentication/token.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, register, #request_payload, #resource

Constructor Details

This class inherits a constructor from HaveAPI::Client::Authentication::Base

Instance Method Details

#load(hash) ⇒ Object



31
32
33
34
# File 'lib/haveapi/client/authentication/token.rb', line 31

def load(hash)
  @token = hash[:token]
  @valid_to = hash[:valid_to]
end

#request_headersObject



21
22
23
24
25
# File 'lib/haveapi/client/authentication/token.rb', line 21

def request_headers
  return {} unless @configured
  check_validity
  @via == :header ? {@desc[:http_header] => @token} : {}
end

#request_url_paramsObject



15
16
17
18
19
# File 'lib/haveapi/client/authentication/token.rb', line 15

def request_url_params
  return {} unless @configured
  check_validity
  @via == :query_param ? {@desc[:query_parameter] => @token} : {}
end

#saveObject



27
28
29
# File 'lib/haveapi/client/authentication/token.rb', line 27

def save
  {token: @token, valid_to: @valid_to}
end

#setupObject



5
6
7
8
9
10
11
12
13
# File 'lib/haveapi/client/authentication/token.rb', line 5

def setup
  @via = @opts[:via] || :header
  @token = @opts[:token]
  @valid_to = @opts[:valid_to]

  request_token unless @token

  @configured = true
end