Sha256: d254080d979ac2f25d3a37b97a612c443fbdb1466800e045d7b9e14a05a89a8b

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

module Peddler
  # Parses MWS-specific headers
  module Headers
    Quota = Struct.new(:max, :remaining, :resets_on)

    def quota
      return if headers.keys.none? { |key| key.include?('quota') }

      Quota.new(
        headers['x-mws-quota-max'].to_i,
        headers['x-mws-quota-remaining'].to_i,
        Time.parse(headers['x-mws-quota-resetsOn'])
      )
    end

    def request_id
      headers['x-mws-request-id']
    end

    def timestamp
      Time.parse(headers['x-mws-timestamp'])
    end

    def response_context
      headers['x-mws-response-context']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
peddler-1.6.3 lib/peddler/headers.rb
peddler-1.6.2 lib/peddler/headers.rb
peddler-1.6.1 lib/peddler/headers.rb