Class: Indix::Products
- Inherits:
-
Object
- Object
- Indix::Products
- Extended by:
- Resource
- Defined in:
- lib/indix/products.rb
Class Method Summary collapse
-
.find(id, view: nil, page_number: 1) ⇒ Mash
Get the details of a product.
-
.search(query: nil, upc: nil, mpn: nil, sku: nil, url: nil, stores: nil, brands: nil, category_id: nil, start_price: nil, end_price: nil, availability: nil, price_history_available: nil, offers_count: nil, price_change: nil, sort_by: nil, page_number: 1) ⇒ Mash
An object containing the count, products array and page_number.
Methods included from Resource
Class Method Details
.find(id, view: nil, page_number: 1) ⇒ Mash
Get the details of a product
58 59 60 61 62 63 |
# File 'lib/indix/products.rb', line 58 def self.find(id, view: nil, page_number: 1) request_params = {} request_params[:view] = view unless view.nil? request_params[:pageNumber] = page_number get("/products/#{id}", request_params) end |
.search(query: nil, upc: nil, mpn: nil, sku: nil, url: nil, stores: nil, brands: nil, category_id: nil, start_price: nil, end_price: nil, availability: nil, price_history_available: nil, offers_count: nil, price_change: nil, sort_by: nil, page_number: 1) ⇒ Mash
Returns an object containing the count, products array and page_number.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/indix/products.rb', line 25 def self.search(query: nil, upc: nil, mpn: nil, sku: nil, url: nil, stores: nil, brands: nil, category_id: nil, start_price: nil, end_price: nil, availability: nil, price_history_available: nil, offers_count: nil, price_change: nil, sort_by: nil, page_number: 1) request_params = {} request_params[:query] = query unless query.nil? request_params[:upc] = upc unless upc.nil? request_params[:mpn] = mpn unless mpn.nil? request_params[:sku] = sku unless sku.nil? request_params[:url] = url unless url.nil? request_params[:storeId] = stores unless stores.nil? request_params[:brandId] = brands unless brands.nil? request_params[:categoryId] = category_id unless category_id.nil? raise Indix::ArgumentError.new('Atleast one required parameter should be passed') if request_params.empty? request_params[:startPrice] = start_price unless start_price.nil? request_params[:endPrice] = end_price unless end_price.nil? request_params[:availability] = availability unless availability.nil? request_params[:priceHistoryAvailable] = price_history_available unless price_history_available.nil? request_params[:offersCount] = offers_count unless offers_count.nil? request_params[:priceChange] = price_change unless price_change.nil? request_params[:sortBy] = sort_by unless sort_by.nil? request_params[:pageNumber] = page_number get("/products", request_params) end |