class Underway::TokenCache
Attributes
db[RW]
Public Class Methods
new(database)
click to toggle source
# File lib/underway/token_cache.rb, line 5 def initialize(database) @db = database end
Public Instance Methods
lookup_installation_auth_token(id:)
click to toggle source
# File lib/underway/token_cache.rb, line 9 def lookup_installation_auth_token(id:) results = db[:cached_tokens].where(installation_id: id) .where{expires_at >= DateTime.now.new_offset(0)} # Force UTC Timezone .reverse(:expires_at) if results.any? results.first[:token] end end
store_installation_auth_token(id:, token:, expires_at:)
click to toggle source
# File lib/underway/token_cache.rb, line 18 def store_installation_auth_token(id:, token:, expires_at:) db[:cached_tokens].insert( installation_id: id, token: token, expires_at: DateTime.parse(expires_at) ) end