Sha256: 58cafca6240a4a1b494289bb90e8799bddb9769e799c42c8fb9d362bcbc38e6c

Contents?: true

Size: 883 Bytes

Versions: 24

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

module MuffinMan
  module ProductPricing
    class V0 < SpApiClient
      GET_COMPETITIVE_PRICE_PARAMS = %w[Asins Skus CustomerType].freeze

      def get_competitive_pricing(marketplace_id, item_type='Asin', params = {})
        @local_var_path = '/products/pricing/v0/competitivePrice'
        @params = { 'MarketplaceId' => marketplace_id, 'ItemType' => item_type }
        @params.merge! params.slice(*GET_COMPETITIVE_PRICE_PARAMS)
        @query_params = hash_to_sp_api_uri_params(@params)
        @request_type = "GET"
        call_api
      end

      private

      # SP APIs expect param array on the form of Asins=Asin1%2CAsin2 (%2C is url escaped for ,) ...
      def hash_to_sp_api_uri_params(params)
        params.keys.map { |k| "#{k}=#{params[k].is_a?(Array) ? params[k].join("%2C") : params[k]}" }.join('&')
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
muffin_man-2.4.8 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.7 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.6 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.5 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.4 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.3 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.4.2 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.3.0 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.2.2 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.2.1 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.1.3 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.1.0 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.6 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.5 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.4 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.3 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.2 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.1 lib/muffin_man/product_pricing/v0.rb
muffin_man-2.0.0 lib/muffin_man/product_pricing/v0.rb
muffin_man-1.5.12 lib/muffin_man/product_pricing/v0.rb