Class: ThePlaidApi::AssetReportInvestmentTransaction

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/asset_report_investment_transaction.rb

Overview

A transaction within an 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(investment_transaction_id:, account_id:, security_id:, date:, name:, quantity:, vested_quantity:, vested_value:, amount:, price:, fees:, type:, subtype:, iso_currency_code:, unofficial_currency_code:, additional_properties: nil) ⇒ AssetReportInvestmentTransaction

Returns a new instance of AssetReportInvestmentTransaction.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 139

def initialize(investment_transaction_id:, account_id:, security_id:, date:,
               name:, quantity:, vested_quantity:, vested_value:, amount:,
               price:, fees:, type:, subtype:, iso_currency_code:,
               unofficial_currency_code:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @investment_transaction_id = investment_transaction_id
  @account_id = 
  @security_id = security_id
  @date = date
  @name = name
  @quantity = quantity
  @vested_quantity = vested_quantity
  @vested_value = vested_value
  @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_idString

The ‘account_id` of the account against which this transaction posted.

Returns:

  • (String)


20
21
22
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 20

def 
  @account_id
end

#amountFloat

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.

Returns:

  • (Float)


56
57
58
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 56

def amount
  @amount
end

#dateDate

The [ISO 8601](wikipedia.org/wiki/ISO_8601) posting date for the transaction.

Returns:

  • (Date)


29
30
31
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 29

def date
  @date
end

#feesFloat

The combined value of all fees applied to this transaction

Returns:

  • (Float)


64
65
66
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 64

def fees
  @fees
end

#investment_transaction_idString

The ID of the Investment transaction, unique across all Plaid transactions. Like all Plaid identifiers, the ‘investment_transaction_id` is case sensitive.

Returns:

  • (String)


16
17
18
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 16

def investment_transaction_id
  @investment_transaction_id
end

#iso_currency_codeString

The ISO-4217 currency code of the transaction. Always ‘null` if `unofficial_currency_code` is non-`null`.

Returns:

  • (String)


91
92
93
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 91

def iso_currency_code
  @iso_currency_code
end

#nameString

The institution’s description of the transaction.

Returns:

  • (String)


33
34
35
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 33

def name
  @name
end

#priceFloat

The price of the security at which this transaction occurred.

Returns:

  • (Float)


60
61
62
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 60

def price
  @price
end

#quantityFloat

The number of units of the security involved in this transaction. Positive for buy transactions; negative for sell transactions.

Returns:

  • (Float)


38
39
40
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 38

def quantity
  @quantity
end

#security_idString

The ‘security_id` to which this transaction is related.

Returns:

  • (String)


24
25
26
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 24

def security_id
  @security_id
end

#subtypeInvestmentTransactionSubtype

For descriptions of possible transaction types and subtypes, see the [Investment transaction types schema](plaid.com/docs/api/accounts/#investment-transaction-types- schema).



86
87
88
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 86

def subtype
  @subtype
end

#typeInvestmentTransactionType

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).



79
80
81
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 79

def type
  @type
end

#unofficial_currency_codeString

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.

Returns:

  • (String)


101
102
103
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 101

def unofficial_currency_code
  @unofficial_currency_code
end

#vested_quantityFloat

The total quantity of vested assets held, as reported by the financial institution. Vested assets are only associated with [equities](plaid.com/docs/api/products/investments/#investments-ho ldings-get-response-securities-type).

Returns:

  • (Float)


45
46
47
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 45

def vested_quantity
  @vested_quantity
end

#vested_valueFloat

The value of the vested holdings as reported by the institution.

Returns:

  • (Float)


49
50
51
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 49

def vested_value
  @vested_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
206
207
208
209
210
211
212
213
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 165

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
   = 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
  vested_quantity =
    hash.key?('vested_quantity') ? hash['vested_quantity'] : nil
  vested_value = hash.key?('vested_value') ? hash['vested_value'] : 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

  # 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.
  AssetReportInvestmentTransaction.new(investment_transaction_id: investment_transaction_id,
                                       account_id: ,
                                       security_id: security_id,
                                       date: date,
                                       name: name,
                                       quantity: quantity,
                                       vested_quantity: vested_quantity,
                                       vested_value: vested_value,
                                       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

.namesObject

A mapping from model property names to API property names.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 104

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['investment_transaction_id'] = 'investment_transaction_id'
  @_hash['account_id'] = 'account_id'
  @_hash['security_id'] = 'security_id'
  @_hash['date'] = 'date'
  @_hash['name'] = 'name'
  @_hash['quantity'] = 'quantity'
  @_hash['vested_quantity'] = 'vested_quantity'
  @_hash['vested_value'] = 'vested_value'
  @_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

.nullablesObject

An array for nullable fields



130
131
132
133
134
135
136
137
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 130

def self.nullables
  %w[
    security_id
    fees
    iso_currency_code
    unofficial_currency_code
  ]
end

.optionalsObject

An array for optional fields



125
126
127
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 125

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



227
228
229
230
231
232
233
234
235
236
237
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 227

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} investment_transaction_id: #{@investment_transaction_id.inspect},"\
  " account_id: #{@account_id.inspect}, security_id: #{@security_id.inspect}, date:"\
  " #{@date.inspect}, name: #{@name.inspect}, quantity: #{@quantity.inspect}, vested_quantity:"\
  " #{@vested_quantity.inspect}, vested_value: #{@vested_value.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_sObject

Provides a human-readable string representation of the object.



216
217
218
219
220
221
222
223
224
# File 'lib/the_plaid_api/models/asset_report_investment_transaction.rb', line 216

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} investment_transaction_id: #{@investment_transaction_id}, account_id:"\
  " #{@account_id}, security_id: #{@security_id}, date: #{@date}, name: #{@name}, quantity:"\
  " #{@quantity}, vested_quantity: #{@vested_quantity}, vested_value: #{@vested_value},"\
  " 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