Class: MWS::Orders::Parser

Inherits:
Object
  • Object
show all
Includes:
Peddler::Headers
Defined in:
lib/mws/orders/parser.rb

Overview

Overrides the default parser in Peddler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, _encoding) ⇒ Parser

Returns a new instance of Parser.



19
20
21
# File 'lib/mws/orders/parser.rb', line 19

def initialize(response, _encoding)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



17
18
19
# File 'lib/mws/orders/parser.rb', line 17

def response
  @response
end

Instance Method Details

#parseObject



23
24
25
26
27
28
29
30
31
# File 'lib/mws/orders/parser.rb', line 23

def parse
  case payload.name
  when /GetOrderResult/         then orders
  when /ListOrders.*Result/     then orders
  when /ListOrderItems.*Result/ then order_items
  when 'GetServiceStatusResult' then service_status
  else raise NotImplementedError
  end
end

#payloadObject



33
34
35
# File 'lib/mws/orders/parser.rb', line 33

def payload
  @payload ||= find_payload
end