Sha256: 65b46b000ffb5487c96fe7a3ee5a4838aac88194a64dd79c48cc21895cf70c67

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

module A2z
  module Requests
    class ItemSearch < BlankSlate
      include Helpers
      
      attr_reader :params
      
      def initialize(&block)
        @params = { 'Operation' => 'ItemSearch' }
        instance_eval(&block) if block_given?
      end
      
      %w(Actor Artist AudienceRating Author Brand BrowseNode Composer Conductor
         Condition Director ItemPage Manufacturer MaximumPrice MerchantId
         MinimumPrice MinPercentageOff MusicLabel Orchestra Power Publisher
         Sort Title TruncateReviewsAt VariationPage).each do |param|
        method = underscore(param)
        
        class_eval <<-END, __FILE__, __LINE__
          def #{method}(value)
            @params['#{param}'] = value
          end
        END
      end
      
      def keywords(value)
        value = value.join(' ') if value.kind_of?(Array)
        @params['Keywords'] = 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_search.rb
a2z-0.1.2 lib/a2z/requests/item_search.rb
a2z-0.1.1 lib/a2z/requests/item_search.rb
a2z-0.1.0 lib/a2z/requests/item_search.rb
a2z-0.0.4 lib/a2z/requests/item_search.rb
a2z-0.0.3 lib/a2z/requests/item_search.rb
a2z-0.0.2 lib/a2z/requests/item_search.rb
a2z-0.0.1 lib/a2z/requests/item_search.rb