Sha256: b45560645b232ca47fa7c0e9071f084f77fc3c21310f7d56523ea20cad98a940

Contents?: true

Size: 986 Bytes

Versions: 6

Compression:

Stored size: 986 Bytes

Contents

require 'peddler/request'
require 'mws/feeds/parsers/feed'

module MWS
  module Feeds
    module Requests
      class Feed < ::Peddler::Request
        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

        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
peddler-0.6.5 lib/mws/feeds/requests/feed.rb
peddler-0.6.4 lib/mws/feeds/requests/feed.rb
peddler-0.6.3 lib/mws/feeds/requests/feed.rb
peddler-0.6.2 lib/mws/feeds/requests/feed.rb
peddler-0.6.1 lib/mws/feeds/requests/feed.rb
peddler-0.6.0 lib/mws/feeds/requests/feed.rb