Sha256: 34249f5ae14e2e02e65b7df74007ac8019c99ce8fbeb9401bc117c7ae078f635

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

module A2z
  module Requests
    class ItemLookup < BlankSlate
      include Helpers
      
      attr_reader :params
      
      def initialize(&block)
        @params = { 'Operation' => 'ItemLookup' }
        instance_eval(&block) if block_given?
      end
      
      %w(Condition IdType MerchantId TruncateReviewsAt VariationPage).each do |param|
        method = underscore(param)
        
        class_eval <<-END, __FILE__, __LINE__
          def #{method}(value)
            @params['#{param}'] = value
          end
        END
      end
      
      def id(value)
        value = value.join(',') if value.kind_of?(Array)
        @params['ItemId'] = value
      end
      
      def category(value)
        @params['SearchIndex'] = value
      end
      
      def response_group(value, &block)
        response_group = ResponseGroup.new(value, &block)
        @params.merge!(response_group.params)
      end
      
      def include_reviews_summary(value)
        @params['IncludeReviewsSummary'] = value ? 'True' : 'False'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
a2z-0.1.3 lib/a2z/requests/item_lookup.rb
a2z-0.1.2 lib/a2z/requests/item_lookup.rb
a2z-0.1.1 lib/a2z/requests/item_lookup.rb
a2z-0.1.0 lib/a2z/requests/item_lookup.rb
a2z-0.0.4 lib/a2z/requests/item_lookup.rb
a2z-0.0.3 lib/a2z/requests/item_lookup.rb
a2z-0.0.2 lib/a2z/requests/item_lookup.rb
a2z-0.0.1 lib/a2z/requests/item_lookup.rb