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



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

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



18
19
20
# File 'lib/peddler/headers.rb', line 18

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

#response_contextObject



26
27
28
# File 'lib/peddler/headers.rb', line 26

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

#timestampObject



22
23
24
# File 'lib/peddler/headers.rb', line 22

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