Class: KondutoItem
- Inherits:
-
Object
- Object
- KondutoItem
- Defined in:
- lib/konduto-ruby/konduto_item.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#discount ⇒ Object
Returns the value of attribute discount.
-
#name ⇒ Object
Returns the value of attribute name.
-
#product_code ⇒ Object
Returns the value of attribute product_code.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#sku ⇒ Object
Returns the value of attribute sku.
-
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
Instance Method Summary collapse
-
#initialize(*args) ⇒ KondutoItem
constructor
A new instance of KondutoItem.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(*args) ⇒ KondutoItem
Returns a new instance of KondutoItem.
4 5 6 7 8 9 10 |
# File 'lib/konduto-ruby/konduto_item.rb', line 4 def initialize(*args) unless args[0].nil? args[0].each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def category @category end |
#created_at ⇒ Object
Returns the value of attribute created_at.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def discount @discount end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def name @name end |
#product_code ⇒ Object
Returns the value of attribute product_code.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def product_code @product_code end |
#quantity ⇒ Object
Returns the value of attribute quantity.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def quantity @quantity end |
#sku ⇒ Object
Returns the value of attribute sku.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def sku @sku end |
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
2 3 4 |
# File 'lib/konduto-ruby/konduto_item.rb', line 2 def unit_cost @unit_cost end |
Instance Method Details
#to_hash ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/konduto-ruby/konduto_item.rb', line 12 def to_hash hash = { sku: self.sku, category: self.category, name: self.name, description: self.description, product_code: self.product_code, unit_cost: self.unit_cost, quantity: self.quantity, discount: self.discount, created_at: self.created_at } KondutoUtils.remove_nil_keys_from_hash(hash) end |
#to_json ⇒ Object
27 28 29 |
# File 'lib/konduto-ruby/konduto_item.rb', line 27 def to_json self.to_hash.to_json end |