Class: Plaid::Holding
- Defined in:
- lib/plaid/models/holding.rb
Overview
A securities holding at an institution.
Instance Attribute Summary collapse
-
#account_id ⇒ String
The Plaid ‘account_id` associated with the holding.
-
#cost_basis ⇒ Float
The cost basis of the holding.
-
#institution_price ⇒ Float
The last price given by the institution for this security.
-
#institution_price_as_of ⇒ Date
The date at which ‘institution_price` was current.
-
#institution_value ⇒ Float
The value of the holding, as reported by the institution.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the holding.
-
#quantity ⇒ Float
The total quantity of the asset held, as reported by the financial institution.
-
#security_id ⇒ String
The Plaid ‘security_id` associated with the holding.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the holding.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(account_id:, security_id:, institution_price:, institution_price_as_of:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, additional_properties: nil) ⇒ Holding
constructor
A new instance of Holding.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(account_id:, security_id:, institution_price:, institution_price_as_of:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, additional_properties: nil) ⇒ Holding
Returns a new instance of Holding.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/plaid/models/holding.rb', line 88 def initialize(account_id:, security_id:, institution_price:, institution_price_as_of:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @account_id = account_id @security_id = security_id @institution_price = institution_price @institution_price_as_of = institution_price_as_of @institution_value = institution_value @cost_basis = cost_basis @quantity = quantity @iso_currency_code = iso_currency_code @unofficial_currency_code = unofficial_currency_code @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ String
The Plaid ‘account_id` associated with the holding.
14 15 16 |
# File 'lib/plaid/models/holding.rb', line 14 def account_id @account_id end |
#cost_basis ⇒ Float
The cost basis of the holding.
34 35 36 |
# File 'lib/plaid/models/holding.rb', line 34 def cost_basis @cost_basis end |
#institution_price ⇒ Float
The last price given by the institution for this security.
22 23 24 |
# File 'lib/plaid/models/holding.rb', line 22 def institution_price @institution_price end |
#institution_price_as_of ⇒ Date
The date at which ‘institution_price` was current.
26 27 28 |
# File 'lib/plaid/models/holding.rb', line 26 def institution_price_as_of @institution_price_as_of end |
#institution_value ⇒ Float
The value of the holding, as reported by the institution.
30 31 32 |
# File 'lib/plaid/models/holding.rb', line 30 def institution_value @institution_value end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the holding. Always ‘null` if `unofficial_currency_code` is non-`null`.
46 47 48 |
# File 'lib/plaid/models/holding.rb', line 46 def iso_currency_code @iso_currency_code end |
#quantity ⇒ Float
The total quantity of the asset held, as reported by the financial institution. If the security is an option, ‘quantity` will reflect the total number of options (typically the number of contracts multiplied by 100), not the number of contracts.
41 42 43 |
# File 'lib/plaid/models/holding.rb', line 41 def quantity @quantity end |
#security_id ⇒ String
The Plaid ‘security_id` associated with the holding.
18 19 20 |
# File 'lib/plaid/models/holding.rb', line 18 def security_id @security_id end |
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the holding. Always ‘null` if `iso_currency_code` is non-`null`. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `iso_currency_code`s.
56 57 58 |
# File 'lib/plaid/models/holding.rb', line 56 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/plaid/models/holding.rb', line 108 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_id = hash.key?('account_id') ? hash['account_id'] : nil security_id = hash.key?('security_id') ? hash['security_id'] : nil institution_price = hash.key?('institution_price') ? hash['institution_price'] : nil institution_price_as_of = hash.key?('institution_price_as_of') ? hash['institution_price_as_of'] : nil institution_value = hash.key?('institution_value') ? hash['institution_value'] : nil cost_basis = hash.key?('cost_basis') ? hash['cost_basis'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil iso_currency_code = hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil unofficial_currency_code = hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : 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. Holding.new(account_id: account_id, security_id: security_id, institution_price: institution_price, institution_price_as_of: institution_price_as_of, institution_value: institution_value, cost_basis: cost_basis, quantity: quantity, iso_currency_code: iso_currency_code, unofficial_currency_code: unofficial_currency_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/plaid/models/holding.rb', line 59 def self.names @_hash = {} if @_hash.nil? @_hash['account_id'] = 'account_id' @_hash['security_id'] = 'security_id' @_hash['institution_price'] = 'institution_price' @_hash['institution_price_as_of'] = 'institution_price_as_of' @_hash['institution_value'] = 'institution_value' @_hash['cost_basis'] = 'cost_basis' @_hash['quantity'] = 'quantity' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash end |
.nullables ⇒ Object
An array for nullable fields
79 80 81 82 83 84 85 86 |
# File 'lib/plaid/models/holding.rb', line 79 def self.nullables %w[ institution_price_as_of cost_basis iso_currency_code unofficial_currency_code ] end |
.optionals ⇒ Object
An array for optional fields
74 75 76 |
# File 'lib/plaid/models/holding.rb', line 74 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
159 160 161 162 163 164 165 166 167 |
# File 'lib/plaid/models/holding.rb', line 159 def inspect class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id.inspect}, security_id: #{@security_id.inspect},"\ " institution_price: #{@institution_price.inspect}, institution_price_as_of:"\ " #{@institution_price_as_of.inspect}, institution_value: #{@institution_value.inspect},"\ " cost_basis: #{@cost_basis.inspect}, quantity: #{@quantity.inspect}, iso_currency_code:"\ " #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
148 149 150 151 152 153 154 155 156 |
# File 'lib/plaid/models/holding.rb', line 148 def to_s class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id}, security_id: #{@security_id},"\ " institution_price: #{@institution_price}, institution_price_as_of:"\ " #{@institution_price_as_of}, institution_value: #{@institution_value}, cost_basis:"\ " #{@cost_basis}, quantity: #{@quantity}, iso_currency_code: #{@iso_currency_code},"\ " unofficial_currency_code: #{@unofficial_currency_code}, additional_properties:"\ " #{@additional_properties}>" end |