Module: Peddler::Headers

Included in:
FlatFileParser, XMLParser
Defined in:
lib/peddler/headers.rb

Overview

Parses MWS-specific headers

Defined Under Namespace

Classes: Quota

Instance Method Summary collapse

Instance Method Details

#quotaObject



6
7
8
9
10
11
12
13
14
# File 'lib/peddler/headers.rb', line 6

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

#request_idObject



16
17
18
# File 'lib/peddler/headers.rb', line 16

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

#response_contextObject



24
25
26
# File 'lib/peddler/headers.rb', line 24

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

#timestampObject



20
21
22
# File 'lib/peddler/headers.rb', line 20

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