Class: WxOpendata::Token
- Inherits:
-
Object
- Object
- WxOpendata::Token
- Defined in:
- lib/wx_opendata/token.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#appid ⇒ Object
readonly
Returns the value of attribute appid.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#store_token_at ⇒ Object
readonly
Returns the value of attribute store_token_at.
-
#token_expires_in ⇒ Object
readonly
Returns the value of attribute token_expires_in.
-
#token_file ⇒ Object
readonly
Returns the value of attribute token_file.
Instance Method Summary collapse
-
#initialize(appid, appsecret, token_file) ⇒ Token
constructor
A new instance of Token.
- #token ⇒ Object
Constructor Details
#initialize(appid, appsecret, token_file) ⇒ Token
Returns a new instance of Token.
8 9 10 11 12 13 |
# File 'lib/wx_opendata/token.rb', line 8 def initialize(appid, appsecret, token_file) @appid = appid @appsecret = appsecret @token_file = token_file @random_generator = Random.new end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def access_token @access_token end |
#appid ⇒ Object (readonly)
Returns the value of attribute appid.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def appid @appid end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def secret @secret end |
#store_token_at ⇒ Object (readonly)
Returns the value of attribute store_token_at.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def store_token_at @store_token_at end |
#token_expires_in ⇒ Object (readonly)
Returns the value of attribute token_expires_in.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def token_expires_in @token_expires_in end |
#token_file ⇒ Object (readonly)
Returns the value of attribute token_file.
6 7 8 |
# File 'lib/wx_opendata/token.rb', line 6 def token_file @token_file end |
Instance Method Details
#token ⇒ Object
15 16 17 18 19 |
# File 'lib/wx_opendata/token.rb', line 15 def token read_token_from_cache refresh_token if remain_seconds < @random_generator.rand(30..3 * 60) access_token end |