Class: MWS::Feeds::Requests::Feed

Inherits:
Peddler::Request show all
Defined in:
lib/mws/feeds/requests/feed.rb

Instance Attribute Summary

Attributes inherited from Peddler::Request

#body, #client, #last_response

Instance Method Summary collapse

Methods inherited from Peddler::Request

#execute, #initialize, #parameters

Constructor Details

This class inherits a constructor from Peddler::Request

Instance Method Details

#set_content_typeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mws/feeds/requests/feed.rb', line 20

def set_content_type
  headers['Content-Type'] =
    if body.start_with?('<?xml')
      'text/xml; charset=ISO-8859-1'
    else
      case client.default_country
      when 'JP'
        'text/tab-separated-values; charset=Shift_JIS'
      when 'CN'
        'text/tab-separated-values; charset=UTF-16'
      else
        'text/tab-separated-values; charset=ISO-8859-1'
      end
    end
end

#submit(content, type, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mws/feeds/requests/feed.rb', line 8

def submit(content, type, options = {})
  self.body = content
  set_content_type
  parameters(:submit_feed)
    .update(feed_type: type)
    .update(options)
    .format_structured_lists!
    .camelize_keys!

  execute
end