Class: FdxV660Api::TaxLotEntity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/tax_lot_entity.rb

Overview

Block of securities receiving the same tax treatment

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(original_purchase_date: SKIP, quantity: SKIP, purchased_price: SKIP, cost_basis: SKIP, current_value: SKIP, position_type: SKIP, additional_properties: nil) ⇒ TaxLotEntity

Returns a new instance of TaxLotEntity.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 66

def initialize(original_purchase_date: SKIP, quantity: SKIP,
               purchased_price: SKIP, cost_basis: SKIP, current_value: SKIP,
               position_type: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @original_purchase_date = original_purchase_date unless original_purchase_date == SKIP
  @quantity = quantity unless quantity == SKIP
  @purchased_price = purchased_price unless purchased_price == SKIP
  @cost_basis = cost_basis unless cost_basis == SKIP
  @current_value = current_value unless current_value == SKIP
  @position_type = position_type unless position_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#cost_basisFloat

Total amount of money spent acquiring this lot including any fees or commission expenses incurred

Returns:

  • (Float)


27
28
29
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 27

def cost_basis
  @cost_basis
end

#current_valueFloat

Lot market value

Returns:

  • (Float)


31
32
33
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 31

def current_value
  @current_value
end

#original_purchase_dateDate

Lot acquired date

Returns:

  • (Date)


14
15
16
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 14

def original_purchase_date
  @original_purchase_date
end

#position_typePositionType1

LONG, SHORT

Returns:



35
36
37
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 35

def position_type
  @position_type
end

#purchased_priceFloat

Original purchase price

Returns:

  • (Float)


22
23
24
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 22

def purchased_price
  @purchased_price
end

#quantityFloat

Lot quantity

Returns:

  • (Float)


18
19
20
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 18

def quantity
  @quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  original_purchase_date =
    hash.key?('originalPurchaseDate') ? hash['originalPurchaseDate'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  purchased_price =
    hash.key?('purchasedPrice') ? hash['purchasedPrice'] : SKIP
  cost_basis = hash.key?('costBasis') ? hash['costBasis'] : SKIP
  current_value = hash.key?('currentValue') ? hash['currentValue'] : SKIP
  position_type = hash.key?('positionType') ? hash['positionType'] : 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.
  TaxLotEntity.new(original_purchase_date: original_purchase_date,
                   quantity: quantity,
                   purchased_price: purchased_price,
                   cost_basis: cost_basis,
                   current_value: current_value,
                   position_type: position_type,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['original_purchase_date'] = 'originalPurchaseDate'
  @_hash['quantity'] = 'quantity'
  @_hash['purchased_price'] = 'purchasedPrice'
  @_hash['cost_basis'] = 'costBasis'
  @_hash['current_value'] = 'currentValue'
  @_hash['position_type'] = 'positionType'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
59
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 50

def self.optionals
  %w[
    original_purchase_date
    quantity
    purchased_price
    cost_basis
    current_value
    position_type
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (TaxLotEntity | Hash)

    value against the validation is performed.



114
115
116
117
118
119
120
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 114

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



132
133
134
135
136
137
138
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 132

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} original_purchase_date: #{@original_purchase_date.inspect}, quantity:"\
  " #{@quantity.inspect}, purchased_price: #{@purchased_price.inspect}, cost_basis:"\
  " #{@cost_basis.inspect}, current_value: #{@current_value.inspect}, position_type:"\
  " #{@position_type.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



123
124
125
126
127
128
129
# File 'lib/fdx_v660_api/models/tax_lot_entity.rb', line 123

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} original_purchase_date: #{@original_purchase_date}, quantity: #{@quantity},"\
  " purchased_price: #{@purchased_price}, cost_basis: #{@cost_basis}, current_value:"\
  " #{@current_value}, position_type: #{@position_type}, additional_properties:"\
  " #{@additional_properties}>"
end