Class: AdvancedBilling::PrepaymentAccountBalanceChanged

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

Overview

PrepaymentAccountBalanceChanged Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(reason:, prepayment_account_balance_in_cents:, prepayment_balance_change_in_cents:, currency_code:, additional_properties: {}) ⇒ PrepaymentAccountBalanceChanged

Returns a new instance of PrepaymentAccountBalanceChanged.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 50

def initialize(reason:, prepayment_account_balance_in_cents:,
               prepayment_balance_change_in_cents:, currency_code:,
               additional_properties: {})
  @reason = reason
  @prepayment_account_balance_in_cents = 
  @prepayment_balance_change_in_cents = prepayment_balance_change_in_cents
  @currency_code = currency_code

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

Instance Attribute Details

#currency_codeString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 26

def currency_code
  @currency_code
end

#prepayment_account_balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 18

def 
  @prepayment_account_balance_in_cents
end

#prepayment_balance_change_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 22

def prepayment_balance_change_in_cents
  @prepayment_balance_change_in_cents
end

#reasonString

TODO: Write general description for this method

Returns:

  • (String)


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

def reason
  @reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reason = hash.key?('reason') ? hash['reason'] : nil
   =
    hash.key?('prepayment_account_balance_in_cents') ? hash['prepayment_account_balance_in_cents'] : nil
  prepayment_balance_change_in_cents =
    hash.key?('prepayment_balance_change_in_cents') ? hash['prepayment_balance_change_in_cents'] : nil
  currency_code = hash.key?('currency_code') ? hash['currency_code'] : nil

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

  # Create object from extracted values.
  PrepaymentAccountBalanceChanged.new(reason: reason,
                                      prepayment_account_balance_in_cents: ,
                                      prepayment_balance_change_in_cents: prepayment_balance_change_in_cents,
                                      currency_code: currency_code,
                                      additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reason'] = 'reason'
  @_hash['prepayment_account_balance_in_cents'] =
    'prepayment_account_balance_in_cents'
  @_hash['prepayment_balance_change_in_cents'] =
    'prepayment_balance_change_in_cents'
  @_hash['currency_code'] = 'currency_code'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 41

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/advanced_billing/models/prepayment_account_balance_changed.rb', line 89

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.reason,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.prepayment_balance_change_in_cents,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.currency_code,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['reason'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['prepayment_account_balance_in_cents'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['prepayment_balance_change_in_cents'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['currency_code'],
                            ->(val) { val.instance_of? String })
  )
end