Class: FdxV660Api::BondSecurityEntity

Inherits:
DebtSecurityEntity show all
Defined in:
lib/fdx_v660_api/models/bond_security_entity.rb

Overview

A Bond held on an investment account

Instance Attribute Summary collapse

Attributes inherited from DebtSecurityEntity

#bond_maturity_date, #call_date, #call_price, #call_type, #coupon_date, #coupon_mature_frequency, #coupon_rate, #debt_class, #debt_type, #par_value, #yield_to_call, #yield_to_maturity

Attributes inherited from SecurityEntity

#fi_attributes, #security_category

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DebtSecurityEntity

discriminators

Methods inherited from SecurityEntity

discriminators

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(face_value: SKIP, par_value: SKIP, debt_type: SKIP, debt_class: SKIP, coupon_rate: SKIP, coupon_date: SKIP, coupon_mature_frequency: SKIP, call_price: SKIP, yield_to_call: SKIP, call_date: SKIP, call_type: SKIP, yield_to_maturity: SKIP, bond_maturity_date: SKIP, security_category: 'Bond Security entity', fi_attributes: SKIP, additional_properties: nil) ⇒ BondSecurityEntity

Returns a new instance of BondSecurityEntity.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 37

def initialize(face_value: SKIP, par_value: SKIP, debt_type: SKIP,
               debt_class: SKIP, coupon_rate: SKIP, coupon_date: SKIP,
               coupon_mature_frequency: SKIP, call_price: SKIP,
               yield_to_call: SKIP, call_date: SKIP, call_type: SKIP,
               yield_to_maturity: SKIP, bond_maturity_date: SKIP,
               security_category: 'Bond Security entity',
               fi_attributes: SKIP, additional_properties: nil)
  @face_value = face_value unless face_value == SKIP
  @additional_properties = additional_properties

  # Call the constructor of the base class
  super(par_value: par_value,
        debt_type: debt_type,
        debt_class: debt_class,
        coupon_rate: coupon_rate,
        coupon_date: coupon_date,
        coupon_mature_frequency: coupon_mature_frequency,
        call_price: call_price,
        yield_to_call: yield_to_call,
        call_date: call_date,
        call_type: call_type,
        yield_to_maturity: yield_to_maturity,
        bond_maturity_date: bond_maturity_date,
        security_category: security_category,
        fi_attributes: fi_attributes,
        additional_properties: additional_properties)
end

Instance Attribute Details

#face_valueFloat

Face value at the time of data retrieved

Returns:

  • (Float)


13
14
15
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 13

def face_value
  @face_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  face_value = hash.key?('faceValue') ? hash['faceValue'] : SKIP
  par_value = hash.key?('parValue') ? hash['parValue'] : SKIP
  debt_type = hash.key?('debtType') ? hash['debtType'] : SKIP
  debt_class = hash.key?('debtClass') ? hash['debtClass'] : SKIP
  coupon_rate = hash.key?('couponRate') ? hash['couponRate'] : SKIP
  coupon_date = hash.key?('couponDate') ? hash['couponDate'] : SKIP
  coupon_mature_frequency =
    hash.key?('couponMatureFrequency') ? hash['couponMatureFrequency'] : SKIP
  call_price = hash.key?('callPrice') ? hash['callPrice'] : SKIP
  yield_to_call = hash.key?('yieldToCall') ? hash['yieldToCall'] : SKIP
  call_date = hash.key?('callDate') ? hash['callDate'] : SKIP
  call_type = hash.key?('callType') ? hash['callType'] : SKIP
  yield_to_maturity =
    hash.key?('yieldToMaturity') ? hash['yieldToMaturity'] : SKIP
  bond_maturity_date =
    hash.key?('bondMaturityDate') ? hash['bondMaturityDate'] : SKIP
  security_category = hash['securityCategory'] ||= 'Bond Security entity'
  # Parameter is an array, so we need to iterate through it
  fi_attributes = nil
  unless hash['fiAttributes'].nil?
    fi_attributes = []
    hash['fiAttributes'].each do |structure|
      fi_attributes << (FiAttributeEntity.from_hash(structure) if structure)
    end
  end

  fi_attributes = SKIP unless hash.key?('fiAttributes')

  # 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.
  BondSecurityEntity.new(face_value: face_value,
                         par_value: par_value,
                         debt_type: debt_type,
                         debt_class: debt_class,
                         coupon_rate: coupon_rate,
                         coupon_date: coupon_date,
                         coupon_mature_frequency: coupon_mature_frequency,
                         call_price: call_price,
                         yield_to_call: yield_to_call,
                         call_date: call_date,
                         call_type: call_type,
                         yield_to_maturity: yield_to_maturity,
                         bond_maturity_date: bond_maturity_date,
                         security_category: security_category,
                         fi_attributes: fi_attributes,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



16
17
18
19
20
21
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 16

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['face_value'] = 'faceValue'
  @_hash = super().merge(@_hash)
  @_hash
end

.nullablesObject

An array for nullable fields



32
33
34
35
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 32

def self.nullables
  _arr = []
  (_arr << super()).flatten!
end

.optionalsObject

An array for optional fields



24
25
26
27
28
29
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 24

def self.optionals
  _arr = %w[
    face_value
  ]
  (_arr << super()).flatten!
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



126
127
128
129
130
131
132
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 126

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 142

def inspect
  class_name = self.class.name.split('::').last
  super_string = super().inspect.sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, face_value: #{@face_value.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



135
136
137
138
139
# File 'lib/fdx_v660_api/models/bond_security_entity.rb', line 135

def to_s
  class_name = self.class.name.split('::').last
  super_string = super().sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, face_value: #{@face_value}>"
end