Class: BigcommerceAPI::Sku
- Defined in:
- lib/bigcommerce_api/sku.rb
Instance Attribute Summary collapse
-
#bin_picking_number ⇒ Object
Returns the value of attribute bin_picking_number.
-
#cost_price ⇒ Object
Returns the value of attribute cost_price.
-
#id ⇒ Object
Returns the value of attribute id.
-
#inventory_level ⇒ Object
Returns the value of attribute inventory_level.
-
#inventory_warning_level ⇒ Object
Returns the value of attribute inventory_warning_level.
-
#options ⇒ Object
Returns the value of attribute options.
-
#product_id ⇒ Object
Returns the value of attribute product_id.
-
#sku ⇒ Object
Returns the value of attribute sku.
-
#upc ⇒ Object
Returns the value of attribute upc.
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#find_for_reload ⇒ Object
we override this on resources that need paired IDs for find.
- #option_value ⇒ Object
- #option_value_id ⇒ Object
- #parent ⇒ Object
- #product_option ⇒ Object
- #product_option_id ⇒ Object
- #resource_url ⇒ Object
Methods inherited from Resource
belongs_to, #changed, #create, has_many, has_one, http_request, #initialize, #mark_dirty!, #reload, #resource, resource, #save
Methods inherited from Base
#attributes, clean!, date_adjust, #initialize, #store, #time, to_rfc2822
Constructor Details
This class inherits a constructor from BigcommerceAPI::Resource
Instance Attribute Details
#bin_picking_number ⇒ Object
Returns the value of attribute bin_picking_number.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def bin_picking_number @bin_picking_number end |
#cost_price ⇒ Object
Returns the value of attribute cost_price.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def cost_price @cost_price end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def id @id end |
#inventory_level ⇒ Object
Returns the value of attribute inventory_level.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def inventory_level @inventory_level end |
#inventory_warning_level ⇒ Object
Returns the value of attribute inventory_warning_level.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def inventory_warning_level @inventory_warning_level end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def @options end |
#product_id ⇒ Object
Returns the value of attribute product_id.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def product_id @product_id end |
#sku ⇒ Object
Returns the value of attribute sku.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def sku @sku end |
#upc ⇒ Object
Returns the value of attribute upc.
4 5 6 |
# File 'lib/bigcommerce_api/sku.rb', line 4 def upc @upc end |
Class Method Details
.all(product_id, params = {}) ⇒ Object
50 51 52 53 |
# File 'lib/bigcommerce_api/sku.rb', line 50 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) ⇒ Object
55 56 57 58 |
# File 'lib/bigcommerce_api/sku.rb', line 55 def find(product_id, id) r = BigcommerceAPI::Base.get("/products/#{product_id}/skus/#{id}") (r.success? and !r.nil?) ? self.new(r) : nil end |
Instance Method Details
#description ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/bigcommerce_api/sku.rb', line 35 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 ⇒ Object
we override this on resources that need paired IDs for find
45 46 47 |
# File 'lib/bigcommerce_api/sku.rb', line 45 def find_for_reload self.class.find(self.product_id, self.id) end |
#option_value ⇒ Object
29 30 31 32 33 |
# File 'lib/bigcommerce_api/sku.rb', line 29 def option_value option_id = self.product_option.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 end |
#option_value_id ⇒ Object
20 21 22 |
# File 'lib/bigcommerce_api/sku.rb', line 20 def option_value_id self..first['option_value_id'] end |
#parent ⇒ Object
12 13 14 |
# File 'lib/bigcommerce_api/sku.rb', line 12 def parent 'product' end |
#product_option ⇒ Object
24 25 26 27 |
# File 'lib/bigcommerce_api/sku.rb', line 24 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 ⇒ Object
16 17 18 |
# File 'lib/bigcommerce_api/sku.rb', line 16 def product_option_id self..first['product_option_id'] end |
#resource_url ⇒ Object
8 9 10 |
# File 'lib/bigcommerce_api/sku.rb', line 8 def resource_url "products/#{self.product_id}/skus" end |