class ProtonApi::LifeInsuranceNeedsCalculatorRequest

Attributes

beneficiary_bequest_config[RW]
benefit_amount_rounding[RW]
children_education_config[RW]
client_id[RW]
education_inflation_rate[RW]
end_of_life_expenses[RW]
existing_life_insurance[RW]
general_inflation_rate[RW]
income_config[RW]
interest_rate[RW]
liquid_assets[RW]
margin_of_error[RW]
mortgage_balance[RW]
other_debt[RW]
tax_rate[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/life_insurance_needs_calculator_request.rb, line 48
def self.attribute_map
  {
    :'client_id' => :'client_id',
    :'beneficiary_bequest_config' => :'beneficiary_bequest_config',
    :'education_inflation_rate' => :'education_inflation_rate',
    :'margin_of_error' => :'margin_of_error',
    :'liquid_assets' => :'liquid_assets',
    :'tax_rate' => :'tax_rate',
    :'other_debt' => :'other_debt',
    :'end_of_life_expenses' => :'end_of_life_expenses',
    :'existing_life_insurance' => :'existing_life_insurance',
    :'income_config' => :'income_config',
    :'mortgage_balance' => :'mortgage_balance',
    :'benefit_amount_rounding' => :'benefit_amount_rounding',
    :'interest_rate' => :'interest_rate',
    :'children_education_config' => :'children_education_config',
    :'general_inflation_rate' => :'general_inflation_rate'
  }
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/life_insurance_needs_calculator_request.rb, line 91
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?(:'beneficiary_bequest_config')
    if (value = attributes[:'beneficiary_bequest_config']).is_a?(Array)
      self.beneficiary_bequest_config = value
    end
  end

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

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

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

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

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

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

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

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

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

  if attributes.has_key?(:'benefit_amount_rounding')
    self.benefit_amount_rounding = attributes[:'benefit_amount_rounding']
  else
    self.benefit_amount_rounding = 0
  end

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

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

  if attributes.has_key?(:'general_inflation_rate')
    self.general_inflation_rate = attributes[:'general_inflation_rate']
  else
    self.general_inflation_rate = 0.0
  end
end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/proton_api/models/life_insurance_needs_calculator_request.rb, line 69
def self.swagger_types
  {
    :'client_id' => :'String',
    :'beneficiary_bequest_config' => :'Array<BeneficiaryBequestConfig>',
    :'education_inflation_rate' => :'Float',
    :'margin_of_error' => :'Float',
    :'liquid_assets' => :'Float',
    :'tax_rate' => :'Float',
    :'other_debt' => :'Float',
    :'end_of_life_expenses' => :'Float',
    :'existing_life_insurance' => :'Float',
    :'income_config' => :'Array<IncomeConfig>',
    :'mortgage_balance' => :'Float',
    :'benefit_amount_rounding' => :'Integer',
    :'interest_rate' => :'Float',
    :'children_education_config' => :'Array<ChildrenEducationConfig>',
    :'general_inflation_rate' => :'Float'
  }
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/life_insurance_needs_calculator_request.rb, line 381
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      client_id == o.client_id &&
      beneficiary_bequest_config == o.beneficiary_bequest_config &&
      education_inflation_rate == o.education_inflation_rate &&
      margin_of_error == o.margin_of_error &&
      liquid_assets == o.liquid_assets &&
      tax_rate == o.tax_rate &&
      other_debt == o.other_debt &&
      end_of_life_expenses == o.end_of_life_expenses &&
      existing_life_insurance == o.existing_life_insurance &&
      income_config == o.income_config &&
      mortgage_balance == o.mortgage_balance &&
      benefit_amount_rounding == o.benefit_amount_rounding &&
      interest_rate == o.interest_rate &&
      children_education_config == o.children_education_config &&
      general_inflation_rate == o.general_inflation_rate
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/life_insurance_needs_calculator_request.rb, line 436
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/life_insurance_needs_calculator_request.rb, line 500
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
benefit_amount_rounding=(benefit_amount_rounding) click to toggle source

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

# File lib/proton_api/models/life_insurance_needs_calculator_request.rb, line 343
def benefit_amount_rounding=(benefit_amount_rounding)
  if !benefit_amount_rounding.nil? && benefit_amount_rounding > 12
    fail ArgumentError, 'invalid value for "benefit_amount_rounding", must be smaller than or equal to 12.'
  end

  if !benefit_amount_rounding.nil? && benefit_amount_rounding < 0
    fail ArgumentError, 'invalid value for "benefit_amount_rounding", must be greater than or equal to 0.'
  end

  @benefit_amount_rounding = benefit_amount_rounding
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/life_insurance_needs_calculator_request.rb, line 416
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
education_inflation_rate=(education_inflation_rate) click to toggle source

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

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

  @education_inflation_rate = education_inflation_rate
end
end_of_life_expenses=(end_of_life_expenses) click to toggle source

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

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

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

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

# File lib/proton_api/models/life_insurance_needs_calculator_request.rb, line 403
def eql?(o)
  self == o
end
existing_life_insurance=(existing_life_insurance) click to toggle source

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

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

  @existing_life_insurance = existing_life_insurance
end
general_inflation_rate=(general_inflation_rate) click to toggle source

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

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

  @general_inflation_rate = general_inflation_rate
end
hash() click to toggle source

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

# File lib/proton_api/models/life_insurance_needs_calculator_request.rb, line 409
def hash
  [client_id, beneficiary_bequest_config, education_inflation_rate, margin_of_error, liquid_assets, tax_rate, other_debt, end_of_life_expenses, existing_life_insurance, income_config, mortgage_balance, benefit_amount_rounding, interest_rate, children_education_config, general_inflation_rate].hash
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/life_insurance_needs_calculator_request.rb, line 357
def interest_rate=(interest_rate)
  if interest_rate.nil?
    fail ArgumentError, 'interest_rate cannot be nil'
  end

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

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

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

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

  @liquid_assets = liquid_assets
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/life_insurance_needs_calculator_request.rb, line 176
def list_invalid_properties
  invalid_properties = Array.new
  if !@education_inflation_rate.nil? && @education_inflation_rate < -1
    invalid_properties.push('invalid value for "education_inflation_rate", must be greater than or equal to -1.')
  end

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

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

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

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

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

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

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

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

  if !@benefit_amount_rounding.nil? && @benefit_amount_rounding > 12
    invalid_properties.push('invalid value for "benefit_amount_rounding", must be smaller than or equal to 12.')
  end

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

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

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

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

  invalid_properties
end
margin_of_error=(margin_of_error) click to toggle source

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

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

  @margin_of_error = margin_of_error
end
mortgage_balance=(mortgage_balance) click to toggle source

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

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

  @mortgage_balance = mortgage_balance
end
other_debt=(other_debt) click to toggle source

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

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

  @other_debt = other_debt
end
tax_rate=(tax_rate) click to toggle source

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

# File lib/proton_api/models/life_insurance_needs_calculator_request.rb, line 289
def tax_rate=(tax_rate)
  if !tax_rate.nil? && tax_rate > 1
    fail ArgumentError, 'invalid value for "tax_rate", must be smaller than or equal to 1.'
  end

  if !tax_rate.nil? && tax_rate < 0
    fail ArgumentError, 'invalid value for "tax_rate", must be greater than or equal to 0.'
  end

  @tax_rate = tax_rate
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/life_insurance_needs_calculator_request.rb, line 481
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/life_insurance_needs_calculator_request.rb, line 487
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/life_insurance_needs_calculator_request.rb, line 475
def to_s
  to_hash.to_s
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/life_insurance_needs_calculator_request.rb, line 239
def valid?
  return false if !@education_inflation_rate.nil? && @education_inflation_rate < -1
  return false if !@margin_of_error.nil? && @margin_of_error < 0
  return false if !@liquid_assets.nil? && @liquid_assets < 0
  return false if !@tax_rate.nil? && @tax_rate > 1
  return false if !@tax_rate.nil? && @tax_rate < 0
  return false if !@other_debt.nil? && @other_debt < 0
  return false if !@end_of_life_expenses.nil? && @end_of_life_expenses < 0
  return false if !@existing_life_insurance.nil? && @existing_life_insurance < 0
  return false if !@mortgage_balance.nil? && @mortgage_balance < 0
  return false if !@benefit_amount_rounding.nil? && @benefit_amount_rounding > 12
  return false if !@benefit_amount_rounding.nil? && @benefit_amount_rounding < 0
  return false if @interest_rate.nil?
  return false if @interest_rate < -1
  return false if !@general_inflation_rate.nil? && @general_inflation_rate < -1
  true
end