Class: ThePlaidApi::BuyType

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

Overview

Buying an investment

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(assignment: SKIP, contribution: SKIP, buy: SKIP, buy_to_cover: SKIP, dividend_reinvestment: SKIP, interest_reinvestment: SKIP, long_term_capital_gain_reinvestment: SKIP, short_term_capital_gain_reinvestment: SKIP, additional_properties: nil) ⇒ BuyType

Returns a new instance of BuyType.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/the_plaid_api/models/buy_type.rb', line 79

def initialize(assignment: SKIP, contribution: SKIP, buy: SKIP,
               buy_to_cover: SKIP, dividend_reinvestment: SKIP,
               interest_reinvestment: SKIP,
               long_term_capital_gain_reinvestment: SKIP,
               short_term_capital_gain_reinvestment: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @assignment = assignment unless assignment == SKIP
  @contribution = contribution unless contribution == SKIP
  @buy = buy unless buy == SKIP
  @buy_to_cover = buy_to_cover unless buy_to_cover == SKIP
  @dividend_reinvestment = dividend_reinvestment unless dividend_reinvestment == SKIP
  @interest_reinvestment = interest_reinvestment unless interest_reinvestment == SKIP
  unless long_term_capital_gain_reinvestment == SKIP
    @long_term_capital_gain_reinvestment =
      long_term_capital_gain_reinvestment
  end
  unless short_term_capital_gain_reinvestment == SKIP
    @short_term_capital_gain_reinvestment =
      short_term_capital_gain_reinvestment
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#assignmentString

Assignment of short option holding

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/buy_type.rb', line 14

def assignment
  @assignment
end

#buyString

Purchase to open or increase a position

Returns:

  • (String)


22
23
24
# File 'lib/the_plaid_api/models/buy_type.rb', line 22

def buy
  @buy
end

#buy_to_coverString

Purchase to close a short position

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/buy_type.rb', line 26

def buy_to_cover
  @buy_to_cover
end

#contributionString

Inflow of assets into a tax-advantaged account

Returns:

  • (String)


18
19
20
# File 'lib/the_plaid_api/models/buy_type.rb', line 18

def contribution
  @contribution
end

#dividend_reinvestmentString

Purchase using proceeds from a cash dividend

Returns:

  • (String)


30
31
32
# File 'lib/the_plaid_api/models/buy_type.rb', line 30

def dividend_reinvestment
  @dividend_reinvestment
end

#interest_reinvestmentString

Purchase using proceeds from a cash interest payment

Returns:

  • (String)


34
35
36
# File 'lib/the_plaid_api/models/buy_type.rb', line 34

def interest_reinvestment
  @interest_reinvestment
end

#long_term_capital_gain_reinvestmentString

Purchase using long-term capital gain cash proceeds

Returns:

  • (String)


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

def long_term_capital_gain_reinvestment
  @long_term_capital_gain_reinvestment
end

#short_term_capital_gain_reinvestmentString

Purchase using short-term capital gain cash proceeds

Returns:

  • (String)


42
43
44
# File 'lib/the_plaid_api/models/buy_type.rb', line 42

def short_term_capital_gain_reinvestment
  @short_term_capital_gain_reinvestment
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/the_plaid_api/models/buy_type.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  assignment = hash.key?('assignment') ? hash['assignment'] : SKIP
  contribution = hash.key?('contribution') ? hash['contribution'] : SKIP
  buy = hash.key?('buy') ? hash['buy'] : SKIP
  buy_to_cover = hash.key?('buy to cover') ? hash['buy to cover'] : SKIP
  dividend_reinvestment =
    hash.key?('dividend reinvestment') ? hash['dividend reinvestment'] : SKIP
  interest_reinvestment =
    hash.key?('interest reinvestment') ? hash['interest reinvestment'] : SKIP
  long_term_capital_gain_reinvestment =
    hash.key?('long-term capital gain reinvestment') ? hash['long-term capital gain reinvestment'] : SKIP
  short_term_capital_gain_reinvestment =
    hash.key?('short-term capital gain reinvestment') ? hash['short-term capital gain reinvestment'] : 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.
  BuyType.new(assignment: assignment,
              contribution: contribution,
              buy: buy,
              buy_to_cover: buy_to_cover,
              dividend_reinvestment: dividend_reinvestment,
              interest_reinvestment: interest_reinvestment,
              long_term_capital_gain_reinvestment: long_term_capital_gain_reinvestment,
              short_term_capital_gain_reinvestment: short_term_capital_gain_reinvestment,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/the_plaid_api/models/buy_type.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['assignment'] = 'assignment'
  @_hash['contribution'] = 'contribution'
  @_hash['buy'] = 'buy'
  @_hash['buy_to_cover'] = 'buy to cover'
  @_hash['dividend_reinvestment'] = 'dividend reinvestment'
  @_hash['interest_reinvestment'] = 'interest reinvestment'
  @_hash['long_term_capital_gain_reinvestment'] =
    'long-term capital gain reinvestment'
  @_hash['short_term_capital_gain_reinvestment'] =
    'short-term capital gain reinvestment'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/the_plaid_api/models/buy_type.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/the_plaid_api/models/buy_type.rb', line 61

def self.optionals
  %w[
    assignment
    contribution
    buy
    buy_to_cover
    dividend_reinvestment
    interest_reinvestment
    long_term_capital_gain_reinvestment
    short_term_capital_gain_reinvestment
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



154
155
156
157
158
159
160
161
162
163
# File 'lib/the_plaid_api/models/buy_type.rb', line 154

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} assignment: #{@assignment.inspect}, contribution: #{@contribution.inspect},"\
  " buy: #{@buy.inspect}, buy_to_cover: #{@buy_to_cover.inspect}, dividend_reinvestment:"\
  " #{@dividend_reinvestment.inspect}, interest_reinvestment:"\
  " #{@interest_reinvestment.inspect}, long_term_capital_gain_reinvestment:"\
  " #{@long_term_capital_gain_reinvestment.inspect}, short_term_capital_gain_reinvestment:"\
  " #{@short_term_capital_gain_reinvestment.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



143
144
145
146
147
148
149
150
151
# File 'lib/the_plaid_api/models/buy_type.rb', line 143

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} assignment: #{@assignment}, contribution: #{@contribution}, buy: #{@buy},"\
  " buy_to_cover: #{@buy_to_cover}, dividend_reinvestment: #{@dividend_reinvestment},"\
  " interest_reinvestment: #{@interest_reinvestment}, long_term_capital_gain_reinvestment:"\
  " #{@long_term_capital_gain_reinvestment}, short_term_capital_gain_reinvestment:"\
  " #{@short_term_capital_gain_reinvestment}, additional_properties:"\
  " #{@additional_properties}>"
end