Class: Wework::Token::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/wework/token/store.rb

Direct Known Subclasses

RedisStore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent) ⇒ Store

Returns a new instance of Store.



7
8
9
# File 'lib/wework/token/store.rb', line 7

def initialize(agent)
  @agent = agent
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



5
6
7
# File 'lib/wework/token/store.rb', line 5

def agent
  @agent
end

Instance Method Details

#access_tokenObject



11
12
13
# File 'lib/wework/token/store.rb', line 11

def access_token
  refresh_token if expired?
end

#expired?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/wework/token/store.rb', line 15

def expired?
  raise NotImplementedError, "Subclasses must implement a token_expired? method"
end

#refresh_tokenObject



19
20
21
# File 'lib/wework/token/store.rb', line 19

def refresh_token
  agent.request.get 'gettoken', params: {corpid: agent.corp_id, corpsecret: agent.agent_secret}
end