snaptrade 2.0.184 → 2.0.186

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +126 -2
  4. data/lib/snaptrade/api/experimental_endpoints_api.rb +141 -0
  5. data/lib/snaptrade/api/trading_api.rb +142 -0
  6. data/lib/snaptrade/models/account_order_record_option_symbol.rb +1 -1
  7. data/lib/snaptrade/models/account_order_record_quote_universal_symbol.rb +1 -1
  8. data/lib/snaptrade/models/account_order_record_universal_symbol.rb +1 -1
  9. data/lib/snaptrade/models/account_position.rb +288 -0
  10. data/lib/snaptrade/models/account_universal_activity_option_symbol.rb +1 -1
  11. data/lib/snaptrade/models/account_universal_activity_symbol.rb +1 -1
  12. data/lib/snaptrade/models/all_account_positions_response.rb +262 -0
  13. data/lib/snaptrade/models/complex_order_leg.rb +319 -0
  14. data/lib/snaptrade/models/complex_order_response.rb +229 -0
  15. data/lib/snaptrade/models/complex_order_response_type.rb +38 -0
  16. data/lib/snaptrade/models/crypto_instrument.rb +311 -0
  17. data/lib/snaptrade/models/crypto_instrument_kind.rb +36 -0
  18. data/lib/snaptrade/models/etf_instrument.rb +311 -0
  19. data/lib/snaptrade/models/etf_instrument_kind.rb +36 -0
  20. data/lib/snaptrade/models/future_instrument.rb +326 -0
  21. data/lib/snaptrade/models/future_instrument_kind.rb +36 -0
  22. data/lib/snaptrade/models/instrument.rb +61 -0
  23. data/lib/snaptrade/models/kind.rb +36 -0
  24. data/lib/snaptrade/models/manual_trade_form_complex.rb +251 -0
  25. data/lib/snaptrade/models/manual_trade_form_complex_type.rb +38 -0
  26. data/lib/snaptrade/models/option_instrument.rb +322 -0
  27. data/lib/snaptrade/models/option_instrument_kind.rb +36 -0
  28. data/lib/snaptrade/models/options_symbol.rb +1 -1
  29. data/lib/snaptrade/models/options_symbol_option_type.rb +37 -0
  30. data/lib/snaptrade/models/order_role.rb +38 -0
  31. data/lib/snaptrade/models/other_instrument.rb +311 -0
  32. data/lib/snaptrade/models/other_instrument_kind.rb +36 -0
  33. data/lib/snaptrade/models/stock_instrument.rb +311 -0
  34. data/lib/snaptrade/models/{symbol_figi_instrument.rb → stock_instrument_figi_instrument.rb} +3 -3
  35. data/lib/snaptrade/models/symbol.rb +1 -1
  36. data/lib/snaptrade/models/underlying_option_instrument.rb +57 -0
  37. data/lib/snaptrade/models/underlying_symbol.rb +1 -1
  38. data/lib/snaptrade/models/universal_symbol.rb +1 -1
  39. data/lib/snaptrade/version.rb +1 -1
  40. data/lib/snaptrade.rb +24 -1
  41. data/spec/api/experimental_endpoints_api_spec.rb +16 -0
  42. data/spec/api/trading_api_spec.rb +15 -0
  43. data/spec/models/account_position_spec.rb +65 -0
  44. data/spec/models/all_account_positions_response_spec.rb +47 -0
  45. data/spec/models/complex_order_leg_spec.rb +71 -0
  46. data/spec/models/complex_order_response_spec.rb +35 -0
  47. data/spec/models/complex_order_response_type_spec.rb +23 -0
  48. data/spec/models/crypto_instrument_kind_spec.rb +23 -0
  49. data/spec/models/crypto_instrument_spec.rb +71 -0
  50. data/spec/models/etf_instrument_kind_spec.rb +23 -0
  51. data/spec/models/etf_instrument_spec.rb +71 -0
  52. data/spec/models/future_instrument_kind_spec.rb +23 -0
  53. data/spec/models/future_instrument_spec.rb +77 -0
  54. data/spec/models/instrument_spec.rb +38 -0
  55. data/spec/models/kind_spec.rb +23 -0
  56. data/spec/models/manual_trade_form_complex_spec.rb +41 -0
  57. data/spec/models/manual_trade_form_complex_type_spec.rb +23 -0
  58. data/spec/models/option_instrument_kind_spec.rb +23 -0
  59. data/spec/models/option_instrument_spec.rb +71 -0
  60. data/spec/models/options_symbol_option_type_spec.rb +23 -0
  61. data/spec/models/order_role_spec.rb +23 -0
  62. data/spec/models/other_instrument_kind_spec.rb +23 -0
  63. data/spec/models/other_instrument_spec.rb +71 -0
  64. data/spec/models/{symbol_figi_instrument_spec.rb → stock_instrument_figi_instrument_spec.rb} +6 -6
  65. data/spec/models/stock_instrument_spec.rb +71 -0
  66. data/spec/models/underlying_option_instrument_spec.rb +38 -0
  67. metadata +231 -162
@@ -0,0 +1,326 @@
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
+ # Future instrument metadata for a V2 position.
15
+ class FutureInstrument
16
+ attr_accessor :kind
17
+
18
+ # Unique identifier for the future instrument.
19
+ attr_accessor :id
20
+
21
+ # Display symbol for the future contract.
22
+ attr_accessor :symbol
23
+
24
+ # Root symbol for the future contract.
25
+ attr_accessor :root_symbol
26
+
27
+ # Exchange expiration code for the contract.
28
+ attr_accessor :expiration_code
29
+
30
+ # Expiration date of the contract.
31
+ attr_accessor :expiration_date
32
+
33
+ # Multiplier for the future contract.
34
+ attr_accessor :multiplier
35
+
36
+ # ISO-4217 currency code for the contract.
37
+ attr_accessor :currency
38
+
39
+ # Exchange MIC code or exchange code for the contract.
40
+ attr_accessor :exchange
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'kind' => :'kind',
46
+ :'id' => :'id',
47
+ :'symbol' => :'symbol',
48
+ :'root_symbol' => :'root_symbol',
49
+ :'expiration_code' => :'expiration_code',
50
+ :'expiration_date' => :'expiration_date',
51
+ :'multiplier' => :'multiplier',
52
+ :'currency' => :'currency',
53
+ :'exchange' => :'exchange'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'kind' => :'FutureInstrumentKind',
66
+ :'id' => :'String',
67
+ :'symbol' => :'String',
68
+ :'root_symbol' => :'String',
69
+ :'expiration_code' => :'String',
70
+ :'expiration_date' => :'Date',
71
+ :'multiplier' => :'Float',
72
+ :'currency' => :'String',
73
+ :'exchange' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ :'expiration_date',
81
+ :'multiplier',
82
+ :'currency',
83
+ :'exchange'
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::FutureInstrument` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!self.class.attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::FutureInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'kind')
103
+ self.kind = attributes[:'kind']
104
+ end
105
+
106
+ if attributes.key?(:'id')
107
+ self.id = attributes[:'id']
108
+ end
109
+
110
+ if attributes.key?(:'symbol')
111
+ self.symbol = attributes[:'symbol']
112
+ end
113
+
114
+ if attributes.key?(:'root_symbol')
115
+ self.root_symbol = attributes[:'root_symbol']
116
+ end
117
+
118
+ if attributes.key?(:'expiration_code')
119
+ self.expiration_code = attributes[:'expiration_code']
120
+ end
121
+
122
+ if attributes.key?(:'expiration_date')
123
+ self.expiration_date = attributes[:'expiration_date']
124
+ end
125
+
126
+ if attributes.key?(:'multiplier')
127
+ self.multiplier = attributes[:'multiplier']
128
+ end
129
+
130
+ if attributes.key?(:'currency')
131
+ self.currency = attributes[:'currency']
132
+ end
133
+
134
+ if attributes.key?(:'exchange')
135
+ self.exchange = attributes[:'exchange']
136
+ end
137
+ end
138
+
139
+ # Show invalid properties with the reasons. Usually used together with valid?
140
+ # @return Array for valid properties with the reasons
141
+ def list_invalid_properties
142
+ invalid_properties = Array.new
143
+ if @kind.nil?
144
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
145
+ end
146
+
147
+ if @id.nil?
148
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
149
+ end
150
+
151
+ if @symbol.nil?
152
+ invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
153
+ end
154
+
155
+ if @root_symbol.nil?
156
+ invalid_properties.push('invalid value for "root_symbol", root_symbol cannot be nil.')
157
+ end
158
+
159
+ if @expiration_code.nil?
160
+ invalid_properties.push('invalid value for "expiration_code", expiration_code cannot be nil.')
161
+ end
162
+
163
+ invalid_properties
164
+ end
165
+
166
+ # Check to see if the all the properties in the model are valid
167
+ # @return true if the model is valid
168
+ def valid?
169
+ return false if @kind.nil?
170
+ return false if @id.nil?
171
+ return false if @symbol.nil?
172
+ return false if @root_symbol.nil?
173
+ return false if @expiration_code.nil?
174
+ true
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ kind == o.kind &&
183
+ id == o.id &&
184
+ symbol == o.symbol &&
185
+ root_symbol == o.root_symbol &&
186
+ expiration_code == o.expiration_code &&
187
+ expiration_date == o.expiration_date &&
188
+ multiplier == o.multiplier &&
189
+ currency == o.currency &&
190
+ exchange == o.exchange
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Integer] Hash code
201
+ def hash
202
+ [kind, id, symbol, root_symbol, expiration_code, expiration_date, multiplier, currency, exchange].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def self.build_from_hash(attributes)
209
+ new.build_from_hash(attributes)
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ attributes = attributes.transform_keys(&:to_sym)
218
+ self.class.openapi_types.each_pair do |key, type|
219
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
220
+ self.send("#{key}=", nil)
221
+ elsif type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
225
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
226
+ end
227
+ elsif !attributes[self.class.attribute_map[key]].nil?
228
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
229
+ end
230
+ end
231
+
232
+ self
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def _deserialize(type, value)
240
+ case type.to_sym
241
+ when :Time
242
+ Time.parse(value)
243
+ when :Date
244
+ Date.parse(value)
245
+ when :String
246
+ value.to_s
247
+ when :Integer
248
+ value.to_i
249
+ when :Float
250
+ value.to_f
251
+ when :Boolean
252
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
253
+ true
254
+ else
255
+ false
256
+ end
257
+ when :Object
258
+ # generic object (usually a Hash), return directly
259
+ value
260
+ when /\AArray<(?<inner_type>.+)>\z/
261
+ inner_type = Regexp.last_match[:inner_type]
262
+ value.map { |v| _deserialize(inner_type, v) }
263
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
264
+ k_type = Regexp.last_match[:k_type]
265
+ v_type = Regexp.last_match[:v_type]
266
+ {}.tap do |hash|
267
+ value.each do |k, v|
268
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
269
+ end
270
+ end
271
+ else # model
272
+ # models (e.g. Pet) or oneOf
273
+ klass = SnapTrade.const_get(type)
274
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
275
+ end
276
+ end
277
+
278
+ # Returns the string representation of the object
279
+ # @return [String] String presentation of the object
280
+ def to_s
281
+ to_hash.to_s
282
+ end
283
+
284
+ # to_body is an alias to to_hash (backward compatibility)
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_body
287
+ to_hash
288
+ end
289
+
290
+ # Returns the object in the form of hash
291
+ # @return [Hash] Returns the object in the form of hash
292
+ def to_hash
293
+ hash = {}
294
+ self.class.attribute_map.each_pair do |attr, param|
295
+ value = self.send(attr)
296
+ if value.nil?
297
+ is_nullable = self.class.openapi_nullable.include?(attr)
298
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
299
+ end
300
+
301
+ hash[param] = _to_hash(value)
302
+ end
303
+ hash
304
+ end
305
+
306
+ # Outputs non-array value in the form of hash
307
+ # For object, use to_hash. Otherwise, just return the value
308
+ # @param [Object] value Any valid value
309
+ # @return [Hash] Returns the value in the form of hash
310
+ def _to_hash(value)
311
+ if value.is_a?(Array)
312
+ value.compact.map { |v| _to_hash(v) }
313
+ elsif value.is_a?(Hash)
314
+ {}.tap do |hash|
315
+ value.each { |k, v| hash[k] = _to_hash(v) }
316
+ end
317
+ elsif value.respond_to? :to_hash
318
+ value.to_hash
319
+ else
320
+ value
321
+ end
322
+ end
323
+
324
+ end
325
+
326
+ end
@@ -0,0 +1,36 @@
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 FutureInstrumentKind
15
+ FUTURE = "future".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [FUTURE].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if FutureInstrumentKind.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #FutureInstrumentKind"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,61 @@
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
+ # Instrument metadata for a V2 position. Use `kind` to determine which schema is present.
15
+ module Instrument
16
+ class << self
17
+ # List of class defined in oneOf (OpenAPI v3)
18
+ def openapi_one_of
19
+ [
20
+ :'CryptoInstrument',
21
+ :'EtfInstrument',
22
+ :'FutureInstrument',
23
+ :'OptionInstrument',
24
+ :'OtherInstrument',
25
+ :'StockInstrument'
26
+ ]
27
+ end
28
+
29
+ # Discriminator's property name (OpenAPI v3)
30
+ def openapi_discriminator_name
31
+ :'kind'
32
+ end
33
+
34
+ # Discriminator's mapping (OpenAPI v3)
35
+ def openapi_discriminator_mapping
36
+ {
37
+ :'crypto' => :'CryptoInstrument',
38
+ :'etf' => :'EtfInstrument',
39
+ :'future' => :'FutureInstrument',
40
+ :'option' => :'OptionInstrument',
41
+ :'other' => :'OtherInstrument',
42
+ :'stock' => :'StockInstrument'
43
+ }
44
+ end
45
+
46
+ # Builds the object
47
+ # @param [Mixed] Data to be matched against the list of oneOf items
48
+ # @return [Object] Returns the model or the data itself
49
+ def build(data)
50
+ discriminator_value = data[openapi_discriminator_name]
51
+ return nil if discriminator_value.nil?
52
+
53
+ klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
54
+ return nil unless klass
55
+
56
+ SnapTrade.const_get(klass).build_from_hash(data)
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,36 @@
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 Kind
15
+ STOCK = "stock".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [STOCK].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if Kind.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #Kind"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,251 @@
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
+ # Request body for placing a complex conditional order (OCO, OTO, or OTOCO).
15
+ class ManualTradeFormComplex
16
+ # The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
17
+ attr_accessor :type
18
+
19
+ # The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
20
+ attr_accessor :orders
21
+
22
+ # An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
23
+ attr_accessor :client_order_id
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'type' => :'type',
29
+ :'orders' => :'orders',
30
+ :'client_order_id' => :'client_order_id'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'type' => :'ManualTradeFormComplexType',
43
+ :'orders' => :'Array<ComplexOrderLeg>',
44
+ :'client_order_id' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ :'client_order_id'
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ManualTradeFormComplex` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ManualTradeFormComplex`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'type')
71
+ self.type = attributes[:'type']
72
+ end
73
+
74
+ if attributes.key?(:'orders')
75
+ if (value = attributes[:'orders']).is_a?(Array)
76
+ self.orders = value
77
+ end
78
+ end
79
+
80
+ if attributes.key?(:'client_order_id')
81
+ self.client_order_id = attributes[:'client_order_id']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if @type.nil?
90
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
91
+ end
92
+
93
+ if @orders.nil?
94
+ invalid_properties.push('invalid value for "orders", orders cannot be nil.')
95
+ end
96
+
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ return false if @type.nil?
104
+ return false if @orders.nil?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ type == o.type &&
114
+ orders == o.orders &&
115
+ client_order_id == o.client_order_id
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [type, orders, client_order_id].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ new.build_from_hash(attributes)
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ attributes = attributes.transform_keys(&:to_sym)
143
+ self.class.openapi_types.each_pair do |key, type|
144
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
145
+ self.send("#{key}=", nil)
146
+ elsif type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :Time
167
+ Time.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ # models (e.g. Pet) or oneOf
198
+ klass = SnapTrade.const_get(type)
199
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
200
+ end
201
+ end
202
+
203
+ # Returns the string representation of the object
204
+ # @return [String] String presentation of the object
205
+ def to_s
206
+ to_hash.to_s
207
+ end
208
+
209
+ # to_body is an alias to to_hash (backward compatibility)
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_body
212
+ to_hash
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = self.send(attr)
221
+ if value.nil?
222
+ is_nullable = self.class.openapi_nullable.include?(attr)
223
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
224
+ end
225
+
226
+ hash[param] = _to_hash(value)
227
+ end
228
+ hash
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value)
236
+ if value.is_a?(Array)
237
+ value.compact.map { |v| _to_hash(v) }
238
+ elsif value.is_a?(Hash)
239
+ {}.tap do |hash|
240
+ value.each { |k, v| hash[k] = _to_hash(v) }
241
+ end
242
+ elsif value.respond_to? :to_hash
243
+ value.to_hash
244
+ else
245
+ value
246
+ end
247
+ end
248
+
249
+ end
250
+
251
+ end