Class: KondutoItem

Inherits:
Object
  • Object
show all
Defined in:
lib/konduto-ruby/konduto_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#categoryObject

Returns the value of attribute category.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def category
  @category
end

#created_atObject

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

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def description
  @description
end

#discountObject

Returns the value of attribute discount.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def discount
  @discount
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def name
  @name
end

#product_codeObject

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

#quantityObject

Returns the value of attribute quantity.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def quantity
  @quantity
end

#skuObject

Returns the value of attribute sku.



2
3
4
# File 'lib/konduto-ruby/konduto_item.rb', line 2

def sku
  @sku
end

#unit_costObject

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_hashObject



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_jsonObject



27
28
29
# File 'lib/konduto-ruby/konduto_item.rb', line 27

def to_json
  self.to_hash.to_json
end