Class: Youzan::TokenClient

Inherits:
Object
  • Object
show all
Defined in:
lib/youzan/token_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTokenClient

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

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/youzan/token_client.rb', line 23

def client
  @client
end

#got_token_atObject (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_secondsObject (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_tokenObject



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