class MWS::Feeds::Parser

Public Class Methods

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

Public Instance Methods

body() click to toggle source
# File lib/mws/feeds/parser.rb, line 44
def body
  @response.body
end
headers() click to toggle source
# File lib/mws/feeds/parser.rb, line 36
def headers
  @response.headers
end
parse() click to toggle source
# File lib/mws/feeds/parser.rb, line 19
def parse
  node = find_payload

  case node.name
  when /GetFeedSubmissionCount/
    FeedSubmissionCount.new(node)
  when /SubmitFeedResult/
    FeedSubmissionInfo.new(node.at('FeedSubmissionInfo'))
  when /GetFeedSubmissionListResult/
    FeedSubmissionList.new(node)
  when 'ProcessingReport'
    FeedSubmissionResult.new(node, namespace: nil)
  else
    raise NotImplementedError, node.name
  end
end
status_code() click to toggle source
# File lib/mws/feeds/parser.rb, line 40
def status_code
  @response.status
end

Private Instance Methods

find_payload() click to toggle source
# File lib/mws/feeds/parser.rb, line 50
def find_payload
  xml = Nokogiri(@response.body)
  find_result_node(xml) || find_processing_report_node(xml)
end
find_processing_report_node(xml) click to toggle source
# File lib/mws/feeds/parser.rb, line 60
def find_processing_report_node(xml)
  xml.xpath('//ProcessingReport').first
end
find_result_node(xml) click to toggle source
# File lib/mws/feeds/parser.rb, line 55
def find_result_node(xml)
  root = xml.children.first
  root.children.find { |node| node.name.include?('Result') }
end