Class: AdvancedBilling::PrePayment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/pre_payment.rb

Overview

PrePayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(subscription_id = SKIP, amount_in_cents = SKIP, ending_balance_in_cents = SKIP) ⇒ PrePayment

Returns a new instance of PrePayment.



49
50
51
52
53
54
# File 'lib/advanced_billing/models/pre_payment.rb', line 49

def initialize(subscription_id = SKIP, amount_in_cents = SKIP,
               ending_balance_in_cents = SKIP)
  @subscription_id = subscription_id unless subscription_id == SKIP
  @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP
  @ending_balance_in_cents = ending_balance_in_cents unless ending_balance_in_cents == SKIP
end

Instance Attribute Details

#amount_in_centsString

The amount in cents of the prepayment that was created as a result of this payment.

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/pre_payment.rb', line 19

def amount_in_cents
  @amount_in_cents
end

#ending_balance_in_centsString

The total balance of the prepayment account for this subscription including any prior prepayments

Returns:

  • (String)


24
25
26
# File 'lib/advanced_billing/models/pre_payment.rb', line 24

def ending_balance_in_cents
  @ending_balance_in_cents
end

#subscription_idString

The subscription id for the prepayment account

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/pre_payment.rb', line 14

def subscription_id
  @subscription_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/pre_payment.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  ending_balance_in_cents =
    hash.key?('ending_balance_in_cents') ? hash['ending_balance_in_cents'] : SKIP

  # Create object from extracted values.
  PrePayment.new(subscription_id,
                 amount_in_cents,
                 ending_balance_in_cents)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/advanced_billing/models/pre_payment.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['amount_in_cents'] = 'amount_in_cents'
  @_hash['ending_balance_in_cents'] = 'ending_balance_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/advanced_billing/models/pre_payment.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/pre_payment.rb', line 36

def self.optionals
  %w[
    subscription_id
    amount_in_cents
    ending_balance_in_cents
  ]
end