Class: ProtonApi::EmergencyFundCalculatorRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/proton_api/models/emergency_fund_calculator_request.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ EmergencyFundCalculatorRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 121

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'client_id')
    self.client_id = attributes[:'client_id']
  end

  if attributes.has_key?(:'savings_horizon')
    if (value = attributes[:'savings_horizon']).is_a?(Array)
      self.savings_horizon = value
    end
  end

  if attributes.has_key?(:'housing_cost')
    self.housing_cost = attributes[:'housing_cost']
  else
    self.housing_cost = 0.0
  end

  if attributes.has_key?(:'other_expenses')
    self.other_expenses = attributes[:'other_expenses']
  end

  if attributes.has_key?(:'account_ids')
    if (value = attributes[:'account_ids']).is_a?(Array)
      self. = value
    end
  end

  if attributes.has_key?(:'utility_payments')
    self.utility_payments = attributes[:'utility_payments']
  else
    self.utility_payments = 0.0
  end

  if attributes.has_key?(:'food_costs')
    self.food_costs = attributes[:'food_costs']
  else
    self.food_costs = 0.0
  end

  if attributes.has_key?(:'debt_payments')
    self.debt_payments = attributes[:'debt_payments']
  else
    self.debt_payments = 0.0
  end

  if attributes.has_key?(:'lookback_periods')
    self.lookback_periods = attributes[:'lookback_periods']
  else
    self.lookback_periods = 3
  end

  if attributes.has_key?(:'frequency_unit')
    self.frequency_unit = attributes[:'frequency_unit']
  else
    self.frequency_unit = 'month'
  end

  if attributes.has_key?(:'current_emergency_fund_balance')
    self.current_emergency_fund_balance = attributes[:'current_emergency_fund_balance']
  else
    self.current_emergency_fund_balance = 0.0
  end

  if attributes.has_key?(:'insurance_payments')
    self.insurance_payments = attributes[:'insurance_payments']
  else
    self.insurance_payments = 0.0
  end

  if attributes.has_key?(:'telecom_payments')
    self.telecom_payments = attributes[:'telecom_payments']
  else
    self.telecom_payments = 0.0
  end

  if attributes.has_key?(:'transportation_costs')
    self.transportation_costs = attributes[:'transportation_costs']
  else
    self.transportation_costs = 0.0
  end

  if attributes.has_key?(:'interest_rate')
    self.interest_rate = attributes[:'interest_rate']
  else
    self.interest_rate = 0.0
  end

  if attributes.has_key?(:'emergency_fund_duration')
    self.emergency_fund_duration = attributes[:'emergency_fund_duration']
  end

  if attributes.has_key?(:'aggregation_account_ids')
    if (value = attributes[:'aggregation_account_ids']).is_a?(Array)
      self. = value
    end
  end
end

Instance Attribute Details

#account_idsObject

Returns the value of attribute account_ids.



25
26
27
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 25

def 
  @account_ids
end

#aggregation_account_idsObject

Returns the value of attribute aggregation_account_ids.



49
50
51
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 49

def 
  @aggregation_account_ids
end

#client_idObject

Returns the value of attribute client_id.



17
18
19
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 17

def client_id
  @client_id
end

#current_emergency_fund_balanceObject

Returns the value of attribute current_emergency_fund_balance.



37
38
39
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 37

def current_emergency_fund_balance
  @current_emergency_fund_balance
end

#debt_paymentsObject

Returns the value of attribute debt_payments.



31
32
33
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 31

def debt_payments
  @debt_payments
end

#emergency_fund_durationObject

Returns the value of attribute emergency_fund_duration.



47
48
49
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 47

def emergency_fund_duration
  @emergency_fund_duration
end

#food_costsObject

Returns the value of attribute food_costs.



29
30
31
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 29

def food_costs
  @food_costs
end

#frequency_unitObject

Returns the value of attribute frequency_unit.



35
36
37
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 35

def frequency_unit
  @frequency_unit
end

#housing_costObject

Returns the value of attribute housing_cost.



21
22
23
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 21

def housing_cost
  @housing_cost
end

#insurance_paymentsObject

Returns the value of attribute insurance_payments.



39
40
41
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 39

def insurance_payments
  @insurance_payments
end

#interest_rateObject

Returns the value of attribute interest_rate.



45
46
47
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 45

def interest_rate
  @interest_rate
end

#lookback_periodsObject

Returns the value of attribute lookback_periods.



33
34
35
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 33

def lookback_periods
  @lookback_periods
end

#other_expensesObject

Returns the value of attribute other_expenses.



23
24
25
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 23

def other_expenses
  @other_expenses
end

#savings_horizonObject

Returns the value of attribute savings_horizon.



19
20
21
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 19

def savings_horizon
  @savings_horizon
end

#telecom_paymentsObject

Returns the value of attribute telecom_payments.



41
42
43
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 41

def telecom_payments
  @telecom_payments
end

#transportation_costsObject

Returns the value of attribute transportation_costs.



43
44
45
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 43

def transportation_costs
  @transportation_costs
end

#utility_paymentsObject

Returns the value of attribute utility_payments.



27
28
29
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 27

def utility_payments
  @utility_payments
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 74

def self.attribute_map
  {
    :'client_id' => :'client_id',
    :'savings_horizon' => :'savings_horizon',
    :'housing_cost' => :'housing_cost',
    :'other_expenses' => :'other_expenses',
    :'account_ids' => :'account_ids',
    :'utility_payments' => :'utility_payments',
    :'food_costs' => :'food_costs',
    :'debt_payments' => :'debt_payments',
    :'lookback_periods' => :'lookback_periods',
    :'frequency_unit' => :'frequency_unit',
    :'current_emergency_fund_balance' => :'current_emergency_fund_balance',
    :'insurance_payments' => :'insurance_payments',
    :'telecom_payments' => :'telecom_payments',
    :'transportation_costs' => :'transportation_costs',
    :'interest_rate' => :'interest_rate',
    :'emergency_fund_duration' => :'emergency_fund_duration',
    :'aggregation_account_ids' => :'aggregation_account_ids'
  }
end

.swagger_typesObject

Attribute type mapping.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 97

def self.swagger_types
  {
    :'client_id' => :'String',
    :'savings_horizon' => :'Array<Integer>',
    :'housing_cost' => :'Float',
    :'other_expenses' => :'Object',
    :'account_ids' => :'Array<String>',
    :'utility_payments' => :'Float',
    :'food_costs' => :'Float',
    :'debt_payments' => :'Float',
    :'lookback_periods' => :'Integer',
    :'frequency_unit' => :'String',
    :'current_emergency_fund_balance' => :'Float',
    :'insurance_payments' => :'Float',
    :'telecom_payments' => :'Float',
    :'transportation_costs' => :'Float',
    :'interest_rate' => :'Float',
    :'emergency_fund_duration' => :'Integer',
    :'aggregation_account_ids' => :'Array<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 425

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      client_id == o.client_id &&
      savings_horizon == o.savings_horizon &&
      housing_cost == o.housing_cost &&
      other_expenses == o.other_expenses &&
       == o. &&
      utility_payments == o.utility_payments &&
      food_costs == o.food_costs &&
      debt_payments == o.debt_payments &&
      lookback_periods == o.lookback_periods &&
      frequency_unit == o.frequency_unit &&
      current_emergency_fund_balance == o.current_emergency_fund_balance &&
      insurance_payments == o.insurance_payments &&
      telecom_payments == o.telecom_payments &&
      transportation_costs == o.transportation_costs &&
      interest_rate == o.interest_rate &&
      emergency_fund_duration == o.emergency_fund_duration &&
       == o.
end

#_deserialize(type, value) ⇒ Object

Returns Deserialized data.

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 482

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    value
  when :Date
    value
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = ProtonApi.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 546

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 462

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


449
450
451
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 449

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



455
456
457
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 455

def hash
  [client_id, savings_horizon, housing_cost, other_expenses, , utility_payments, food_costs, debt_payments, lookback_periods, frequency_unit, current_emergency_fund_balance, insurance_payments, telecom_payments, transportation_costs, interest_rate, emergency_fund_duration, ].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 226

def list_invalid_properties
  invalid_properties = Array.new
  if !@housing_cost.nil? && @housing_cost < 0
    invalid_properties.push('invalid value for "housing_cost", must be greater than or equal to 0.')
  end

  if !@utility_payments.nil? && @utility_payments < 0
    invalid_properties.push('invalid value for "utility_payments", must be greater than or equal to 0.')
  end

  if !@food_costs.nil? && @food_costs < 0
    invalid_properties.push('invalid value for "food_costs", must be greater than or equal to 0.')
  end

  if !@debt_payments.nil? && @debt_payments < 0
    invalid_properties.push('invalid value for "debt_payments", must be greater than or equal to 0.')
  end

  if !@lookback_periods.nil? && @lookback_periods < 1
    invalid_properties.push('invalid value for "lookback_periods", must be greater than or equal to 1.')
  end

  if !@current_emergency_fund_balance.nil? && @current_emergency_fund_balance < 0
    invalid_properties.push('invalid value for "current_emergency_fund_balance", must be greater than or equal to 0.')
  end

  if !@insurance_payments.nil? && @insurance_payments < 0
    invalid_properties.push('invalid value for "insurance_payments", must be greater than or equal to 0.')
  end

  if !@telecom_payments.nil? && @telecom_payments < 0
    invalid_properties.push('invalid value for "telecom_payments", must be greater than or equal to 0.')
  end

  if !@transportation_costs.nil? && @transportation_costs < 0
    invalid_properties.push('invalid value for "transportation_costs", must be greater than or equal to 0.')
  end

  if !@interest_rate.nil? && @interest_rate < 0
    invalid_properties.push('invalid value for "interest_rate", must be greater than or equal to 0.')
  end

  if @emergency_fund_duration.nil?
    invalid_properties.push('invalid value for "emergency_fund_duration", emergency_fund_duration cannot be nil.')
  end

  if @emergency_fund_duration < 1
    invalid_properties.push('invalid value for "emergency_fund_duration", must be greater than or equal to 1.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



527
528
529
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 527

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



533
534
535
536
537
538
539
540
541
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 533

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns String presentation of the object.

Returns:

  • (String)

    String presentation of the object



521
522
523
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 521

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/proton_api/models/emergency_fund_calculator_request.rb', line 281

def valid?
  return false if !@housing_cost.nil? && @housing_cost < 0
  return false if !@utility_payments.nil? && @utility_payments < 0
  return false if !@food_costs.nil? && @food_costs < 0
  return false if !@debt_payments.nil? && @debt_payments < 0
  return false if !@lookback_periods.nil? && @lookback_periods < 1
  frequency_unit_validator = EnumAttributeValidator.new('String', ['year', 'six_months', 'quarter', 'month', 'two_weeks', 'week'])
  return false unless frequency_unit_validator.valid?(@frequency_unit)
  return false if !@current_emergency_fund_balance.nil? && @current_emergency_fund_balance < 0
  return false if !@insurance_payments.nil? && @insurance_payments < 0
  return false if !@telecom_payments.nil? && @telecom_payments < 0
  return false if !@transportation_costs.nil? && @transportation_costs < 0
  return false if !@interest_rate.nil? && @interest_rate < 0
  return false if @emergency_fund_duration.nil?
  return false if @emergency_fund_duration < 1
  true
end