Class: MWS::MerchantFulfillment::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(response, _encoding) ⇒ Parser

Returns a new instance of Parser.



14
15
16
# File 'lib/mws/merchant_fulfillment/parser.rb', line 14

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

Instance Method Details

#bodyObject



45
46
47
# File 'lib/mws/merchant_fulfillment/parser.rb', line 45

def body
  @response.body
end

#headersObject



37
38
39
# File 'lib/mws/merchant_fulfillment/parser.rb', line 37

def headers
  @response.headers
end

#parseObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mws/merchant_fulfillment/parser.rb', line 18

def parse
  node = find_result_node

  case node.name
  when /GetServiceStatus/
    ServiceStatus.new(node)
  when /GetEligibleShippingServices/
    ShippingServices.new(node)
  when /CreateShipment/
    shipment_node = node.children.find { |node| node.name == 'Shipment' }
    Shipment.new(shipment_node)
  when /CancelShipment/
    shipment_node = node.children.find { |node| node.name == 'Shipment' }
    Shipment.new(shipment_node)
  else
    raise NotImplementedError
  end
end

#status_codeObject



41
42
43
# File 'lib/mws/merchant_fulfillment/parser.rb', line 41

def status_code
  @response.status
end