Class: ThePlaidApi::FixedIncome

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/fixed_income.rb

Overview

Details about the fixed income security.

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(yield_rate:, maturity_date:, issue_date:, face_value:, additional_properties: nil) ⇒ FixedIncome

Returns a new instance of FixedIncome.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/the_plaid_api/models/fixed_income.rb', line 56

def initialize(yield_rate:, maturity_date:, issue_date:, face_value:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @yield_rate = yield_rate
  @maturity_date = maturity_date
  @issue_date = issue_date
  @face_value = face_value
  @additional_properties = additional_properties
end

Instance Attribute Details

#face_valueFloat

The face value that is paid upon maturity of the fixed income security, per unit of security.

Returns:

  • (Float)


29
30
31
# File 'lib/the_plaid_api/models/fixed_income.rb', line 29

def face_value
  @face_value
end

#issue_dateDate

The issue date for this fixed income security, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (Date)


24
25
26
# File 'lib/the_plaid_api/models/fixed_income.rb', line 24

def issue_date
  @issue_date
end

#maturity_dateDate

The maturity date for this fixed income security, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (Date)


19
20
21
# File 'lib/the_plaid_api/models/fixed_income.rb', line 19

def maturity_date
  @maturity_date
end

#yield_rateYieldRate

Details about a fixed income security’s expected rate of return.

Returns:



14
15
16
# File 'lib/the_plaid_api/models/fixed_income.rb', line 14

def yield_rate
  @yield_rate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/the_plaid_api/models/fixed_income.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  yield_rate = YieldRate.from_hash(hash['yield_rate']) if hash['yield_rate']
  maturity_date = hash.key?('maturity_date') ? hash['maturity_date'] : nil
  issue_date = hash.key?('issue_date') ? hash['issue_date'] : nil
  face_value = hash.key?('face_value') ? hash['face_value'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  FixedIncome.new(yield_rate: yield_rate,
                  maturity_date: maturity_date,
                  issue_date: issue_date,
                  face_value: face_value,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/the_plaid_api/models/fixed_income.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['yield_rate'] = 'yield_rate'
  @_hash['maturity_date'] = 'maturity_date'
  @_hash['issue_date'] = 'issue_date'
  @_hash['face_value'] = 'face_value'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
50
51
52
53
54
# File 'lib/the_plaid_api/models/fixed_income.rb', line 47

def self.nullables
  %w[
    yield_rate
    maturity_date
    issue_date
    face_value
  ]
end

.optionalsObject

An array for optional fields



42
43
44
# File 'lib/the_plaid_api/models/fixed_income.rb', line 42

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
# File 'lib/the_plaid_api/models/fixed_income.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} yield_rate: #{@yield_rate.inspect}, maturity_date:"\
  " #{@maturity_date.inspect}, issue_date: #{@issue_date.inspect}, face_value:"\
  " #{@face_value.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



94
95
96
97
98
99
# File 'lib/the_plaid_api/models/fixed_income.rb', line 94

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} yield_rate: #{@yield_rate}, maturity_date: #{@maturity_date}, issue_date:"\
  " #{@issue_date}, face_value: #{@face_value}, additional_properties:"\
  " #{@additional_properties}>"
end