Class: FdxV660Api::CertificateOfDepositSecurityEntity

Inherits:
SecurityEntity show all
Defined in:
lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb

Overview

A Certificate of Deposit held on an investment account

Instance Attribute Summary collapse

Attributes inherited from SecurityEntity

#fi_attributes, #security_category

Class Method Summary collapse

Instance Method Summary collapse

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(term: SKIP, maturity_date: SKIP, security_category: 'Certificate Of Deposit Security entity', fi_attributes: SKIP, additional_properties: nil) ⇒ CertificateOfDepositSecurityEntity

Returns a new instance of CertificateOfDepositSecurityEntity.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 43

def initialize(term: SKIP, maturity_date: SKIP,
               security_category: 'Certificate Of Deposit Security entity',
               fi_attributes: SKIP, additional_properties: nil)
  @term = term unless term == SKIP
  @maturity_date = maturity_date unless maturity_date == SKIP
  @additional_properties = additional_properties

  # Call the constructor of the base class
  super(security_category: security_category,
        fi_attributes: fi_attributes,
        additional_properties: additional_properties)
end

Instance Attribute Details

#maturity_dateDate

Certificate of Deposit maturity date

Returns:

  • (Date)


17
18
19
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 17

def maturity_date
  @maturity_date
end

#termInteger

Term of CD in months

Returns:

  • (Integer)


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

def term
  @term
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  term = hash.key?('term') ? hash['term'] : SKIP
  maturity_date = hash.key?('maturityDate') ? hash['maturityDate'] : SKIP
  security_category =
    hash['securityCategory'] ||= 'Certificate Of Deposit 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.
  CertificateOfDepositSecurityEntity.new(term: term,
                                         maturity_date: 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.



20
21
22
23
24
25
26
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 20

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

.nullablesObject

An array for nullable fields



38
39
40
41
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 38

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

.optionalsObject

An array for optional fields



29
30
31
32
33
34
35
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 29

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



93
94
95
96
97
98
99
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 93

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.



109
110
111
112
113
114
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 109

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

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
# File 'lib/fdx_v660_api/models/certificate_of_deposit_security_entity.rb', line 102

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