Class: ThirdPartyWxa::Token::LocalStore
- Inherits:
-
Store
- Object
- Store
- ThirdPartyWxa::Token::LocalStore
show all
- Defined in:
- lib/third_party_wxa/token/local_store.rb
Instance Attribute Summary
Attributes inherited from Store
#plugin
Instance Method Summary
collapse
Methods inherited from Store
init_with, #initialize, #wx_redis
Instance Method Details
#get_token ⇒ Object
18
19
20
|
# File 'lib/third_party_wxa/token/local_store.rb', line 18
def get_token
plugin.component_access_token
end
|
#set_token ⇒ Object
11
12
13
14
15
16
|
# File 'lib/third_party_wxa/token/local_store.rb', line 11
def set_token
res = plugin.component_access_token_api
plugin.component_access_token = res['component_access_token']
plugin.component_expire_at = ThirdPartyWxa.cal_expire_at res['expires_in']
plugin
end
|
#valid? ⇒ Boolean
6
7
8
9
|
# File 'lib/third_party_wxa/token/local_store.rb', line 6
def valid?
return false if plugin.component_access_token.nil? || plugin.component_expire_at.nil?
Time.now.to_i <= plugin.component_expire_at
end
|