class MWS::Orders::Parser

Overrides the default parser in Peddler

Attributes

response[R]

Public Class Methods

new(response, _encoding) click to toggle source
# File lib/mws/orders/parser.rb, line 19
def initialize(response, _encoding)
  @response = response
end

Public Instance Methods

parse() click to toggle source
# 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
payload() click to toggle source
# File lib/mws/orders/parser.rb, line 33
def payload
  @payload ||= find_payload
end

Private Instance Methods

find_payload() click to toggle source
# File lib/mws/orders/parser.rb, line 51
def find_payload
  xml = Nokogiri(response.body)
  root = xml.children.first

  root.children.find { |node| node.name.include?('Result') }
end
order_items() click to toggle source
# File lib/mws/orders/parser.rb, line 43
def order_items
  OrderItems.new(payload)
end
orders() click to toggle source
# File lib/mws/orders/parser.rb, line 39
def orders
  Orders.new(payload)
end
service_status() click to toggle source
# File lib/mws/orders/parser.rb, line 47
def service_status
  ServiceStatus.new(payload)
end