class SageWorld::Api::Product

Constants

DEFAULT_SEARCH_PARAMS

Public Class Methods

cached_data(supp_id, params={}) click to toggle source
# File lib/sage_world/api/product.rb, line 168
def self.cached_data(supp_id, params={})
  response = SageWorld::Client.new(cached_product_params(supp_id, params)).send_request
  SageWorld::ResponseHandler.new(response)
end
new(product_id) click to toggle source
# File lib/sage_world/api/product.rb, line 14
def initialize(product_id)
  @product_id = product_id
end

Private Class Methods

cached_product_params(supp_id, params) click to toggle source
# File lib/sage_world/api/product.rb, line 187
                     def self.cached_product_params(supp_id, params)
  {
    supplier_product_data_dump: {
      supp_id: supp_id,
      start_rec: params[:start_rec] || 1,
      max_recs_to_return: params[:max_recs_to_return] || 0
    }
  }
end
search_product_params(params) click to toggle source
# File lib/sage_world/api/product.rb, line 181
                     def self.search_product_params(params)
  {
    search: params
  }
end

Public Instance Methods

details(options = {}) click to toggle source

Product Details Usage: product = SageWorld::Api::Product.new(“Product_id_or_spc”) response = product.details response.body => product details as hash

# File lib/sage_world/api/product.rb, line 24
def details(options = {})
  if @existing_options == options
    @response
  else
    @existing_options = options
    response = SageWorld::Client.new(find_product_params(@product_id ,options)).send_request
    @response = SageWorld::ResponseHandler.new(response)
  end
end

Private Instance Methods

find_product_params(product_id, options) click to toggle source
# File lib/sage_world/api/product.rb, line 173
        def find_product_params(product_id, options)
  {
    product_detail: {
      product_id: product_id
    }
  }.merge(options)
end