class ProtonApi::EmergencyFundCalculatorRequest

Attributes

account_ids[RW]
aggregation_account_ids[RW]
client_id[RW]
current_emergency_fund_balance[RW]
debt_payments[RW]
emergency_fund_duration[RW]
food_costs[RW]
frequency_unit[RW]
housing_cost[RW]
insurance_payments[RW]
interest_rate[RW]
lookback_periods[RW]
other_expenses[RW]
savings_horizon[RW]
telecom_payments[RW]
transportation_costs[RW]
utility_payments[RW]

Public Class Methods

attribute_map() click to toggle source

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

# 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
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# 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.account_ids = 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.aggregation_account_ids = value
    end
  end
end
swagger_types() click to toggle source

Attribute type mapping.

# 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

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# 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 &&
      account_ids == o.account_ids &&
      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 &&
      aggregation_account_ids == o.aggregation_account_ids
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# 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) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# 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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# 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
current_emergency_fund_balance=(current_emergency_fund_balance) click to toggle source

Custom attribute writer method with validation @param [Object] current_emergency_fund_balance Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 361
def current_emergency_fund_balance=(current_emergency_fund_balance)
  if !current_emergency_fund_balance.nil? && current_emergency_fund_balance < 0
    fail ArgumentError, 'invalid value for "current_emergency_fund_balance", must be greater than or equal to 0.'
  end

  @current_emergency_fund_balance = current_emergency_fund_balance
end
debt_payments=(debt_payments) click to toggle source

Custom attribute writer method with validation @param [Object] debt_payments Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 331
def debt_payments=(debt_payments)
  if !debt_payments.nil? && debt_payments < 0
    fail ArgumentError, 'invalid value for "debt_payments", must be greater than or equal to 0.'
  end

  @debt_payments = debt_payments
end
emergency_fund_duration=(emergency_fund_duration) click to toggle source

Custom attribute writer method with validation @param [Object] emergency_fund_duration Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 411
def emergency_fund_duration=(emergency_fund_duration)
  if emergency_fund_duration.nil?
    fail ArgumentError, 'emergency_fund_duration cannot be nil'
  end

  if emergency_fund_duration < 1
    fail ArgumentError, 'invalid value for "emergency_fund_duration", must be greater than or equal to 1.'
  end

  @emergency_fund_duration = emergency_fund_duration
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 449
def eql?(o)
  self == o
end
food_costs=(food_costs) click to toggle source

Custom attribute writer method with validation @param [Object] food_costs Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 321
def food_costs=(food_costs)
  if !food_costs.nil? && food_costs < 0
    fail ArgumentError, 'invalid value for "food_costs", must be greater than or equal to 0.'
  end

  @food_costs = food_costs
end
frequency_unit=(frequency_unit) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] frequency_unit Object to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 351
def frequency_unit=(frequency_unit)
  validator = EnumAttributeValidator.new('String', ['year', 'six_months', 'quarter', 'month', 'two_weeks', 'week'])
  unless validator.valid?(frequency_unit)
    fail ArgumentError, 'invalid value for "frequency_unit", must be one of #{validator.allowable_values}.'
  end
  @frequency_unit = frequency_unit
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 455
def hash
  [client_id, savings_horizon, housing_cost, other_expenses, account_ids, 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, aggregation_account_ids].hash
end
housing_cost=(housing_cost) click to toggle source

Custom attribute writer method with validation @param [Object] housing_cost Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 301
def housing_cost=(housing_cost)
  if !housing_cost.nil? && housing_cost < 0
    fail ArgumentError, 'invalid value for "housing_cost", must be greater than or equal to 0.'
  end

  @housing_cost = housing_cost
end
insurance_payments=(insurance_payments) click to toggle source

Custom attribute writer method with validation @param [Object] insurance_payments Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 371
def insurance_payments=(insurance_payments)
  if !insurance_payments.nil? && insurance_payments < 0
    fail ArgumentError, 'invalid value for "insurance_payments", must be greater than or equal to 0.'
  end

  @insurance_payments = insurance_payments
end
interest_rate=(interest_rate) click to toggle source

Custom attribute writer method with validation @param [Object] interest_rate Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 401
def interest_rate=(interest_rate)
  if !interest_rate.nil? && interest_rate < 0
    fail ArgumentError, 'invalid value for "interest_rate", must be greater than or equal to 0.'
  end

  @interest_rate = interest_rate
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# 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
lookback_periods=(lookback_periods) click to toggle source

Custom attribute writer method with validation @param [Object] lookback_periods Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 341
def lookback_periods=(lookback_periods)
  if !lookback_periods.nil? && lookback_periods < 1
    fail ArgumentError, 'invalid value for "lookback_periods", must be greater than or equal to 1.'
  end

  @lookback_periods = lookback_periods
end
telecom_payments=(telecom_payments) click to toggle source

Custom attribute writer method with validation @param [Object] telecom_payments Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 381
def telecom_payments=(telecom_payments)
  if !telecom_payments.nil? && telecom_payments < 0
    fail ArgumentError, 'invalid value for "telecom_payments", must be greater than or equal to 0.'
  end

  @telecom_payments = telecom_payments
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 527
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# 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_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 521
def to_s
  to_hash.to_s
end
transportation_costs=(transportation_costs) click to toggle source

Custom attribute writer method with validation @param [Object] transportation_costs Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 391
def transportation_costs=(transportation_costs)
  if !transportation_costs.nil? && transportation_costs < 0
    fail ArgumentError, 'invalid value for "transportation_costs", must be greater than or equal to 0.'
  end

  @transportation_costs = transportation_costs
end
utility_payments=(utility_payments) click to toggle source

Custom attribute writer method with validation @param [Object] utility_payments Value to be assigned

# File lib/proton_api/models/emergency_fund_calculator_request.rb, line 311
def utility_payments=(utility_payments)
  if !utility_payments.nil? && utility_payments < 0
    fail ArgumentError, 'invalid value for "utility_payments", must be greater than or equal to 0.'
  end

  @utility_payments = utility_payments
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# 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