Class: FdxV660Api::InvestmentBalanceEntity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/investment_balance_entity.rb

Overview

A point-in-time balance of the investment account

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(balance_name: SKIP, balance_description: SKIP, balance_type: SKIP, balance_value: SKIP, balance_date: SKIP, currency: SKIP, additional_properties: nil) ⇒ InvestmentBalanceEntity

Returns a new instance of InvestmentBalanceEntity.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 65

def initialize(balance_name: SKIP, balance_description: SKIP,
               balance_type: SKIP, balance_value: SKIP, balance_date: SKIP,
               currency: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @balance_name = balance_name unless balance_name == SKIP
  @balance_description = balance_description unless balance_description == SKIP
  @balance_type = balance_type unless balance_type == SKIP
  @balance_value = balance_value unless balance_value == SKIP
  @balance_date = balance_date unless balance_date == SKIP
  @currency = currency unless currency == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#balance_dateDate

Date as of this balance

Returns:

  • (Date)


30
31
32
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 30

def balance_date
  @balance_date
end

#balance_descriptionString

Description of balance

Returns:

  • (String)


18
19
20
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 18

def balance_description
  @balance_description
end

#balance_nameString

Name of the balance

Returns:

  • (String)


14
15
16
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 14

def balance_name
  @balance_name
end

#balance_typeInvestmentBalanceType2

AMOUNT, PERCENTAGE



22
23
24
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 22

def balance_type
  @balance_type
end

#balance_valueFloat

Value of named balance

Returns:

  • (Float)


26
27
28
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 26

def balance_value
  @balance_value
end

#currencyCurrencyEntity2

Currency if different from that of account

Returns:



34
35
36
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 34

def currency
  @currency
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  balance_name = hash.key?('balanceName') ? hash['balanceName'] : SKIP
  balance_description =
    hash.key?('balanceDescription') ? hash['balanceDescription'] : SKIP
  balance_type = hash.key?('balanceType') ? hash['balanceType'] : SKIP
  balance_value = hash.key?('balanceValue') ? hash['balanceValue'] : SKIP
  balance_date = hash.key?('balanceDate') ? hash['balanceDate'] : SKIP
  currency = CurrencyEntity2.from_hash(hash['currency']) if hash['currency']

  # 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.
  InvestmentBalanceEntity.new(balance_name: balance_name,
                              balance_description: balance_description,
                              balance_type: balance_type,
                              balance_value: balance_value,
                              balance_date: balance_date,
                              currency: currency,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['balance_name'] = 'balanceName'
  @_hash['balance_description'] = 'balanceDescription'
  @_hash['balance_type'] = 'balanceType'
  @_hash['balance_value'] = 'balanceValue'
  @_hash['balance_date'] = 'balanceDate'
  @_hash['currency'] = 'currency'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 49

def self.optionals
  %w[
    balance_name
    balance_description
    balance_type
    balance_value
    balance_date
    currency
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



112
113
114
115
116
117
118
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 112

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.



130
131
132
133
134
135
136
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 130

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} balance_name: #{@balance_name.inspect}, balance_description:"\
  " #{@balance_description.inspect}, balance_type: #{@balance_type.inspect}, balance_value:"\
  " #{@balance_value.inspect}, balance_date: #{@balance_date.inspect}, currency:"\
  " #{@currency.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
126
127
# File 'lib/fdx_v660_api/models/investment_balance_entity.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} balance_name: #{@balance_name}, balance_description:"\
  " #{@balance_description}, balance_type: #{@balance_type}, balance_value: #{@balance_value},"\
  " balance_date: #{@balance_date}, currency: #{@currency}, additional_properties:"\
  " #{@additional_properties}>"
end