Class: AdvancedBilling::InvoicePrePayment

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

Overview

InvoicePrePayment 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, additional_properties: {}) ⇒ InvoicePrePayment

Returns a new instance of InvoicePrePayment.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/advanced_billing/models/invoice_pre_payment.rb', line 49

def initialize(subscription_id: SKIP, amount_in_cents: SKIP,
               ending_balance_in_cents: SKIP, additional_properties: {})
  @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

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#amount_in_centsInteger

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

Returns:

  • (Integer)


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

def amount_in_cents
  @amount_in_cents
end

#ending_balance_in_centsInteger

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

Returns:

  • (Integer)


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

def ending_balance_in_cents
  @ending_balance_in_cents
end

#subscription_idInteger

The subscription id for the prepayment account

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/invoice_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.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/advanced_billing/models/invoice_pre_payment.rb', line 62

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

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  InvoicePrePayment.new(subscription_id: subscription_id,
                        amount_in_cents: amount_in_cents,
                        ending_balance_in_cents: ending_balance_in_cents,
                        additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/advanced_billing/models/invoice_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/invoice_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/invoice_pre_payment.rb', line 36

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