Class: Youzan::TokenClient
- Inherits:
-
Object
- Object
- Youzan::TokenClient
- Defined in:
- lib/youzan/token_client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#got_token_at ⇒ Object
readonly
Returns the value of attribute got_token_at.
-
#token_life_in_seconds ⇒ Object
readonly
Returns the value of attribute token_life_in_seconds.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize ⇒ TokenClient
constructor
A new instance of TokenClient.
Constructor Details
#initialize ⇒ TokenClient
Returns a new instance of TokenClient.
25 26 27 |
# File 'lib/youzan/token_client.rb', line 25 def initialize @random_generator = Random.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/youzan/token_client.rb', line 23 def client @client end |
#got_token_at ⇒ Object (readonly)
Returns the value of attribute got_token_at.
23 24 25 |
# File 'lib/youzan/token_client.rb', line 23 def got_token_at @got_token_at end |
#token_life_in_seconds ⇒ Object (readonly)
Returns the value of attribute token_life_in_seconds.
23 24 25 |
# File 'lib/youzan/token_client.rb', line 23 def token_life_in_seconds @token_life_in_seconds end |
Instance Method Details
#access_token ⇒ Object
29 30 31 32 33 |
# File 'lib/youzan/token_client.rb', line 29 def access_token read_token_from_store refresh if remain_life_seconds < @random_generator.rand(60..5 * 60) @access_token end |