Sha256: dd366d40c1be48a25cfcb944094f67d3186c42d0e4ee39b3b3c793ad046c387e

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

module Vacuum
  module Endpoint
    # A Marketplace Web Services (MWS) API endpoint.
    class MWS < Base
      # A list of MWS API hosts.
      HOSTS = {
        'CA' => 'mws.amazonservices.ca',
        'CN' => 'mws.amazonservices.com.cn',
        'DE' => 'mws-eu.amazonservices.com',
        'ES' => 'mws-eu.amazonservices.com',
        'FR' => 'mws-eu.amazonservices.com',
        'IT' => 'mws-eu.amazonservices.com',
        'JP' => 'mws.amazonservices.jp',
        'UK' => 'mws-eu.amazonservices.com',
        'US' => 'mws.amazonservices.com'
      }

      # Internal: Gets/Sets the Symbol MWS API type.
      attr_accessor :api

      # Returns a String MWS API host.
      def host
        HOSTS[locale]
      end

      # Sets the String marketplace ID.
      #
      # Raises a Missing Marketplace error if marketplace ID is missing.
      def marketplace
        @marketplace or raise MissingMarketplace
      end

      # Sets the String marketplace ID tag.
      attr_writer :marketplace

      # Returns a String MWS API URL path.
      #
      # Raises a Not Implemented Error if API is not implemented.
      def path
        case api
        when :products
          '/Products/2011-10-01'
        else
          raise NotImplementedError
        end
      end

      # Sets the String seller ID.
      #
      # Raises a Missing Seller error if seller ID is missing.
      def seller
        @seller or raise MissingSeller
      end

      # Sets the String seller ID tag.
      attr_writer :seller
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vacuum-0.2.2 lib/vacuum/endpoint/mws.rb
vacuum-0.2.1 lib/vacuum/endpoint/mws.rb
vacuum-0.2.0 lib/vacuum/endpoint/mws.rb
vacuum-0.2.0.pre.1 lib/vacuum/endpoint/mws.rb
vacuum-0.2.0.pre lib/vacuum/endpoint/mws.rb