Class: Plaid::InvestmentTransaction
- Defined in:
- lib/plaid/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, or transacted date for pending transactions.
-
#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 ⇒ Subtype
For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).
-
#type ⇒ Type4
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, additional_properties: nil) ⇒ InvestmentTransaction
constructor
A new instance of InvestmentTransaction.
-
#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(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, additional_properties: nil) ⇒ InvestmentTransaction
Returns a new instance of InvestmentTransaction.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/plaid/models/investment_transaction.rb', line 134 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, 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 @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.
25 26 27 |
# File 'lib/plaid/models/investment_transaction.rb', line 25 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.
49 50 51 |
# File 'lib/plaid/models/investment_transaction.rb', line 49 def amount @amount end |
#cancel_transaction_id ⇒ String
A legacy field formerly used internally by Plaid to identify certain canceled transactions.
21 22 23 |
# File 'lib/plaid/models/investment_transaction.rb', line 21 def cancel_transaction_id @cancel_transaction_id end |
#date ⇒ Date
The [ISO 8601](wikipedia.org/wiki/ISO_8601) posting date for the transaction, or transacted date for pending transactions.
34 35 36 |
# File 'lib/plaid/models/investment_transaction.rb', line 34 def date @date end |
#fees ⇒ Float
The combined value of all fees applied to this transaction
57 58 59 |
# File 'lib/plaid/models/investment_transaction.rb', line 57 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.
16 17 18 |
# File 'lib/plaid/models/investment_transaction.rb', line 16 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`.
84 85 86 |
# File 'lib/plaid/models/investment_transaction.rb', line 84 def iso_currency_code @iso_currency_code end |
#name ⇒ String
The institution’s description of the transaction.
38 39 40 |
# File 'lib/plaid/models/investment_transaction.rb', line 38 def name @name end |
#price ⇒ Float
The price of the security at which this transaction occurred.
53 54 55 |
# File 'lib/plaid/models/investment_transaction.rb', line 53 def price @price end |
#quantity ⇒ Float
The number of units of the security involved in this transaction.
42 43 44 |
# File 'lib/plaid/models/investment_transaction.rb', line 42 def quantity @quantity end |
#security_id ⇒ String
The ‘security_id` to which this transaction is related.
29 30 31 |
# File 'lib/plaid/models/investment_transaction.rb', line 29 def security_id @security_id end |
#subtype ⇒ Subtype
For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).
79 80 81 |
# File 'lib/plaid/models/investment_transaction.rb', line 79 def subtype @subtype end |
#type ⇒ Type4
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).
72 73 74 |
# File 'lib/plaid/models/investment_transaction.rb', line 72 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.
94 95 96 |
# File 'lib/plaid/models/investment_transaction.rb', line 94 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 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 |
# File 'lib/plaid/models/investment_transaction.rb', line 159 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 # 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, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/plaid/models/investment_transaction.rb', line 97 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['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
124 125 126 127 128 129 130 131 132 |
# File 'lib/plaid/models/investment_transaction.rb', line 124 def self.nullables %w[ cancel_transaction_id security_id fees iso_currency_code unofficial_currency_code ] end |
.optionals ⇒ Object
An array for optional fields
117 118 119 120 121 |
# File 'lib/plaid/models/investment_transaction.rb', line 117 def self.optionals %w[ cancel_transaction_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/plaid/models/investment_transaction.rb', line 219 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},"\ " 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_s ⇒ Object
Provides a human-readable string representation of the object.
208 209 210 211 212 213 214 215 216 |
# File 'lib/plaid/models/investment_transaction.rb', line 208 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}, 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 |