lib/mws/orders/parser.rb in mws-orders-0.4.0 vs lib/mws/orders/parser.rb in mws-orders-0.5.0

- old
+ new

@@ -5,14 +5,19 @@ require 'mws/orders/order_items' require 'mws/orders/service_status' require 'peddler' module MWS + # With the MWS Orders API, you can list orders created or updated during a + # time frame you specify or retrieve information about specific orders. module Orders + # Overrides the default parser in Peddler class Parser include ::Peddler::Headers + attr_reader :response + def initialize(response, _encoding) @response = response end def parse @@ -23,22 +28,10 @@ when /ListOrderItems/ then order_items else raise NotImplementedError end end - def headers - @response.headers - end - - def status_code - @response.status - end - - def body - @response.body - end - private def order orders.first end @@ -58,16 +51,15 @@ def result_node @result_node ||= find_result_node end def find_result_node - xml = Nokogiri(body) + xml = Nokogiri(response.body) root = xml.children.first root.children.find { |node| node.name.include?('Result') } end end - # Override Peddler's default Parser. Client.parser = Parser end end