Class: SixSaferpay::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/six_saferpay/models/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, id: nil, variant_id: nil, name: nil, category_name: nil, description: nil, quantity: nil, unit_price: nil, is_pre_order: nil, tax_rate: nil, tax_amount: nil, discount_amount: nil) ⇒ Item

Returns a new instance of Item.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/six_saferpay/models/item.rb', line 19

def initialize(
  type: nil,
  id: nil,
  variant_id: nil,
  name: nil,
  category_name: nil,
  description: nil,
  quantity: nil,
  unit_price: nil,
  is_pre_order: nil,
  tax_rate: nil,
  tax_amount: nil,
  discount_amount: nil
  )
  @type = type
  @id = id
  @variant_id = variant_id
  @name = name
  @category_name = category_name
  @description = description
  @quantity = quantity
  @unit_price = unit_price
  @is_pre_order = is_pre_order
  @tax_rate = tax_rate
  @tax_amount = tax_amount
  @discount_amount = discount_amount
end

Instance Attribute Details

#category_nameObject

Returns the value of attribute category_name.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def category_name
  @category_name
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def description
  @description
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def id
  @id
end

#is_pre_orderObject

Returns the value of attribute is_pre_order.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def is_pre_order
  @is_pre_order
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def name
  @name
end

#quantityObject

Returns the value of attribute quantity.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def quantity
  @quantity
end

#tax_amountObject

Returns the value of attribute tax_amount.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def tax_amount
  @tax_amount
end

#tax_rateObject

Returns the value of attribute tax_rate.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def tax_rate
  @tax_rate
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def type
  @type
end

#unit_priceObject

Returns the value of attribute unit_price.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def unit_price
  @unit_price
end

#variant_idObject

Returns the value of attribute variant_id.



4
5
6
# File 'lib/six_saferpay/models/item.rb', line 4

def variant_id
  @variant_id
end

Instance Method Details

#to_hashObject Also known as: to_h



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/six_saferpay/models/item.rb', line 47

def to_hash
  hash = Hash.new
  hash.merge!(type: @type) if @type
  hash.merge!(id: @id) if @id
  hash.merge!(variant_id: @variant_id) if @variant_id
  hash.merge!(name: @name) if @name
  hash.merge!(category_name: @category_name) if @category_name
  hash.merge!(description: @description) if @description
  hash.merge!(quantity: @quantity) if @quantity
  hash.merge!(unit_price: @unit_price) if @unit_price
  hash.merge!(is_pre_order: @is_pre_order) if !@is_pre_order.nil?
  hash.merge!(tax_rate: @tax_rate) if @tax_rate
  hash.merge!(tax_amount: @tax_amount) if @tax_amount
  hash.merge!(discount_amount: @discount_amount) if @discount_amount

  hash
end