Class: Finicity::Fetchers::Token

Inherits:
Base
  • Object
show all
Defined in:
lib/finicity/fetchers/token.rb

Class Method Summary collapse

Methods inherited from Base

request

Class Method Details

.getObject



7
8
9
10
# File 'lib/finicity/fetchers/token.rb', line 7

def get
  refresh if token_expired?
  token
end

.refreshObject



12
13
14
15
16
17
18
19
# File 'lib/finicity/fetchers/token.rb', line 12

def refresh
  response = fetch_new_one

  raise Finicity::TokenRefreshError, response.body unless response.success?

  redis["finicity-token-expires-at"] = 90.minutes.from_now.to_s
  redis["finicity-token"] = response.body.token
end