Class: Transbank::Onepay::Item
- Inherits:
-
Object
- Object
- Transbank::Onepay::Item
- Includes:
- Utils::JSONUtils
- Defined in:
- lib/transbank/sdk/onepay/models/item.rb
Instance Attribute Summary collapse
-
#additional_data ⇒ Object
Merchant might want to add.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#description ⇒ String
An item’s description.
-
#expire ⇒ Object
Returns the value of attribute expire.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
-
#==(another_item) ⇒ boolean
Override == to allow comparison between [Item]s.
-
#eql?(another_item) ⇒ Boolean
Alias for #==.
-
#initialize(opts = {}) ⇒ Item
constructor
Merchant might want to add.
-
#total ⇒ Numeric
Return the total amount to pay for the Item, that is, amount * quantity.
Methods included from Utils::JSONUtils
included, #jsonify, #transform_hash_keys, #underscore
Constructor Details
#initialize(opts = {}) ⇒ Item
Merchant might want to add
30 31 32 33 34 35 36 37 38 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 30 def initialize(opts = {}) raise Errors::ItemError, 'Item must be a Hash' unless opts.is_a? Hash opts = transform_hash_keys opts self.description = opts.fetch(:description) self.quantity = opts.fetch(:quantity) self.amount = opts.fetch(:amount) self.additional_data = opts.fetch(:additional_data, nil) self.expire = opts.fetch(:expire, nil) end |
Instance Attribute Details
#additional_data ⇒ Object
Merchant might want to add
18 19 20 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 18 def additional_data @additional_data end |
#amount ⇒ Object
Returns the value of attribute amount.
14 15 16 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 14 def amount @amount end |
#description ⇒ String
Returns An item’s description.
8 9 10 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 8 def description @description end |
#expire ⇒ Object
Returns the value of attribute expire.
21 22 23 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 21 def expire @expire end |
#quantity ⇒ Object
Returns the value of attribute quantity.
11 12 13 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 11 def quantity @quantity end |
Instance Method Details
#==(another_item) ⇒ boolean
Override == to allow comparison between [Item]s
89 90 91 92 93 94 95 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 89 def ==(another_item) self.description == another_item.description && self.quantity == another_item.quantity && self.amount == another_item.amount && self.additional_data == another_item.additional_data && self.expire == another_item.expire end |
#eql?(another_item) ⇒ Boolean
Alias for #==
98 99 100 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 98 def eql?(another_item) self.==(another_item) end |
#total ⇒ Numeric
Return the total amount to pay for the Item, that is, amount * quantity
83 84 85 |
# File 'lib/transbank/sdk/onepay/models/item.rb', line 83 def total self.quantity * self.amount end |