class Omnikassa2::AccessTokenProvider
Public Class Methods
instance()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 3 def self.instance @@instance ||= AccessTokenProvider.new @@instance end
new()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 19 def initialize @access_token = nil end
Public Instance Methods
access_token()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 8 def access_token refresh_token if token_needs_refresh? @access_token end
to_s()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 13 def to_s access_token.to_s end
Private Instance Methods
refresh_token()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 27 def refresh_token response = Omnikassa2::RefreshRequest.new.send raise Omnikassa2::HttpError, response.to_s unless response.success? @access_token = response.access_token end
token_needs_refresh?()
click to toggle source
# File lib/omnikassa2/helpers/access_token_provider.rb, line 23 def token_needs_refresh? @access_token.nil? || @access_token.expiring? end