class Finicity::Fetchers::Token
Public Class Methods
get()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 7 def get refresh if token_expired? token end
refresh()
click to toggle source
# 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
Protected Class Methods
fetch_new_one()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 23 def fetch_new_one endpoint = "/aggregation/v2/partners/authentication" body = { partner_id: Finicity.configs.partner_id, partner_secret: Finicity.configs.partner_secret } request(:post, endpoint, body: body) end
redis()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 44 def redis Finicity.configs.redis end
token()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 36 def token redis["finicity-token"] end
token_expired?()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 32 def token_expired? !(token_expired_at.present? && Time.parse(token_expired_at).future?) end
token_expired_at()
click to toggle source
# File lib/finicity/fetchers/token.rb, line 40 def token_expired_at redis["finicity-token-expires-at"] end