Sha256: 2a95a6c03d5df4b18a51c141b18ef0326f5f173a1a8e7c91b751ffb319905be2
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Peddler # Parses MWS metadata provided in the headers of a response class MWS # @!visibility private attr_reader :headers # @!visibility private def initialize(headers) @headers = headers.select { |key| key.start_with?('x-mws') } end # The max hourly request quota for the requested operation # @return [Integer, nil] def quota_max return unless headers['x-mws-quota-max'] headers['x-mws-quota-max'].to_i end # The remaining hourly request quota for the requested operation # @return [Integer, nil] def quota_remaining return unless headers['x-mws-quota-remaining'] headers['x-mws-quota-remaining'].to_i end # When the hourly request quota for the requested operation resets # @return [Time, nil] def quota_resets_on return unless headers['x-mws-quota-resetsOn'] Time.parse(headers['x-mws-quota-resetsOn']) end # The ID of the request # @return [String, nil] def request_id headers['x-mws-request-id'] end # The timestamp of the request # @return [Time, nil] def timestamp return unless headers['x-mws-timestamp'] Time.parse(headers['x-mws-timestamp']) end # The context of the response # @return [String, nil] def response_context headers['x-mws-response-context'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
peddler-2.3.0 | lib/peddler/mws.rb |