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
#assign_attributes, belongs_to, #changed, #create, #delete, has_many, has_one, http_request, #initialize, #mark_dirty!, #reload, #resource, resource, #save, #update_attributes
Methods inherited from Base
#attributes, clean!, date_adjust, default_options, #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.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def bin_picking_number @bin_picking_number end |
#cost_price ⇒ Object
Returns the value of attribute cost_price.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def cost_price @cost_price end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def id @id end |
#inventory_level ⇒ Object
Returns the value of attribute inventory_level.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def inventory_level @inventory_level end |
#inventory_warning_level ⇒ Object
Returns the value of attribute inventory_warning_level.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def inventory_warning_level @inventory_warning_level end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def @options end |
#product_id ⇒ Object
Returns the value of attribute product_id.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def product_id @product_id end |
#sku ⇒ Object
Returns the value of attribute sku.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def sku @sku end |
#upc ⇒ Object
Returns the value of attribute upc.
3 4 5 |
# File 'lib/bigcommerce_api/sku.rb', line 3 def upc @upc end |
Class Method Details
.all(product_id, params = {}) ⇒ Object
62 63 64 65 |
# 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) ⇒ Object
67 68 69 70 |
# 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 |
Instance Method Details
#description ⇒ Object
47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
we override this on resources that need paired IDs for find
57 58 59 |
# File 'lib/bigcommerce_api/sku.rb', line 57 def find_for_reload self.class.find(self.product_id, self.id) end |
#option_value ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# 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 ⇒ Object
27 28 29 |
# File 'lib/bigcommerce_api/sku.rb', line 27 def option_value_id self..first['option_value_id'] end |
#parent ⇒ Object
19 20 21 |
# File 'lib/bigcommerce_api/sku.rb', line 19 def parent 'product' end |
#product_option ⇒ Object
31 32 33 34 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/bigcommerce_api/sku.rb', line 23 def product_option_id self..first['product_option_id'] end |
#resource_url ⇒ Object
15 16 17 |
# File 'lib/bigcommerce_api/sku.rb', line 15 def resource_url "products/#{self.product_id}/skus" end |