Class: ThePlaidApi::InvestmentTransaction
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ThePlaidApi::InvestmentTransaction
- Defined in:
- lib/the_plaid_api/models/investment_transaction.rb
Overview
A transaction within an investment account.
Instance Attribute Summary collapse
-
#account_id ⇒ String
The ‘account_id` of the account against which this transaction posted.
-
#amount ⇒ Float
The complete value of the transaction.
-
#cancel_transaction_id ⇒ String
A legacy field formerly used internally by Plaid to identify certain canceled transactions.
-
#date ⇒ Date
The [ISO 8601](wikipedia.org/wiki/ISO_8601) posting date for the transaction.
-
#fees ⇒ Float
The combined value of all fees applied to this transaction.
-
#investment_transaction_id ⇒ String
The ID of the Investment transaction, unique across all Plaid transactions.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the transaction.
-
#name ⇒ String
The institution’s description of the transaction.
-
#price ⇒ Float
The price of the security at which this transaction occurred.
-
#quantity ⇒ Float
The number of units of the security involved in this transaction.
-
#security_id ⇒ String
The ‘security_id` to which this transaction is related.
-
#subtype ⇒ InvestmentTransactionSubtype
For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).
-
#transaction_datetime ⇒ DateTime
Timestamp in [ISO 8601](wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) representing when the order type was initiated.
-
#type ⇒ InvestmentTransactionType
Value is one of the following: ‘buy`: Buying an investment `sell`: Selling an investment `cancel`: A cancellation of a pending transaction `cash`: Activity that modifies a cash position `fee`: A fee on the account `transfer`: Activity which modifies a position, but not through buy/sell activity e.g.
-
#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(investment_transaction_id:, account_id:, security_id:, date:, name:, quantity:, amount:, price:, fees:, type:, subtype:, iso_currency_code:, unofficial_currency_code:, cancel_transaction_id: SKIP, transaction_datetime: SKIP, additional_properties: nil) ⇒ InvestmentTransaction
constructor
A new instance of InvestmentTransaction.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_transaction_datetime ⇒ Object
-
#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(investment_transaction_id:, account_id:, security_id:, date:, name:, quantity:, amount:, price:, fees:, type:, subtype:, iso_currency_code:, unofficial_currency_code:, cancel_transaction_id: SKIP, transaction_datetime: SKIP, additional_properties: nil) ⇒ InvestmentTransaction
Returns a new instance of InvestmentTransaction.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 146 def initialize(investment_transaction_id:, account_id:, security_id:, date:, name:, quantity:, amount:, price:, fees:, type:, subtype:, iso_currency_code:, unofficial_currency_code:, cancel_transaction_id: SKIP, transaction_datetime: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @investment_transaction_id = investment_transaction_id @cancel_transaction_id = cancel_transaction_id unless cancel_transaction_id == SKIP @account_id = account_id @security_id = security_id @date = date @transaction_datetime = transaction_datetime unless transaction_datetime == SKIP @name = name @quantity = quantity @amount = amount @price = price @fees = fees @type = type @subtype = subtype @iso_currency_code = iso_currency_code @unofficial_currency_code = unofficial_currency_code @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ String
The ‘account_id` of the account against which this transaction posted.
26 27 28 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 26 def account_id @account_id end |
#amount ⇒ Float
The complete value of the transaction. Positive values when cash is debited, e.g. purchases of stock; negative values when cash is credited, e.g. sales of stock. Treatment remains the same for cash-only movements unassociated with securities.
58 59 60 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 58 def amount @amount end |
#cancel_transaction_id ⇒ String
A legacy field formerly used internally by Plaid to identify certain canceled transactions.
22 23 24 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 22 def cancel_transaction_id @cancel_transaction_id end |
#date ⇒ Date
The [ISO 8601](wikipedia.org/wiki/ISO_8601) posting date for the transaction. This is typically the settlement date.
35 36 37 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 35 def date @date end |
#fees ⇒ Float
The combined value of all fees applied to this transaction
66 67 68 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 66 def fees @fees end |
#investment_transaction_id ⇒ String
The ID of the Investment transaction, unique across all Plaid transactions. Like all Plaid identifiers, the ‘investment_transaction_id` is case sensitive.
17 18 19 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 17 def investment_transaction_id @investment_transaction_id end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the transaction. Always ‘null` if `unofficial_currency_code` is non-`null`.
93 94 95 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 93 def iso_currency_code @iso_currency_code end |
#name ⇒ String
The institution’s description of the transaction.
46 47 48 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 46 def name @name end |
#price ⇒ Float
The price of the security at which this transaction occurred.
62 63 64 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 62 def price @price end |
#quantity ⇒ Float
The number of units of the security involved in this transaction. Positive for buy transactions; negative for sell transactions.
51 52 53 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 51 def quantity @quantity end |
#security_id ⇒ String
The ‘security_id` to which this transaction is related.
30 31 32 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 30 def security_id @security_id end |
#subtype ⇒ InvestmentTransactionSubtype
For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).
88 89 90 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 88 def subtype @subtype end |
#transaction_datetime ⇒ DateTime
Timestamp in [ISO 8601](wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) representing when the order type was initiated. This field is returned for select financial institutions and reflects the value provided by the institution.
42 43 44 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 42 def transaction_datetime @transaction_datetime end |
#type ⇒ InvestmentTransactionType
Value is one of the following: ‘buy`: Buying an investment `sell`: Selling an investment `cancel`: A cancellation of a pending transaction `cash`: Activity that modifies a cash position `fee`: A fee on the account `transfer`: Activity which modifies a position, but not through buy/sell activity e.g. options exercise, portfolio transfer For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).
81 82 83 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 81 def type @type 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.
103 104 105 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 103 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 173 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. investment_transaction_id = hash.key?('investment_transaction_id') ? hash['investment_transaction_id'] : nil account_id = hash.key?('account_id') ? hash['account_id'] : nil security_id = hash.key?('security_id') ? hash['security_id'] : nil date = hash.key?('date') ? hash['date'] : nil name = hash.key?('name') ? hash['name'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil amount = hash.key?('amount') ? hash['amount'] : nil price = hash.key?('price') ? hash['price'] : nil fees = hash.key?('fees') ? hash['fees'] : nil type = hash.key?('type') ? hash['type'] : nil subtype = hash.key?('subtype') ? hash['subtype'] : 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 cancel_transaction_id = hash.key?('cancel_transaction_id') ? hash['cancel_transaction_id'] : SKIP transaction_datetime = if hash.key?('transaction_datetime') (DateTimeHelper.from_rfc3339(hash['transaction_datetime']) if hash['transaction_datetime']) else SKIP end # 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. InvestmentTransaction.new(investment_transaction_id: investment_transaction_id, account_id: account_id, security_id: security_id, date: date, name: name, quantity: quantity, amount: amount, price: price, fees: fees, type: type, subtype: subtype, iso_currency_code: iso_currency_code, unofficial_currency_code: unofficial_currency_code, cancel_transaction_id: cancel_transaction_id, transaction_datetime: transaction_datetime, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 106 def self.names @_hash = {} if @_hash.nil? @_hash['investment_transaction_id'] = 'investment_transaction_id' @_hash['cancel_transaction_id'] = 'cancel_transaction_id' @_hash['account_id'] = 'account_id' @_hash['security_id'] = 'security_id' @_hash['date'] = 'date' @_hash['transaction_datetime'] = 'transaction_datetime' @_hash['name'] = 'name' @_hash['quantity'] = 'quantity' @_hash['amount'] = 'amount' @_hash['price'] = 'price' @_hash['fees'] = 'fees' @_hash['type'] = 'type' @_hash['subtype'] = 'subtype' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash end |
.nullables ⇒ Object
An array for nullable fields
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 135 def self.nullables %w[ cancel_transaction_id security_id transaction_datetime fees iso_currency_code unofficial_currency_code ] end |
.optionals ⇒ Object
An array for optional fields
127 128 129 130 131 132 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 127 def self.optionals %w[ cancel_transaction_id transaction_datetime ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 244 def inspect class_name = self.class.name.split('::').last "<#{class_name} investment_transaction_id: #{@investment_transaction_id.inspect},"\ " cancel_transaction_id: #{@cancel_transaction_id.inspect}, account_id:"\ " #{@account_id.inspect}, security_id: #{@security_id.inspect}, date: #{@date.inspect},"\ " transaction_datetime: #{@transaction_datetime.inspect}, name: #{@name.inspect}, quantity:"\ " #{@quantity.inspect}, amount: #{@amount.inspect}, price: #{@price.inspect}, fees:"\ " #{@fees.inspect}, type: #{@type.inspect}, subtype: #{@subtype.inspect}, iso_currency_code:"\ " #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_transaction_datetime ⇒ Object
227 228 229 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 227 def to_custom_transaction_datetime DateTimeHelper.to_rfc3339(transaction_datetime) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/the_plaid_api/models/investment_transaction.rb', line 232 def to_s class_name = self.class.name.split('::').last "<#{class_name} investment_transaction_id: #{@investment_transaction_id},"\ " cancel_transaction_id: #{@cancel_transaction_id}, account_id: #{@account_id}, security_id:"\ " #{@security_id}, date: #{@date}, transaction_datetime: #{@transaction_datetime}, name:"\ " #{@name}, quantity: #{@quantity}, amount: #{@amount}, price: #{@price}, fees: #{@fees},"\ " type: #{@type}, subtype: #{@subtype}, iso_currency_code: #{@iso_currency_code},"\ " unofficial_currency_code: #{@unofficial_currency_code}, additional_properties:"\ " #{@additional_properties}>" end |