Class: MWS::Feeds::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(response, _encoding) ⇒ Parser

Returns a new instance of Parser.



15
16
17
# File 'lib/mws/feeds/parser.rb', line 15

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

Instance Method Details

#bodyObject



44
45
46
# File 'lib/mws/feeds/parser.rb', line 44

def body
  @response.body
end

#headersObject



36
37
38
# File 'lib/mws/feeds/parser.rb', line 36

def headers
  @response.headers
end

#parseObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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_codeObject



40
41
42
# File 'lib/mws/feeds/parser.rb', line 40

def status_code
  @response.status
end