Class: ThirdPartyWxa::Token::LocalStore

Inherits:
Store
  • Object
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

Constructor Details

This class inherits a constructor from ThirdPartyWxa::Token::Store

Instance Method Details

#get_tokenObject



18
19
20
# File 'lib/third_party_wxa/token/local_store.rb', line 18

def get_token
	plugin.component_access_token
end

#set_tokenObject



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

Returns:

  • (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