class BigcommerceAPI::Sku

Attributes

bin_picking_number[RW]
cost_price[RW]
id[RW]
inventory_level[RW]
inventory_warning_level[RW]
options[RW]
product_id[RW]
sku[RW]
upc[RW]

Public Class Methods

all(product_id, params={}) click to toggle source
# File lib/bigcommerce_api/sku.rb, line 62
def all(product_id, params={})
  resources = BigcommerceAPI::Base.get("/products/#{product_id}/skus", query: date_adjust(params))
  (resources.success? and !resources.nil?) ? resources.collect{|r| self.new(r)} : []
end
find(product_id, id) click to toggle source
# File lib/bigcommerce_api/sku.rb, line 67
def find(product_id, id)
  r = BigcommerceAPI::Base.get("/products/#{product_id}/skus/#{id}")
  (r.success? and !r.nil?) ? self.new(r) : nil
end

Public Instance Methods

description() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 47
def description
  out = Array.new
  po = self.product_option
  ov = self.option_value
  out << po.display_name if po
  out << ov.label if ov
  return out.join(' ')
end
find_for_reload() click to toggle source

we override this on resources that need paired IDs for find

# File lib/bigcommerce_api/sku.rb, line 57
def find_for_reload
  self.class.find(self.product_id, self.id)
end
option_value() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 36
def option_value
  po = self.product_option
  if po # we've got to have a product option for this to work
    option_id = po.option_id
    ov = BigcommerceAPI::Base.get '/options/' + option_id.to_s + '/values/' + self.option_value_id.to_s
    (ov.success? and !ov.nil?) ? OptionValue.new(ov) : nil
  else
    return nil
  end
end
option_value_id() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 27
def option_value_id
  self.options.first['option_value_id']
end
parent() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 19
def parent
  'product'
end
product_option() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 31
def product_option
  po = BigcommerceAPI::Base.get '/products/' + self.product_id.to_s + '/options/' + self.product_option_id.to_s
  (po.success? and !po.nil?) ? ProductOption.new(po) : nil
end
product_option_id() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 23
def product_option_id
  self.options.first['product_option_id']
end
resource_url() click to toggle source
# File lib/bigcommerce_api/sku.rb, line 15
def resource_url
  "products/#{self.product_id}/skus"
end