class RDStation::ErrorHandler::ExpiredAccessToken

Constants

EXPIRED_TOKEN_ERROR

Attributes

errors[R]

Public Class Methods

new(errors) click to toggle source
# File lib/rdstation/error_handler/expired_access_token.rb, line 8
def initialize(errors)
  @errors = errors
end

Public Instance Methods

raise_error() click to toggle source
# File lib/rdstation/error_handler/expired_access_token.rb, line 12
def raise_error
  return if expired_token_errors.empty?
  raise RDStation::Error::ExpiredAccessToken, expired_token_errors.first
end

Private Instance Methods

expired_token_error?(error_header) click to toggle source
# File lib/rdstation/error_handler/expired_access_token.rb, line 27
def expired_token_error?(error_header)
  auth_header = error_header['x-amzn-remapped-www-authenticate'] || error_header['www-authenticate']
  return unless auth_header
  auth_header.include?(EXPIRED_TOKEN_ERROR)
end
expired_token_errors() click to toggle source
# File lib/rdstation/error_handler/expired_access_token.rb, line 19
def expired_token_errors
  errors.select do |error|
    error_header = error['headers']
    next unless error_header
    expired_token_error?(error_header)
  end
end