Sha256: 9df4485e9ceda6c335a398e0da42241150781dbaeb016f40017a02fa7d896fb4

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

module ApiAuthenticator
  class BaseError < StandardError
  end

  class InvalidTimeError < BaseError
    attr_reader :upper_threshold, :lower_threshold, :actual_time

    def initialize(upper_threshold, lower_threshold, actual_time)
      @upper_threshold = upper_threshold
      @lower_threshold = lower_threshold
      @actual_time = actual_time
    end

    def constructed_message
      "Invalid Time Error: upper threshold: #{@upper_threshold} lower threshold: #{@lower_threshold} actual time: #{@actual_time}"
    end
  end

  class InvalidTokenError < BaseError
    attr_reader :time, :keys_and_tokens

    def initialize(time, keys_and_tokens)
      @time = time
      @keys_and_tokens = keys_and_tokens
    end


    def constructed_message
      message = ""
      @keys_and_tokens.each do |key_and_token|
        message << "Invalid Token Error Time: #{@time} Shared Key: #{key_and_token[0]} expected token: #{key_and_token[2]} actual token: #{key_and_token[1]}"
      end
      message
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_authenticator-0.3.0 lib/api_authenticator/errors.rb
api_authenticator-0.2.1 lib/api_authenticator/errors.rb