Class: CloudRailSi::Types::Charge
- Inherits:
-
SandboxObject
- Object
- SandboxObject
- CloudRailSi::Types::Charge
- Defined in:
- lib/cloudrail_si/types/Charge.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#refunded ⇒ Object
readonly
Returns the value of attribute refunded.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(amount, created, currency, id, refunded, source, status) ⇒ Charge
constructor
A new instance of Charge.
Methods inherited from SandboxObject
Constructor Details
#initialize(amount, created, currency, id, refunded, source, status) ⇒ Charge
Returns a new instance of Charge.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cloudrail_si/types/Charge.rb', line 8 def initialize(amount, created, currency, id, refunded, source, status) super() @amount = amount @created = created @currency = currency.upcase @id = id @refunded = !!refunded @source = source @status = status @currency = currency.upcase @refunded = !!refunded if (currency.nil? || id.nil? || source.nil? || status.nil? || refunded.nil?) raise Errors::IllegalArgumentError.new('One or more parameters are nil.') elsif (amount < 0) raise Errors::IllegalArgumentError.new('The amount can not be less than 0.') elsif (currency.length != 3) raise Errors::IllegalArgumentError.new('The passed currency is invalid.') elsif (["pending", "succeeded", "failed"].index(status) < 0) raise Errors::IllegalArgumentError.new("The passed state should be one of: 'pending', 'succeeded' or 'failed'.") end end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def amount @amount end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def created @created end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def currency @currency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def id @id end |
#refunded ⇒ Object (readonly)
Returns the value of attribute refunded.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def refunded @refunded end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def source @source end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/cloudrail_si/types/Charge.rb', line 6 def status @status end |