Class: AdvancedBilling::CreditAccountBalanceChanged

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

Overview

CreditAccountBalanceChanged Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(reason:, service_credit_account_balance_in_cents:, service_credit_balance_change_in_cents:, currency_code:, at_time:, additional_properties: {}) ⇒ CreditAccountBalanceChanged

Returns a new instance of CreditAccountBalanceChanged.



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

def initialize(reason:, service_credit_account_balance_in_cents:,
               service_credit_balance_change_in_cents:, currency_code:,
               at_time:, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @reason = reason
  @service_credit_account_balance_in_cents = 
  @service_credit_balance_change_in_cents = service_credit_balance_change_in_cents
  @currency_code = currency_code
  @at_time = at_time
end

Instance Attribute Details

#at_timeDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


31
32
33
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 31

def at_time
  @at_time
end

#currency_codeString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 27

def currency_code
  @currency_code
end

#reasonString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 15

def reason
  @reason
end

#service_credit_account_balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def 
  @service_credit_account_balance_in_cents
end

#service_credit_balance_change_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


23
24
25
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 23

def service_credit_balance_change_in_cents
  @service_credit_balance_change_in_cents
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reason = hash.key?('reason') ? hash['reason'] : nil
   =
    hash.key?('service_credit_account_balance_in_cents') ? hash['service_credit_account_balance_in_cents'] : nil
  service_credit_balance_change_in_cents =
    hash.key?('service_credit_balance_change_in_cents') ? hash['service_credit_balance_change_in_cents'] : nil
  currency_code = hash.key?('currency_code') ? hash['currency_code'] : nil
  at_time = if hash.key?('at_time')
              (DateTimeHelper.from_rfc3339(hash['at_time']) if hash['at_time'])
            end

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  CreditAccountBalanceChanged.new(reason: reason,
                                  service_credit_account_balance_in_cents: ,
                                  service_credit_balance_change_in_cents: service_credit_balance_change_in_cents,
                                  currency_code: currency_code,
                                  at_time: at_time,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reason'] = 'reason'
  @_hash['service_credit_account_balance_in_cents'] =
    'service_credit_account_balance_in_cents'
  @_hash['service_credit_balance_change_in_cents'] =
    'service_credit_balance_change_in_cents'
  @_hash['currency_code'] = 'currency_code'
  @_hash['at_time'] = 'at_time'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



47
48
49
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 47

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 104

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.service_credit_balance_change_in_cents,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.currency_code,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.at_time,
                              ->(val) { val.instance_of? DateTime })
    )
  end

  return false unless value.instance_of? Hash

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

Instance Method Details

#to_custom_at_timeObject



98
99
100
# File 'lib/advanced_billing/models/credit_account_balance_changed.rb', line 98

def to_custom_at_time
  DateTimeHelper.to_rfc3339(at_time)
end