Class: Peddler::MWS

Inherits:
Object
  • Object
show all
Defined in:
lib/peddler/mws.rb

Overview

Parses MWS metadata provided in the headers of a response

Instance Method Summary collapse

Instance Method Details

#quota_maxInteger?

The max hourly request quota for the requested operation

Returns:

  • (Integer, nil)


16
17
18
19
20
# File 'lib/peddler/mws.rb', line 16

def quota_max
  return unless headers['x-mws-quota-max']

  headers['x-mws-quota-max'].to_i
end

#quota_remainingInteger?

The remaining hourly request quota for the requested operation

Returns:

  • (Integer, nil)


24
25
26
27
28
# File 'lib/peddler/mws.rb', line 24

def quota_remaining
  return unless headers['x-mws-quota-remaining']

  headers['x-mws-quota-remaining'].to_i
end

#quota_resets_onTime?

When the hourly request quota for the requested operation resets

Returns:

  • (Time, nil)


32
33
34
35
36
# File 'lib/peddler/mws.rb', line 32

def quota_resets_on
  return unless headers['x-mws-quota-resetsOn']

  Time.parse(headers['x-mws-quota-resetsOn'])
end

#request_idString?

The ID of the request

Returns:

  • (String, nil)


40
41
42
# File 'lib/peddler/mws.rb', line 40

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

#response_contextString?

The context of the response

Returns:

  • (String, nil)


54
55
56
# File 'lib/peddler/mws.rb', line 54

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

#timestampTime?

The timestamp of the request

Returns:

  • (Time, nil)


46
47
48
49
50
# File 'lib/peddler/mws.rb', line 46

def timestamp
  return unless headers['x-mws-timestamp']

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