Class: HaveAPI::Client::Authentication::Token
- Inherits:
-
Base
- Object
- Base
- HaveAPI::Client::Authentication::Token
show all
- Defined in:
- lib/haveapi/client/authentication/token.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, register, #request_payload, #resource
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
4
5
6
|
# File 'lib/haveapi/client/authentication/token.rb', line 4
def token
@token
end
|
#valid_to ⇒ Object
Returns the value of attribute valid_to.
4
5
6
|
# File 'lib/haveapi/client/authentication/token.rb', line 4
def valid_to
@valid_to
end
|
Instance Method Details
#load(hash) ⇒ Object
32
33
34
35
|
# File 'lib/haveapi/client/authentication/token.rb', line 32
def load(hash)
@token = hash[:token]
@valid_to = hash[:valid_to]
end
|
22
23
24
25
26
|
# File 'lib/haveapi/client/authentication/token.rb', line 22
def
return {} unless @configured
check_validity
@via == :header ? {@desc[:http_header] => @token} : {}
end
|
#request_url_params ⇒ Object
16
17
18
19
20
|
# File 'lib/haveapi/client/authentication/token.rb', line 16
def request_url_params
return {} unless @configured
check_validity
@via == :query_param ? {@desc[:query_parameter] => @token} : {}
end
|
#save ⇒ Object
28
29
30
|
# File 'lib/haveapi/client/authentication/token.rb', line 28
def save
{token: @token, valid_to: @valid_to}
end
|
#setup ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/haveapi/client/authentication/token.rb', line 6
def setup
@via = @opts[:via] || :header
@token = @opts[:token]
@valid_to = @opts[:valid_to]
request_token unless @token
@configured = true
end
|