Class: CloudRailSi::Types::Charge

Inherits:
SandboxObject show all
Defined in:
lib/cloudrail_si/types/Charge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SandboxObject

#get, #set

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

#amountObject (readonly)

Returns the value of attribute amount.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def amount
  @amount
end

#createdObject (readonly)

Returns the value of attribute created.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def created
  @created
end

#currencyObject (readonly)

Returns the value of attribute currency.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def id
  @id
end

#refundedObject (readonly)

Returns the value of attribute refunded.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def refunded
  @refunded
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def source
  @source
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/cloudrail_si/types/Charge.rb', line 6

def status
  @status
end