snaptrade 2.0.31 → 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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +31 -29
  3. data/README.md +4 -2
  4. data/lib/snaptrade/api/account_information_api.rb +6 -2
  5. data/lib/snaptrade/models/account_holdings_account.rb +1 -1
  6. data/lib/snaptrade/models/account_order_record.rb +4 -2
  7. data/lib/snaptrade/models/exchange.rb +9 -1
  8. data/lib/snaptrade/models/figi_instrument.rb +3 -1
  9. data/lib/snaptrade/models/option_brokerage_symbol.rb +3 -1
  10. data/lib/snaptrade/models/options_position.rb +1 -1
  11. data/lib/snaptrade/models/options_position_currency.rb +1 -0
  12. data/lib/snaptrade/models/options_symbol.rb +12 -24
  13. data/lib/snaptrade/models/position_symbol.rb +6 -1
  14. data/lib/snaptrade/models/security_type.rb +5 -1
  15. data/lib/snaptrade/models/symbol_figi_instrument.rb +2 -0
  16. data/lib/snaptrade/models/underlying_symbol.rb +20 -5
  17. data/lib/snaptrade/models/{model_portfolio.rb → underlying_symbol_exchange.rb} +73 -12
  18. data/lib/snaptrade/models/{brokerage_symbol.rb → underlying_symbol_type.rb} +28 -38
  19. data/lib/snaptrade/models/universal_symbol.rb +9 -3
  20. data/lib/snaptrade/models/{model_asset_class.rb → universal_symbol_currency.rb} +24 -4
  21. data/lib/snaptrade/models/{portfolio_group.rb → universal_symbol_exchange.rb} +78 -7
  22. data/lib/snaptrade/version.rb +1 -1
  23. data/lib/snaptrade.rb +4 -36
  24. data/spec/api/account_information_api_spec.rb +1 -1
  25. data/spec/models/options_symbol_spec.rb +0 -12
  26. data/spec/models/{brokerage_symbol_option_symbol_spec.rb → underlying_symbol_exchange_spec.rb} +14 -14
  27. data/spec/models/underlying_symbol_spec.rb +6 -0
  28. data/spec/models/{trade_impact_spec.rb → underlying_symbol_type_spec.rb} +10 -16
  29. data/spec/models/{model_portfolio_spec.rb → universal_symbol_currency_spec.rb} +8 -8
  30. data/spec/models/{trade_spec.rb → universal_symbol_exchange_spec.rb} +13 -13
  31. metadata +113 -209
  32. data/lib/snaptrade/models/brokerage_authorization_type.rb +0 -216
  33. data/lib/snaptrade/models/brokerage_authorization_type_type.rb +0 -37
  34. data/lib/snaptrade/models/brokerage_symbol_option_symbol.rb +0 -325
  35. data/lib/snaptrade/models/brokerage_symbol_symbol.rb +0 -339
  36. data/lib/snaptrade/models/calculated_trade.rb +0 -228
  37. data/lib/snaptrade/models/excluded_asset.rb +0 -217
  38. data/lib/snaptrade/models/jwt.rb +0 -217
  39. data/lib/snaptrade/models/model_asset_class_details.rb +0 -227
  40. data/lib/snaptrade/models/model_asset_class_target.rb +0 -216
  41. data/lib/snaptrade/models/model_portfolio_asset_class.rb +0 -249
  42. data/lib/snaptrade/models/model_portfolio_details.rb +0 -238
  43. data/lib/snaptrade/models/model_portfolio_security.rb +0 -249
  44. data/lib/snaptrade/models/model_type.rb +0 -38
  45. data/lib/snaptrade/models/portfolio_group_info.rb +0 -325
  46. data/lib/snaptrade/models/portfolio_group_position.rb +0 -237
  47. data/lib/snaptrade/models/portfolio_group_settings.rb +0 -276
  48. data/lib/snaptrade/models/redirect_tokenand_pin.rb +0 -226
  49. data/lib/snaptrade/models/snap_trade_api_disclaimer_accept_status.rb +0 -226
  50. data/lib/snaptrade/models/state.rb +0 -40
  51. data/lib/snaptrade/models/strategy_impact.rb +0 -309
  52. data/lib/snaptrade/models/strategy_impact_legs_inner.rb +0 -270
  53. data/lib/snaptrade/models/strategy_order_place.rb +0 -228
  54. data/lib/snaptrade/models/strategy_order_place_orders_inner.rb +0 -596
  55. data/lib/snaptrade/models/strategy_order_place_orders_inner_legs_inner.rb +0 -270
  56. data/lib/snaptrade/models/target_asset.rb +0 -289
  57. data/lib/snaptrade/models/trade.rb +0 -280
  58. data/lib/snaptrade/models/trade_action.rb +0 -37
  59. data/lib/snaptrade/models/trade_execution_status.rb +0 -297
  60. data/lib/snaptrade/models/trade_execution_status_action.rb +0 -37
  61. data/lib/snaptrade/models/trade_impact.rb +0 -256
  62. data/lib/snaptrade/models/user_error_log.rb +0 -262
  63. data/lib/snaptrade/models/user_settings.rb +0 -298
  64. data/spec/models/brokerage_authorization_type_spec.rb +0 -29
  65. data/spec/models/brokerage_authorization_type_type_spec.rb +0 -23
  66. data/spec/models/brokerage_symbol_spec.rb +0 -59
  67. data/spec/models/brokerage_symbol_symbol_spec.rb +0 -83
  68. data/spec/models/calculated_trade_spec.rb +0 -35
  69. data/spec/models/excluded_asset_spec.rb +0 -29
  70. data/spec/models/jwt_spec.rb +0 -29
  71. data/spec/models/model_asset_class_details_spec.rb +0 -35
  72. data/spec/models/model_asset_class_spec.rb +0 -35
  73. data/spec/models/model_asset_class_target_spec.rb +0 -29
  74. data/spec/models/model_portfolio_asset_class_spec.rb +0 -35
  75. data/spec/models/model_portfolio_details_spec.rb +0 -41
  76. data/spec/models/model_portfolio_security_spec.rb +0 -35
  77. data/spec/models/model_type_spec.rb +0 -23
  78. data/spec/models/portfolio_group_info_spec.rb +0 -89
  79. data/spec/models/portfolio_group_position_spec.rb +0 -41
  80. data/spec/models/portfolio_group_settings_spec.rb +0 -53
  81. data/spec/models/portfolio_group_spec.rb +0 -35
  82. data/spec/models/redirect_tokenand_pin_spec.rb +0 -35
  83. data/spec/models/snap_trade_api_disclaimer_accept_status_spec.rb +0 -35
  84. data/spec/models/state_spec.rb +0 -23
  85. data/spec/models/strategy_impact_legs_inner_spec.rb +0 -65
  86. data/spec/models/strategy_impact_spec.rb +0 -89
  87. data/spec/models/strategy_order_place_orders_inner_legs_inner_spec.rb +0 -65
  88. data/spec/models/strategy_order_place_orders_inner_spec.rb +0 -281
  89. data/spec/models/strategy_order_place_spec.rb +0 -35
  90. data/spec/models/target_asset_spec.rb +0 -59
  91. data/spec/models/trade_action_spec.rb +0 -23
  92. data/spec/models/trade_execution_status_action_spec.rb +0 -23
  93. data/spec/models/trade_execution_status_spec.rb +0 -77
  94. data/spec/models/user_error_log_spec.rb +0 -59
  95. data/spec/models/user_settings_spec.rb +0 -83
@@ -1,596 +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
- class StrategyOrderPlaceOrdersInner
15
- attr_accessor :id
16
-
17
- attr_accessor :symbol
18
-
19
- attr_accessor :symbol_id
20
-
21
- attr_accessor :total_quantity
22
-
23
- attr_accessor :open_quantity
24
-
25
- attr_accessor :filled_quantity
26
-
27
- attr_accessor :canceled_quantity
28
-
29
- attr_accessor :side
30
-
31
- attr_accessor :order_type
32
-
33
- attr_accessor :limit_price
34
-
35
- attr_accessor :stop_price
36
-
37
- attr_accessor :is_all_or_none
38
-
39
- attr_accessor :is_anonymous
40
-
41
- attr_accessor :iceberg_quantity
42
-
43
- attr_accessor :min_quantity
44
-
45
- attr_accessor :avg_exec_price
46
-
47
- attr_accessor :last_exec_price
48
-
49
- attr_accessor :source
50
-
51
- attr_accessor :time_in_force
52
-
53
- attr_accessor :gtd_date
54
-
55
- attr_accessor :state
56
-
57
- attr_accessor :rejection_reason
58
-
59
- attr_accessor :chain_id
60
-
61
- attr_accessor :creation_time
62
-
63
- attr_accessor :update_time
64
-
65
- attr_accessor :notes
66
-
67
- attr_accessor :primary_route
68
-
69
- attr_accessor :secondary_route
70
-
71
- attr_accessor :order_route
72
-
73
- attr_accessor :venue_holding_order
74
-
75
- attr_accessor :comission_charged
76
-
77
- attr_accessor :exchange_order_id
78
-
79
- attr_accessor :is_significant_share_holder
80
-
81
- attr_accessor :is_insider
82
-
83
- attr_accessor :is_limit_offset_in_dollar
84
-
85
- attr_accessor :user_id
86
-
87
- attr_accessor :placement_commission
88
-
89
- attr_accessor :legs
90
-
91
- attr_accessor :strategy_type
92
-
93
- attr_accessor :trigger_stop_price
94
-
95
- attr_accessor :order_group_id
96
-
97
- attr_accessor :order_class
98
-
99
- attr_accessor :is_cross_zero
100
-
101
- # Attribute mapping from ruby-style variable name to JSON key.
102
- def self.attribute_map
103
- {
104
- :'id' => :'id',
105
- :'symbol' => :'symbol',
106
- :'symbol_id' => :'symbolId',
107
- :'total_quantity' => :'totalQuantity',
108
- :'open_quantity' => :'openQuantity',
109
- :'filled_quantity' => :'filledQuantity',
110
- :'canceled_quantity' => :'canceledQuantity',
111
- :'side' => :'side',
112
- :'order_type' => :'orderType',
113
- :'limit_price' => :'limitPrice',
114
- :'stop_price' => :'stopPrice',
115
- :'is_all_or_none' => :'isAllOrNone',
116
- :'is_anonymous' => :'isAnonymous',
117
- :'iceberg_quantity' => :'icebergQuantity',
118
- :'min_quantity' => :'minQuantity',
119
- :'avg_exec_price' => :'avgExecPrice',
120
- :'last_exec_price' => :'lastExecPrice',
121
- :'source' => :'source',
122
- :'time_in_force' => :'timeInForce',
123
- :'gtd_date' => :'gtdDate',
124
- :'state' => :'state',
125
- :'rejection_reason' => :'rejectionReason',
126
- :'chain_id' => :'chainId',
127
- :'creation_time' => :'creationTime',
128
- :'update_time' => :'updateTime',
129
- :'notes' => :'notes',
130
- :'primary_route' => :'primaryRoute',
131
- :'secondary_route' => :'secondaryRoute',
132
- :'order_route' => :'orderRoute',
133
- :'venue_holding_order' => :'venueHoldingOrder',
134
- :'comission_charged' => :'comissionCharged',
135
- :'exchange_order_id' => :'exchangeOrderId',
136
- :'is_significant_share_holder' => :'isSignificantShareHolder',
137
- :'is_insider' => :'isInsider',
138
- :'is_limit_offset_in_dollar' => :'isLimitOffsetInDollar',
139
- :'user_id' => :'userId',
140
- :'placement_commission' => :'placementCommission',
141
- :'legs' => :'legs',
142
- :'strategy_type' => :'strategyType',
143
- :'trigger_stop_price' => :'triggerStopPrice',
144
- :'order_group_id' => :'orderGroupId',
145
- :'order_class' => :'orderClass',
146
- :'is_cross_zero' => :'isCrossZero'
147
- }
148
- end
149
-
150
- # Returns all the JSON keys this model knows about
151
- def self.acceptable_attributes
152
- attribute_map.values
153
- end
154
-
155
- # Attribute type mapping.
156
- def self.openapi_types
157
- {
158
- :'id' => :'Integer',
159
- :'symbol' => :'String',
160
- :'symbol_id' => :'Integer',
161
- :'total_quantity' => :'Integer',
162
- :'open_quantity' => :'Integer',
163
- :'filled_quantity' => :'Integer',
164
- :'canceled_quantity' => :'Integer',
165
- :'side' => :'String',
166
- :'order_type' => :'String',
167
- :'limit_price' => :'String',
168
- :'stop_price' => :'String',
169
- :'is_all_or_none' => :'Boolean',
170
- :'is_anonymous' => :'Boolean',
171
- :'iceberg_quantity' => :'String',
172
- :'min_quantity' => :'String',
173
- :'avg_exec_price' => :'Integer',
174
- :'last_exec_price' => :'String',
175
- :'source' => :'String',
176
- :'time_in_force' => :'String',
177
- :'gtd_date' => :'String',
178
- :'state' => :'String',
179
- :'rejection_reason' => :'String',
180
- :'chain_id' => :'Integer',
181
- :'creation_time' => :'String',
182
- :'update_time' => :'String',
183
- :'notes' => :'String',
184
- :'primary_route' => :'String',
185
- :'secondary_route' => :'String',
186
- :'order_route' => :'String',
187
- :'venue_holding_order' => :'String',
188
- :'comission_charged' => :'Integer',
189
- :'exchange_order_id' => :'String',
190
- :'is_significant_share_holder' => :'Boolean',
191
- :'is_insider' => :'Boolean',
192
- :'is_limit_offset_in_dollar' => :'Boolean',
193
- :'user_id' => :'Integer',
194
- :'placement_commission' => :'String',
195
- :'legs' => :'Array<StrategyOrderPlaceOrdersInnerLegsInner>',
196
- :'strategy_type' => :'String',
197
- :'trigger_stop_price' => :'String',
198
- :'order_group_id' => :'Integer',
199
- :'order_class' => :'String',
200
- :'is_cross_zero' => :'Boolean'
201
- }
202
- end
203
-
204
- # List of attributes with nullable: true
205
- def self.openapi_nullable
206
- Set.new([
207
- ])
208
- end
209
-
210
- # Initializes the object
211
- # @param [Hash] attributes Model attributes in the form of hash
212
- def initialize(attributes = {})
213
- if (!attributes.is_a?(Hash))
214
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::StrategyOrderPlaceOrdersInner` initialize method"
215
- end
216
-
217
- # check to see if the attribute exists and convert string to symbol for hash key
218
- attributes = attributes.each_with_object({}) { |(k, v), h|
219
- if (!self.class.attribute_map.key?(k.to_sym))
220
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::StrategyOrderPlaceOrdersInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
221
- end
222
- h[k.to_sym] = v
223
- }
224
-
225
- if attributes.key?(:'id')
226
- self.id = attributes[:'id']
227
- end
228
-
229
- if attributes.key?(:'symbol')
230
- self.symbol = attributes[:'symbol']
231
- end
232
-
233
- if attributes.key?(:'symbol_id')
234
- self.symbol_id = attributes[:'symbol_id']
235
- end
236
-
237
- if attributes.key?(:'total_quantity')
238
- self.total_quantity = attributes[:'total_quantity']
239
- end
240
-
241
- if attributes.key?(:'open_quantity')
242
- self.open_quantity = attributes[:'open_quantity']
243
- end
244
-
245
- if attributes.key?(:'filled_quantity')
246
- self.filled_quantity = attributes[:'filled_quantity']
247
- end
248
-
249
- if attributes.key?(:'canceled_quantity')
250
- self.canceled_quantity = attributes[:'canceled_quantity']
251
- end
252
-
253
- if attributes.key?(:'side')
254
- self.side = attributes[:'side']
255
- end
256
-
257
- if attributes.key?(:'order_type')
258
- self.order_type = attributes[:'order_type']
259
- end
260
-
261
- if attributes.key?(:'limit_price')
262
- self.limit_price = attributes[:'limit_price']
263
- end
264
-
265
- if attributes.key?(:'stop_price')
266
- self.stop_price = attributes[:'stop_price']
267
- end
268
-
269
- if attributes.key?(:'is_all_or_none')
270
- self.is_all_or_none = attributes[:'is_all_or_none']
271
- end
272
-
273
- if attributes.key?(:'is_anonymous')
274
- self.is_anonymous = attributes[:'is_anonymous']
275
- end
276
-
277
- if attributes.key?(:'iceberg_quantity')
278
- self.iceberg_quantity = attributes[:'iceberg_quantity']
279
- end
280
-
281
- if attributes.key?(:'min_quantity')
282
- self.min_quantity = attributes[:'min_quantity']
283
- end
284
-
285
- if attributes.key?(:'avg_exec_price')
286
- self.avg_exec_price = attributes[:'avg_exec_price']
287
- end
288
-
289
- if attributes.key?(:'last_exec_price')
290
- self.last_exec_price = attributes[:'last_exec_price']
291
- end
292
-
293
- if attributes.key?(:'source')
294
- self.source = attributes[:'source']
295
- end
296
-
297
- if attributes.key?(:'time_in_force')
298
- self.time_in_force = attributes[:'time_in_force']
299
- end
300
-
301
- if attributes.key?(:'gtd_date')
302
- self.gtd_date = attributes[:'gtd_date']
303
- end
304
-
305
- if attributes.key?(:'state')
306
- self.state = attributes[:'state']
307
- end
308
-
309
- if attributes.key?(:'rejection_reason')
310
- self.rejection_reason = attributes[:'rejection_reason']
311
- end
312
-
313
- if attributes.key?(:'chain_id')
314
- self.chain_id = attributes[:'chain_id']
315
- end
316
-
317
- if attributes.key?(:'creation_time')
318
- self.creation_time = attributes[:'creation_time']
319
- end
320
-
321
- if attributes.key?(:'update_time')
322
- self.update_time = attributes[:'update_time']
323
- end
324
-
325
- if attributes.key?(:'notes')
326
- self.notes = attributes[:'notes']
327
- end
328
-
329
- if attributes.key?(:'primary_route')
330
- self.primary_route = attributes[:'primary_route']
331
- end
332
-
333
- if attributes.key?(:'secondary_route')
334
- self.secondary_route = attributes[:'secondary_route']
335
- end
336
-
337
- if attributes.key?(:'order_route')
338
- self.order_route = attributes[:'order_route']
339
- end
340
-
341
- if attributes.key?(:'venue_holding_order')
342
- self.venue_holding_order = attributes[:'venue_holding_order']
343
- end
344
-
345
- if attributes.key?(:'comission_charged')
346
- self.comission_charged = attributes[:'comission_charged']
347
- end
348
-
349
- if attributes.key?(:'exchange_order_id')
350
- self.exchange_order_id = attributes[:'exchange_order_id']
351
- end
352
-
353
- if attributes.key?(:'is_significant_share_holder')
354
- self.is_significant_share_holder = attributes[:'is_significant_share_holder']
355
- end
356
-
357
- if attributes.key?(:'is_insider')
358
- self.is_insider = attributes[:'is_insider']
359
- end
360
-
361
- if attributes.key?(:'is_limit_offset_in_dollar')
362
- self.is_limit_offset_in_dollar = attributes[:'is_limit_offset_in_dollar']
363
- end
364
-
365
- if attributes.key?(:'user_id')
366
- self.user_id = attributes[:'user_id']
367
- end
368
-
369
- if attributes.key?(:'placement_commission')
370
- self.placement_commission = attributes[:'placement_commission']
371
- end
372
-
373
- if attributes.key?(:'legs')
374
- if (value = attributes[:'legs']).is_a?(Array)
375
- self.legs = value
376
- end
377
- end
378
-
379
- if attributes.key?(:'strategy_type')
380
- self.strategy_type = attributes[:'strategy_type']
381
- end
382
-
383
- if attributes.key?(:'trigger_stop_price')
384
- self.trigger_stop_price = attributes[:'trigger_stop_price']
385
- end
386
-
387
- if attributes.key?(:'order_group_id')
388
- self.order_group_id = attributes[:'order_group_id']
389
- end
390
-
391
- if attributes.key?(:'order_class')
392
- self.order_class = attributes[:'order_class']
393
- end
394
-
395
- if attributes.key?(:'is_cross_zero')
396
- self.is_cross_zero = attributes[:'is_cross_zero']
397
- end
398
- end
399
-
400
- # Show invalid properties with the reasons. Usually used together with valid?
401
- # @return Array for valid properties with the reasons
402
- def list_invalid_properties
403
- invalid_properties = Array.new
404
- invalid_properties
405
- end
406
-
407
- # Check to see if the all the properties in the model are valid
408
- # @return true if the model is valid
409
- def valid?
410
- true
411
- end
412
-
413
- # Checks equality by comparing each attribute.
414
- # @param [Object] Object to be compared
415
- def ==(o)
416
- return true if self.equal?(o)
417
- self.class == o.class &&
418
- id == o.id &&
419
- symbol == o.symbol &&
420
- symbol_id == o.symbol_id &&
421
- total_quantity == o.total_quantity &&
422
- open_quantity == o.open_quantity &&
423
- filled_quantity == o.filled_quantity &&
424
- canceled_quantity == o.canceled_quantity &&
425
- side == o.side &&
426
- order_type == o.order_type &&
427
- limit_price == o.limit_price &&
428
- stop_price == o.stop_price &&
429
- is_all_or_none == o.is_all_or_none &&
430
- is_anonymous == o.is_anonymous &&
431
- iceberg_quantity == o.iceberg_quantity &&
432
- min_quantity == o.min_quantity &&
433
- avg_exec_price == o.avg_exec_price &&
434
- last_exec_price == o.last_exec_price &&
435
- source == o.source &&
436
- time_in_force == o.time_in_force &&
437
- gtd_date == o.gtd_date &&
438
- state == o.state &&
439
- rejection_reason == o.rejection_reason &&
440
- chain_id == o.chain_id &&
441
- creation_time == o.creation_time &&
442
- update_time == o.update_time &&
443
- notes == o.notes &&
444
- primary_route == o.primary_route &&
445
- secondary_route == o.secondary_route &&
446
- order_route == o.order_route &&
447
- venue_holding_order == o.venue_holding_order &&
448
- comission_charged == o.comission_charged &&
449
- exchange_order_id == o.exchange_order_id &&
450
- is_significant_share_holder == o.is_significant_share_holder &&
451
- is_insider == o.is_insider &&
452
- is_limit_offset_in_dollar == o.is_limit_offset_in_dollar &&
453
- user_id == o.user_id &&
454
- placement_commission == o.placement_commission &&
455
- legs == o.legs &&
456
- strategy_type == o.strategy_type &&
457
- trigger_stop_price == o.trigger_stop_price &&
458
- order_group_id == o.order_group_id &&
459
- order_class == o.order_class &&
460
- is_cross_zero == o.is_cross_zero
461
- end
462
-
463
- # @see the `==` method
464
- # @param [Object] Object to be compared
465
- def eql?(o)
466
- self == o
467
- end
468
-
469
- # Calculates hash code according to all attributes.
470
- # @return [Integer] Hash code
471
- def hash
472
- [id, symbol, symbol_id, total_quantity, open_quantity, filled_quantity, canceled_quantity, side, order_type, limit_price, stop_price, is_all_or_none, is_anonymous, iceberg_quantity, min_quantity, avg_exec_price, last_exec_price, source, time_in_force, gtd_date, state, rejection_reason, chain_id, creation_time, update_time, notes, primary_route, secondary_route, order_route, venue_holding_order, comission_charged, exchange_order_id, is_significant_share_holder, is_insider, is_limit_offset_in_dollar, user_id, placement_commission, legs, strategy_type, trigger_stop_price, order_group_id, order_class, is_cross_zero].hash
473
- end
474
-
475
- # Builds the object from hash
476
- # @param [Hash] attributes Model attributes in the form of hash
477
- # @return [Object] Returns the model itself
478
- def self.build_from_hash(attributes)
479
- new.build_from_hash(attributes)
480
- end
481
-
482
- # Builds the object from hash
483
- # @param [Hash] attributes Model attributes in the form of hash
484
- # @return [Object] Returns the model itself
485
- def build_from_hash(attributes)
486
- return nil unless attributes.is_a?(Hash)
487
- attributes = attributes.transform_keys(&:to_sym)
488
- self.class.openapi_types.each_pair do |key, type|
489
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
490
- self.send("#{key}=", nil)
491
- elsif type =~ /\AArray<(.*)>/i
492
- # check to ensure the input is an array given that the attribute
493
- # is documented as an array but the input is not
494
- if attributes[self.class.attribute_map[key]].is_a?(Array)
495
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
496
- end
497
- elsif !attributes[self.class.attribute_map[key]].nil?
498
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
499
- end
500
- end
501
-
502
- self
503
- end
504
-
505
- # Deserializes the data based on type
506
- # @param string type Data type
507
- # @param string value Value to be deserialized
508
- # @return [Object] Deserialized data
509
- def _deserialize(type, value)
510
- case type.to_sym
511
- when :Time
512
- Time.parse(value)
513
- when :Date
514
- Date.parse(value)
515
- when :String
516
- value.to_s
517
- when :Integer
518
- value.to_i
519
- when :Float
520
- value.to_f
521
- when :Boolean
522
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
523
- true
524
- else
525
- false
526
- end
527
- when :Object
528
- # generic object (usually a Hash), return directly
529
- value
530
- when /\AArray<(?<inner_type>.+)>\z/
531
- inner_type = Regexp.last_match[:inner_type]
532
- value.map { |v| _deserialize(inner_type, v) }
533
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
534
- k_type = Regexp.last_match[:k_type]
535
- v_type = Regexp.last_match[:v_type]
536
- {}.tap do |hash|
537
- value.each do |k, v|
538
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
539
- end
540
- end
541
- else # model
542
- # models (e.g. Pet) or oneOf
543
- klass = SnapTrade.const_get(type)
544
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
545
- end
546
- end
547
-
548
- # Returns the string representation of the object
549
- # @return [String] String presentation of the object
550
- def to_s
551
- to_hash.to_s
552
- end
553
-
554
- # to_body is an alias to to_hash (backward compatibility)
555
- # @return [Hash] Returns the object in the form of hash
556
- def to_body
557
- to_hash
558
- end
559
-
560
- # Returns the object in the form of hash
561
- # @return [Hash] Returns the object in the form of hash
562
- def to_hash
563
- hash = {}
564
- self.class.attribute_map.each_pair do |attr, param|
565
- value = self.send(attr)
566
- if value.nil?
567
- is_nullable = self.class.openapi_nullable.include?(attr)
568
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
569
- end
570
-
571
- hash[param] = _to_hash(value)
572
- end
573
- hash
574
- end
575
-
576
- # Outputs non-array value in the form of hash
577
- # For object, use to_hash. Otherwise, just return the value
578
- # @param [Object] value Any valid value
579
- # @return [Hash] Returns the value in the form of hash
580
- def _to_hash(value)
581
- if value.is_a?(Array)
582
- value.compact.map { |v| _to_hash(v) }
583
- elsif value.is_a?(Hash)
584
- {}.tap do |hash|
585
- value.each { |k, v| hash[k] = _to_hash(v) }
586
- end
587
- elsif value.respond_to? :to_hash
588
- value.to_hash
589
- else
590
- value
591
- end
592
- end
593
-
594
- end
595
-
596
- end