Class: ThePlaidApi::YieldRate

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

Overview

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

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(percentage:, type:, additional_properties: nil) ⇒ YieldRate

Returns a new instance of YieldRate.



52
53
54
55
56
57
58
59
# File 'lib/the_plaid_api/models/yield_rate.rb', line 52

def initialize(percentage:, type:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @percentage = percentage
  @type = type
  @additional_properties = additional_properties
end

Instance Attribute Details

#percentageFloat

The fixed income security’s expected rate of return.

Returns:

  • (Float)


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

def percentage
  @percentage
end

#typeYieldRateType

The type of rate which indicates how the predicted yield was calculated. It is one of: ‘coupon`: the annualized interest rate for securities with a one-year term or longer, such as treasury notes and bonds. `coupon_equivalent`: the calculated equivalent for the annualized interest rate factoring in the discount rate and time to maturity, for shorter term, non-interest-bearing securities such as treasury bills. `discount`: the rate at which the present value or cost is discounted from the future value upon maturity, also known as the face value. `yield`: the total predicted rate of return factoring in both the discount rate and the coupon rate, applicable to securities such as exchange-traded bonds which can both be interest-bearing as well as sold at a discount off its face value.

Returns:



30
31
32
# File 'lib/the_plaid_api/models/yield_rate.rb', line 30

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/the_plaid_api/models/yield_rate.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  percentage = hash.key?('percentage') ? hash['percentage'] : nil
  type = hash.key?('type') ? hash['type'] : 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.
  YieldRate.new(percentage: percentage,
                type: type,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['percentage'] = 'percentage'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
50
# File 'lib/the_plaid_api/models/yield_rate.rb', line 46

def self.nullables
  %w[
    type
  ]
end

.optionalsObject

An array for optional fields



41
42
43
# File 'lib/the_plaid_api/models/yield_rate.rb', line 41

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
94
# File 'lib/the_plaid_api/models/yield_rate.rb', line 90

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

#to_sObject

Provides a human-readable string representation of the object.



83
84
85
86
87
# File 'lib/the_plaid_api/models/yield_rate.rb', line 83

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