Class: HaveAPI::Client::Authentication::Token
- Inherits:
-
Base
- Object
- Base
- HaveAPI::Client::Authentication::Token
show all
- Defined in:
- lib/haveapi/client/authentication/token.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, register, #request_payload, #resource
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
|
21
22
23
24
25
|
# File 'lib/haveapi/client/authentication/token.rb', line 21
def
return {} unless @configured
check_validity
@via == :header ? {@desc[:http_header] => @token} : {}
end
|
#request_url_params ⇒ Object
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
|
#save ⇒ Object
27
28
29
|
# File 'lib/haveapi/client/authentication/token.rb', line 27
def save
{token: @token, valid_to: @valid_to}
end
|
#setup ⇒ Object
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
|