=begin #MoneyKit API #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: 2023-02-18 Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.1.0 =end require 'date' require 'time' module MoneyKit class InvestmentTransactionResponse # The unique ID for this investment transaction. attr_accessor :investment_transaction_id # The ID of the account in which this investment transaction occurred. attr_accessor :account_id # The total value of this transaction, denominated in account currency. Positive values indicate debits (withdrawals); negative values are credits (deposits). When a transaction has both quantity and price, the amount should be equal to `quantity * price + fees`. attr_accessor :amount # The effective (posted) date of the transaction, in ISO-8601 format. attr_accessor :date # If the institution has provided the actual time of the transaction, this field contains the full date and time of the transaction, in ISO-8601 format. If the time is not available, this field will be null.
Note that the time is generally reported in the timezone of the institution or the account holder.
attr_accessor :datetime
# A normalized, cleaned transaction description suitable for presentation to the end user.
attr_accessor :description
# The type of transaction (buy, sell, cash, fee, transfer). May include a dotted subtype, for example, `buy.buy_to_cover` or `fee.transfer_fee`.
attr_accessor :type
# The combined value of any fees applied to the transaction. Fees are reported as positive values; refunds are reported as negative values.
attr_accessor :fees
# The currency exchange rate applied. Only present for transactions involving a security that is denominated in a currency other than the account currency.
attr_accessor :forex_rate
# The price per share, denominated in account currency. Omitted for transactions not involving a security.
attr_accessor :price
# The units of security (aka \"shares\") bought, sold, or transferred. Omitted for transactions not involving a security. Positive values indicate shares added to the account.
attr_accessor :quantity
# The MoneyKit ID of the security involved in this transaction (for example, the security bought or sold, or upon which interest or dividends are paid.
attr_accessor :security_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'investment_transaction_id' => :'investment_transaction_id',
:'account_id' => :'account_id',
:'amount' => :'amount',
:'date' => :'date',
:'datetime' => :'datetime',
:'description' => :'description',
:'type' => :'type',
:'fees' => :'fees',
:'forex_rate' => :'forex_rate',
:'price' => :'price',
:'quantity' => :'quantity',
:'security_id' => :'security_id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'investment_transaction_id' => :'String',
:'account_id' => :'String',
:'amount' => :'String',
:'date' => :'Date',
:'datetime' => :'Time',
:'description' => :'String',
:'type' => :'String',
:'fees' => :'String',
:'forex_rate' => :'String',
:'price' => :'String',
:'quantity' => :'String',
:'security_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::InvestmentTransactionResponse` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::InvestmentTransactionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'investment_transaction_id')
self.investment_transaction_id = attributes[:'investment_transaction_id']
else
self.investment_transaction_id = nil
end
if attributes.key?(:'account_id')
self.account_id = attributes[:'account_id']
else
self.account_id = nil
end
if attributes.key?(:'amount')
self.amount = attributes[:'amount']
else
self.amount = nil
end
if attributes.key?(:'date')
self.date = attributes[:'date']
else
self.date = nil
end
if attributes.key?(:'datetime')
self.datetime = attributes[:'datetime']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
else
self.description = nil
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = nil
end
if attributes.key?(:'fees')
self.fees = attributes[:'fees']
end
if attributes.key?(:'forex_rate')
self.forex_rate = attributes[:'forex_rate']
end
if attributes.key?(:'price')
self.price = attributes[:'price']
end
if attributes.key?(:'quantity')
self.quantity = attributes[:'quantity']
end
if attributes.key?(:'security_id')
self.security_id = attributes[:'security_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
invalid_properties = Array.new
if @investment_transaction_id.nil?
invalid_properties.push('invalid value for "investment_transaction_id", investment_transaction_id cannot be nil.')
end
if @account_id.nil?
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
end
if @amount.nil?
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
end
if @date.nil?
invalid_properties.push('invalid value for "date", date cannot be nil.')
end
if @description.nil?
invalid_properties.push('invalid value for "description", description cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
warn '[DEPRECATED] the `valid?` method is obsolete'
return false if @investment_transaction_id.nil?
return false if @account_id.nil?
return false if @amount.nil?
return false if @date.nil?
return false if @description.nil?
return false if @type.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
investment_transaction_id == o.investment_transaction_id &&
account_id == o.account_id &&
amount == o.amount &&
date == o.date &&
datetime == o.datetime &&
description == o.description &&
type == o.type &&
fees == o.fees &&
forex_rate == o.forex_rate &&
price == o.price &&
quantity == o.quantity &&
security_id == o.security_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[investment_transaction_id, account_id, amount, date, datetime, description, type, fees, forex_rate, price, quantity, security_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
transformed_hash = {}
openapi_types.each_pair do |key, type|
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
transformed_hash["#{key}"] = nil
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[attribute_map[key]].is_a?(Array)
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
end
elsif !attributes[attribute_map[key]].nil?
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
end
end
new(transformed_hash)
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def self._deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
::Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?