Class: Wework::Token::Store
- Inherits:
-
Object
- Object
- Wework::Token::Store
- Defined in:
- lib/wework/token/store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
- #access_token ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(app) ⇒ Store
constructor
A new instance of Store.
- #refresh_token ⇒ Object
Constructor Details
#initialize(app) ⇒ Store
Returns a new instance of Store.
7 8 9 |
# File 'lib/wework/token/store.rb', line 7 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/wework/token/store.rb', line 5 def app @app end |
Instance Method Details
#access_token ⇒ Object
11 12 13 |
# File 'lib/wework/token/store.rb', line 11 def access_token refresh_token if expired? end |
#expired? ⇒ Boolean
15 16 17 |
# File 'lib/wework/token/store.rb', line 15 def expired? raise NotImplementedError, "Subclasses must implement a token_expired? method" end |
#refresh_token ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/wework/token/store.rb', line 19 def refresh_token result = app.request.get 'gettoken', params: {corpid: app.corp_id, corpsecret: app.app_secret} if defined?(Rails) Rails.logger.warn "[WEWORK] refresh Token(#{app.corp_id}): #{result.inspect}" end result end |