snaptrade 2.0.30 → 2.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +31 -29
  3. data/README.md +5 -7
  4. data/lib/snaptrade/api/account_information_api.rb +16 -16
  5. data/lib/snaptrade/models/account_balance.rb +1 -1
  6. data/lib/snaptrade/models/account_balance_total.rb +2 -0
  7. data/lib/snaptrade/models/account_holdings_account.rb +5 -1
  8. data/lib/snaptrade/models/account_order_record.rb +4 -2
  9. data/lib/snaptrade/models/amount.rb +2 -0
  10. data/lib/snaptrade/models/balance.rb +3 -1
  11. data/lib/snaptrade/models/currency.rb +4 -1
  12. data/lib/snaptrade/models/exchange.rb +9 -1
  13. data/lib/snaptrade/models/figi_instrument.rb +3 -1
  14. data/lib/snaptrade/models/option_brokerage_symbol.rb +3 -1
  15. data/lib/snaptrade/models/options_position.rb +4 -3
  16. data/lib/snaptrade/models/options_position_currency.rb +4 -0
  17. data/lib/snaptrade/models/options_symbol.rb +12 -24
  18. data/lib/snaptrade/models/position.rb +6 -4
  19. data/lib/snaptrade/models/position_symbol.rb +6 -1
  20. data/lib/snaptrade/models/security_type.rb +5 -1
  21. data/lib/snaptrade/models/snap_trade_holdings_account_account_id.rb +11 -3
  22. data/lib/snaptrade/models/snap_trade_holdings_total_value.rb +3 -1
  23. data/lib/snaptrade/models/symbol_figi_instrument.rb +2 -0
  24. data/lib/snaptrade/models/underlying_symbol.rb +20 -5
  25. data/lib/snaptrade/models/{model_portfolio.rb → underlying_symbol_exchange.rb} +73 -12
  26. data/lib/snaptrade/models/{brokerage_symbol.rb → underlying_symbol_type.rb} +28 -38
  27. data/lib/snaptrade/models/universal_symbol.rb +9 -3
  28. data/lib/snaptrade/models/{model_asset_class.rb → universal_symbol_currency.rb} +24 -4
  29. data/lib/snaptrade/models/{portfolio_group.rb → universal_symbol_exchange.rb} +78 -7
  30. data/lib/snaptrade/version.rb +1 -1
  31. data/lib/snaptrade.rb +4 -37
  32. data/spec/api/account_information_api_spec.rb +3 -3
  33. data/spec/models/options_symbol_spec.rb +0 -12
  34. data/spec/models/{brokerage_symbol_option_symbol_spec.rb → underlying_symbol_exchange_spec.rb} +14 -14
  35. data/spec/models/underlying_symbol_spec.rb +6 -0
  36. data/spec/models/{trade_impact_spec.rb → underlying_symbol_type_spec.rb} +10 -16
  37. data/spec/models/{model_portfolio_spec.rb → universal_symbol_currency_spec.rb} +8 -8
  38. data/spec/models/{trade_spec.rb → universal_symbol_exchange_spec.rb} +13 -13
  39. metadata +113 -212
  40. data/lib/snaptrade/models/brokerage_authorization_type.rb +0 -216
  41. data/lib/snaptrade/models/brokerage_authorization_type_type.rb +0 -37
  42. data/lib/snaptrade/models/brokerage_symbol_option_symbol.rb +0 -325
  43. data/lib/snaptrade/models/brokerage_symbol_symbol.rb +0 -339
  44. data/lib/snaptrade/models/calculated_trade.rb +0 -228
  45. data/lib/snaptrade/models/excluded_asset.rb +0 -217
  46. data/lib/snaptrade/models/jwt.rb +0 -217
  47. data/lib/snaptrade/models/model_asset_class_details.rb +0 -227
  48. data/lib/snaptrade/models/model_asset_class_target.rb +0 -216
  49. data/lib/snaptrade/models/model_portfolio_asset_class.rb +0 -249
  50. data/lib/snaptrade/models/model_portfolio_details.rb +0 -238
  51. data/lib/snaptrade/models/model_portfolio_security.rb +0 -249
  52. data/lib/snaptrade/models/model_type.rb +0 -38
  53. data/lib/snaptrade/models/options_holdings.rb +0 -267
  54. data/lib/snaptrade/models/portfolio_group_info.rb +0 -325
  55. data/lib/snaptrade/models/portfolio_group_position.rb +0 -237
  56. data/lib/snaptrade/models/portfolio_group_settings.rb +0 -276
  57. data/lib/snaptrade/models/redirect_tokenand_pin.rb +0 -226
  58. data/lib/snaptrade/models/snap_trade_api_disclaimer_accept_status.rb +0 -226
  59. data/lib/snaptrade/models/state.rb +0 -40
  60. data/lib/snaptrade/models/strategy_impact.rb +0 -309
  61. data/lib/snaptrade/models/strategy_impact_legs_inner.rb +0 -270
  62. data/lib/snaptrade/models/strategy_order_place.rb +0 -228
  63. data/lib/snaptrade/models/strategy_order_place_orders_inner.rb +0 -596
  64. data/lib/snaptrade/models/strategy_order_place_orders_inner_legs_inner.rb +0 -270
  65. data/lib/snaptrade/models/target_asset.rb +0 -289
  66. data/lib/snaptrade/models/trade.rb +0 -280
  67. data/lib/snaptrade/models/trade_action.rb +0 -37
  68. data/lib/snaptrade/models/trade_execution_status.rb +0 -297
  69. data/lib/snaptrade/models/trade_execution_status_action.rb +0 -37
  70. data/lib/snaptrade/models/trade_impact.rb +0 -256
  71. data/lib/snaptrade/models/user_error_log.rb +0 -262
  72. data/lib/snaptrade/models/user_settings.rb +0 -298
  73. data/spec/models/brokerage_authorization_type_spec.rb +0 -29
  74. data/spec/models/brokerage_authorization_type_type_spec.rb +0 -23
  75. data/spec/models/brokerage_symbol_spec.rb +0 -59
  76. data/spec/models/brokerage_symbol_symbol_spec.rb +0 -83
  77. data/spec/models/calculated_trade_spec.rb +0 -35
  78. data/spec/models/excluded_asset_spec.rb +0 -29
  79. data/spec/models/jwt_spec.rb +0 -29
  80. data/spec/models/model_asset_class_details_spec.rb +0 -35
  81. data/spec/models/model_asset_class_spec.rb +0 -35
  82. data/spec/models/model_asset_class_target_spec.rb +0 -29
  83. data/spec/models/model_portfolio_asset_class_spec.rb +0 -35
  84. data/spec/models/model_portfolio_details_spec.rb +0 -41
  85. data/spec/models/model_portfolio_security_spec.rb +0 -35
  86. data/spec/models/model_type_spec.rb +0 -23
  87. data/spec/models/options_holdings_spec.rb +0 -59
  88. data/spec/models/portfolio_group_info_spec.rb +0 -89
  89. data/spec/models/portfolio_group_position_spec.rb +0 -41
  90. data/spec/models/portfolio_group_settings_spec.rb +0 -53
  91. data/spec/models/portfolio_group_spec.rb +0 -35
  92. data/spec/models/redirect_tokenand_pin_spec.rb +0 -35
  93. data/spec/models/snap_trade_api_disclaimer_accept_status_spec.rb +0 -35
  94. data/spec/models/state_spec.rb +0 -23
  95. data/spec/models/strategy_impact_legs_inner_spec.rb +0 -65
  96. data/spec/models/strategy_impact_spec.rb +0 -89
  97. data/spec/models/strategy_order_place_orders_inner_legs_inner_spec.rb +0 -65
  98. data/spec/models/strategy_order_place_orders_inner_spec.rb +0 -281
  99. data/spec/models/strategy_order_place_spec.rb +0 -35
  100. data/spec/models/target_asset_spec.rb +0 -59
  101. data/spec/models/trade_action_spec.rb +0 -23
  102. data/spec/models/trade_execution_status_action_spec.rb +0 -23
  103. data/spec/models/trade_execution_status_spec.rb +0 -77
  104. data/spec/models/user_error_log_spec.rb +0 -59
  105. data/spec/models/user_settings_spec.rb +0 -83
@@ -1,325 +0,0 @@
1
- =begin
2
- #SnapTrade
3
-
4
- #Connect brokerage accounts to your app for live positions and trading
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: api@snaptrade.com
8
- =end
9
-
10
- require 'date'
11
- require 'time'
12
-
13
- module SnapTrade
14
- # Summary of all relevant information about a portfolio group.
15
- class PortfolioGroupInfo
16
- attr_accessor :symbols
17
-
18
- attr_accessor :quotable_symbols
19
-
20
- attr_accessor :balances
21
-
22
- attr_accessor :positions
23
-
24
- attr_accessor :target_positions
25
-
26
- attr_accessor :ideal_positions
27
-
28
- attr_accessor :excluded_positions
29
-
30
- attr_accessor :calculated_trades
31
-
32
- attr_accessor :brokerage_authorizations
33
-
34
- attr_accessor :accuracy
35
-
36
- attr_accessor :settings
37
-
38
- # Attribute mapping from ruby-style variable name to JSON key.
39
- def self.attribute_map
40
- {
41
- :'symbols' => :'symbols',
42
- :'quotable_symbols' => :'quotable_symbols',
43
- :'balances' => :'balances',
44
- :'positions' => :'positions',
45
- :'target_positions' => :'target_positions',
46
- :'ideal_positions' => :'ideal_positions',
47
- :'excluded_positions' => :'excluded_positions',
48
- :'calculated_trades' => :'calculated_trades',
49
- :'brokerage_authorizations' => :'brokerage_authorizations',
50
- :'accuracy' => :'accuracy',
51
- :'settings' => :'settings'
52
- }
53
- end
54
-
55
- # Returns all the JSON keys this model knows about
56
- def self.acceptable_attributes
57
- attribute_map.values
58
- end
59
-
60
- # Attribute type mapping.
61
- def self.openapi_types
62
- {
63
- :'symbols' => :'Array<UniversalSymbol>',
64
- :'quotable_symbols' => :'Array<UniversalSymbol>',
65
- :'balances' => :'Array<Balance>',
66
- :'positions' => :'Array<Position>',
67
- :'target_positions' => :'Array<TargetAsset>',
68
- :'ideal_positions' => :'Array<Position>',
69
- :'excluded_positions' => :'Array<ExcludedAsset>',
70
- :'calculated_trades' => :'Array<CalculatedTrade>',
71
- :'brokerage_authorizations' => :'Array<BrokerageAuthorization>',
72
- :'accuracy' => :'Float',
73
- :'settings' => :'PortfolioGroupSettings'
74
- }
75
- end
76
-
77
- # List of attributes with nullable: true
78
- def self.openapi_nullable
79
- Set.new([
80
- ])
81
- end
82
-
83
- # Initializes the object
84
- # @param [Hash] attributes Model attributes in the form of hash
85
- def initialize(attributes = {})
86
- if (!attributes.is_a?(Hash))
87
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::PortfolioGroupInfo` initialize method"
88
- end
89
-
90
- # check to see if the attribute exists and convert string to symbol for hash key
91
- attributes = attributes.each_with_object({}) { |(k, v), h|
92
- if (!self.class.attribute_map.key?(k.to_sym))
93
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::PortfolioGroupInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
- end
95
- h[k.to_sym] = v
96
- }
97
-
98
- if attributes.key?(:'symbols')
99
- if (value = attributes[:'symbols']).is_a?(Array)
100
- self.symbols = value
101
- end
102
- end
103
-
104
- if attributes.key?(:'quotable_symbols')
105
- if (value = attributes[:'quotable_symbols']).is_a?(Array)
106
- self.quotable_symbols = value
107
- end
108
- end
109
-
110
- if attributes.key?(:'balances')
111
- if (value = attributes[:'balances']).is_a?(Array)
112
- self.balances = value
113
- end
114
- end
115
-
116
- if attributes.key?(:'positions')
117
- if (value = attributes[:'positions']).is_a?(Array)
118
- self.positions = value
119
- end
120
- end
121
-
122
- if attributes.key?(:'target_positions')
123
- if (value = attributes[:'target_positions']).is_a?(Array)
124
- self.target_positions = value
125
- end
126
- end
127
-
128
- if attributes.key?(:'ideal_positions')
129
- if (value = attributes[:'ideal_positions']).is_a?(Array)
130
- self.ideal_positions = value
131
- end
132
- end
133
-
134
- if attributes.key?(:'excluded_positions')
135
- if (value = attributes[:'excluded_positions']).is_a?(Array)
136
- self.excluded_positions = value
137
- end
138
- end
139
-
140
- if attributes.key?(:'calculated_trades')
141
- if (value = attributes[:'calculated_trades']).is_a?(Array)
142
- self.calculated_trades = value
143
- end
144
- end
145
-
146
- if attributes.key?(:'brokerage_authorizations')
147
- if (value = attributes[:'brokerage_authorizations']).is_a?(Array)
148
- self.brokerage_authorizations = value
149
- end
150
- end
151
-
152
- if attributes.key?(:'accuracy')
153
- self.accuracy = attributes[:'accuracy']
154
- end
155
-
156
- if attributes.key?(:'settings')
157
- self.settings = attributes[:'settings']
158
- end
159
- end
160
-
161
- # Show invalid properties with the reasons. Usually used together with valid?
162
- # @return Array for valid properties with the reasons
163
- def list_invalid_properties
164
- invalid_properties = Array.new
165
- invalid_properties
166
- end
167
-
168
- # Check to see if the all the properties in the model are valid
169
- # @return true if the model is valid
170
- def valid?
171
- true
172
- end
173
-
174
- # Checks equality by comparing each attribute.
175
- # @param [Object] Object to be compared
176
- def ==(o)
177
- return true if self.equal?(o)
178
- self.class == o.class &&
179
- symbols == o.symbols &&
180
- quotable_symbols == o.quotable_symbols &&
181
- balances == o.balances &&
182
- positions == o.positions &&
183
- target_positions == o.target_positions &&
184
- ideal_positions == o.ideal_positions &&
185
- excluded_positions == o.excluded_positions &&
186
- calculated_trades == o.calculated_trades &&
187
- brokerage_authorizations == o.brokerage_authorizations &&
188
- accuracy == o.accuracy &&
189
- settings == o.settings
190
- end
191
-
192
- # @see the `==` method
193
- # @param [Object] Object to be compared
194
- def eql?(o)
195
- self == o
196
- end
197
-
198
- # Calculates hash code according to all attributes.
199
- # @return [Integer] Hash code
200
- def hash
201
- [symbols, quotable_symbols, balances, positions, target_positions, ideal_positions, excluded_positions, calculated_trades, brokerage_authorizations, accuracy, settings].hash
202
- end
203
-
204
- # Builds the object from hash
205
- # @param [Hash] attributes Model attributes in the form of hash
206
- # @return [Object] Returns the model itself
207
- def self.build_from_hash(attributes)
208
- new.build_from_hash(attributes)
209
- end
210
-
211
- # Builds the object from hash
212
- # @param [Hash] attributes Model attributes in the form of hash
213
- # @return [Object] Returns the model itself
214
- def build_from_hash(attributes)
215
- return nil unless attributes.is_a?(Hash)
216
- attributes = attributes.transform_keys(&:to_sym)
217
- self.class.openapi_types.each_pair do |key, type|
218
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
219
- self.send("#{key}=", nil)
220
- elsif type =~ /\AArray<(.*)>/i
221
- # check to ensure the input is an array given that the attribute
222
- # is documented as an array but the input is not
223
- if attributes[self.class.attribute_map[key]].is_a?(Array)
224
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
225
- end
226
- elsif !attributes[self.class.attribute_map[key]].nil?
227
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
228
- end
229
- end
230
-
231
- self
232
- end
233
-
234
- # Deserializes the data based on type
235
- # @param string type Data type
236
- # @param string value Value to be deserialized
237
- # @return [Object] Deserialized data
238
- def _deserialize(type, value)
239
- case type.to_sym
240
- when :Time
241
- Time.parse(value)
242
- when :Date
243
- Date.parse(value)
244
- when :String
245
- value.to_s
246
- when :Integer
247
- value.to_i
248
- when :Float
249
- value.to_f
250
- when :Boolean
251
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
252
- true
253
- else
254
- false
255
- end
256
- when :Object
257
- # generic object (usually a Hash), return directly
258
- value
259
- when /\AArray<(?<inner_type>.+)>\z/
260
- inner_type = Regexp.last_match[:inner_type]
261
- value.map { |v| _deserialize(inner_type, v) }
262
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
263
- k_type = Regexp.last_match[:k_type]
264
- v_type = Regexp.last_match[:v_type]
265
- {}.tap do |hash|
266
- value.each do |k, v|
267
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
268
- end
269
- end
270
- else # model
271
- # models (e.g. Pet) or oneOf
272
- klass = SnapTrade.const_get(type)
273
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
274
- end
275
- end
276
-
277
- # Returns the string representation of the object
278
- # @return [String] String presentation of the object
279
- def to_s
280
- to_hash.to_s
281
- end
282
-
283
- # to_body is an alias to to_hash (backward compatibility)
284
- # @return [Hash] Returns the object in the form of hash
285
- def to_body
286
- to_hash
287
- end
288
-
289
- # Returns the object in the form of hash
290
- # @return [Hash] Returns the object in the form of hash
291
- def to_hash
292
- hash = {}
293
- self.class.attribute_map.each_pair do |attr, param|
294
- value = self.send(attr)
295
- if value.nil?
296
- is_nullable = self.class.openapi_nullable.include?(attr)
297
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
298
- end
299
-
300
- hash[param] = _to_hash(value)
301
- end
302
- hash
303
- end
304
-
305
- # Outputs non-array value in the form of hash
306
- # For object, use to_hash. Otherwise, just return the value
307
- # @param [Object] value Any valid value
308
- # @return [Hash] Returns the value in the form of hash
309
- def _to_hash(value)
310
- if value.is_a?(Array)
311
- value.compact.map { |v| _to_hash(v) }
312
- elsif value.is_a?(Hash)
313
- {}.tap do |hash|
314
- value.each { |k, v| hash[k] = _to_hash(v) }
315
- end
316
- elsif value.respond_to? :to_hash
317
- value.to_hash
318
- else
319
- value
320
- end
321
- end
322
-
323
- end
324
-
325
- end
@@ -1,237 +0,0 @@
1
- =begin
2
- #SnapTrade
3
-
4
- #Connect brokerage accounts to your app for live positions and trading
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: api@snaptrade.com
8
- =end
9
-
10
- require 'date'
11
- require 'time'
12
-
13
- module SnapTrade
14
- # Details of a security held
15
- class PortfolioGroupPosition
16
- attr_accessor :symbol
17
-
18
- # Last known market price for the symbol
19
- attr_accessor :price
20
-
21
- attr_accessor :units
22
-
23
- # Attribute mapping from ruby-style variable name to JSON key.
24
- def self.attribute_map
25
- {
26
- :'symbol' => :'symbol',
27
- :'price' => :'price',
28
- :'units' => :'units'
29
- }
30
- end
31
-
32
- # Returns all the JSON keys this model knows about
33
- def self.acceptable_attributes
34
- attribute_map.values
35
- end
36
-
37
- # Attribute type mapping.
38
- def self.openapi_types
39
- {
40
- :'symbol' => :'UniversalSymbol',
41
- :'price' => :'Float',
42
- :'units' => :'Integer'
43
- }
44
- end
45
-
46
- # List of attributes with nullable: true
47
- def self.openapi_nullable
48
- Set.new([
49
- :'price',
50
- ])
51
- end
52
-
53
- # Initializes the object
54
- # @param [Hash] attributes Model attributes in the form of hash
55
- def initialize(attributes = {})
56
- if (!attributes.is_a?(Hash))
57
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::PortfolioGroupPosition` initialize method"
58
- end
59
-
60
- # check to see if the attribute exists and convert string to symbol for hash key
61
- attributes = attributes.each_with_object({}) { |(k, v), h|
62
- if (!self.class.attribute_map.key?(k.to_sym))
63
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::PortfolioGroupPosition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
- end
65
- h[k.to_sym] = v
66
- }
67
-
68
- if attributes.key?(:'symbol')
69
- self.symbol = attributes[:'symbol']
70
- end
71
-
72
- if attributes.key?(:'price')
73
- self.price = attributes[:'price']
74
- end
75
-
76
- if attributes.key?(:'units')
77
- self.units = attributes[:'units']
78
- end
79
- end
80
-
81
- # Show invalid properties with the reasons. Usually used together with valid?
82
- # @return Array for valid properties with the reasons
83
- def list_invalid_properties
84
- invalid_properties = Array.new
85
- invalid_properties
86
- end
87
-
88
- # Check to see if the all the properties in the model are valid
89
- # @return true if the model is valid
90
- def valid?
91
- true
92
- end
93
-
94
- # Checks equality by comparing each attribute.
95
- # @param [Object] Object to be compared
96
- def ==(o)
97
- return true if self.equal?(o)
98
- self.class == o.class &&
99
- symbol == o.symbol &&
100
- price == o.price &&
101
- units == o.units
102
- end
103
-
104
- # @see the `==` method
105
- # @param [Object] Object to be compared
106
- def eql?(o)
107
- self == o
108
- end
109
-
110
- # Calculates hash code according to all attributes.
111
- # @return [Integer] Hash code
112
- def hash
113
- [symbol, price, units].hash
114
- end
115
-
116
- # Builds the object from hash
117
- # @param [Hash] attributes Model attributes in the form of hash
118
- # @return [Object] Returns the model itself
119
- def self.build_from_hash(attributes)
120
- new.build_from_hash(attributes)
121
- end
122
-
123
- # Builds the object from hash
124
- # @param [Hash] attributes Model attributes in the form of hash
125
- # @return [Object] Returns the model itself
126
- def build_from_hash(attributes)
127
- return nil unless attributes.is_a?(Hash)
128
- attributes = attributes.transform_keys(&:to_sym)
129
- self.class.openapi_types.each_pair do |key, type|
130
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
131
- self.send("#{key}=", nil)
132
- elsif type =~ /\AArray<(.*)>/i
133
- # check to ensure the input is an array given that the attribute
134
- # is documented as an array but the input is not
135
- if attributes[self.class.attribute_map[key]].is_a?(Array)
136
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
137
- end
138
- elsif !attributes[self.class.attribute_map[key]].nil?
139
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
140
- end
141
- end
142
-
143
- self
144
- end
145
-
146
- # Deserializes the data based on type
147
- # @param string type Data type
148
- # @param string value Value to be deserialized
149
- # @return [Object] Deserialized data
150
- def _deserialize(type, value)
151
- case type.to_sym
152
- when :Time
153
- Time.parse(value)
154
- when :Date
155
- Date.parse(value)
156
- when :String
157
- value.to_s
158
- when :Integer
159
- value.to_i
160
- when :Float
161
- value.to_f
162
- when :Boolean
163
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
- true
165
- else
166
- false
167
- end
168
- when :Object
169
- # generic object (usually a Hash), return directly
170
- value
171
- when /\AArray<(?<inner_type>.+)>\z/
172
- inner_type = Regexp.last_match[:inner_type]
173
- value.map { |v| _deserialize(inner_type, v) }
174
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
- k_type = Regexp.last_match[:k_type]
176
- v_type = Regexp.last_match[:v_type]
177
- {}.tap do |hash|
178
- value.each do |k, v|
179
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
- end
181
- end
182
- else # model
183
- # models (e.g. Pet) or oneOf
184
- klass = SnapTrade.const_get(type)
185
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
186
- end
187
- end
188
-
189
- # Returns the string representation of the object
190
- # @return [String] String presentation of the object
191
- def to_s
192
- to_hash.to_s
193
- end
194
-
195
- # to_body is an alias to to_hash (backward compatibility)
196
- # @return [Hash] Returns the object in the form of hash
197
- def to_body
198
- to_hash
199
- end
200
-
201
- # Returns the object in the form of hash
202
- # @return [Hash] Returns the object in the form of hash
203
- def to_hash
204
- hash = {}
205
- self.class.attribute_map.each_pair do |attr, param|
206
- value = self.send(attr)
207
- if value.nil?
208
- is_nullable = self.class.openapi_nullable.include?(attr)
209
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
- end
211
-
212
- hash[param] = _to_hash(value)
213
- end
214
- hash
215
- end
216
-
217
- # Outputs non-array value in the form of hash
218
- # For object, use to_hash. Otherwise, just return the value
219
- # @param [Object] value Any valid value
220
- # @return [Hash] Returns the value in the form of hash
221
- def _to_hash(value)
222
- if value.is_a?(Array)
223
- value.compact.map { |v| _to_hash(v) }
224
- elsif value.is_a?(Hash)
225
- {}.tap do |hash|
226
- value.each { |k, v| hash[k] = _to_hash(v) }
227
- end
228
- elsif value.respond_to? :to_hash
229
- value.to_hash
230
- else
231
- value
232
- end
233
- end
234
-
235
- end
236
-
237
- end