snaptrade 2.0.31 → 2.0.32

Sign up to get free protection for your applications and to get access to all the features.
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,216 +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 BrokerageAuthorizationType
15
- attr_accessor :type
16
-
17
- # Attribute mapping from ruby-style variable name to JSON key.
18
- def self.attribute_map
19
- {
20
- :'type' => :'type'
21
- }
22
- end
23
-
24
- # Returns all the JSON keys this model knows about
25
- def self.acceptable_attributes
26
- attribute_map.values
27
- end
28
-
29
- # Attribute type mapping.
30
- def self.openapi_types
31
- {
32
- :'type' => :'BrokerageAuthorizationTypeType'
33
- }
34
- end
35
-
36
- # List of attributes with nullable: true
37
- def self.openapi_nullable
38
- Set.new([
39
- ])
40
- end
41
-
42
- # Initializes the object
43
- # @param [Hash] attributes Model attributes in the form of hash
44
- def initialize(attributes = {})
45
- if (!attributes.is_a?(Hash))
46
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageAuthorizationType` initialize method"
47
- end
48
-
49
- # check to see if the attribute exists and convert string to symbol for hash key
50
- attributes = attributes.each_with_object({}) { |(k, v), h|
51
- if (!self.class.attribute_map.key?(k.to_sym))
52
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageAuthorizationType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
- end
54
- h[k.to_sym] = v
55
- }
56
-
57
- if attributes.key?(:'type')
58
- self.type = attributes[:'type']
59
- end
60
- end
61
-
62
- # Show invalid properties with the reasons. Usually used together with valid?
63
- # @return Array for valid properties with the reasons
64
- def list_invalid_properties
65
- invalid_properties = Array.new
66
- invalid_properties
67
- end
68
-
69
- # Check to see if the all the properties in the model are valid
70
- # @return true if the model is valid
71
- def valid?
72
- true
73
- end
74
-
75
- # Checks equality by comparing each attribute.
76
- # @param [Object] Object to be compared
77
- def ==(o)
78
- return true if self.equal?(o)
79
- self.class == o.class &&
80
- type == o.type
81
- end
82
-
83
- # @see the `==` method
84
- # @param [Object] Object to be compared
85
- def eql?(o)
86
- self == o
87
- end
88
-
89
- # Calculates hash code according to all attributes.
90
- # @return [Integer] Hash code
91
- def hash
92
- [type].hash
93
- end
94
-
95
- # Builds the object from hash
96
- # @param [Hash] attributes Model attributes in the form of hash
97
- # @return [Object] Returns the model itself
98
- def self.build_from_hash(attributes)
99
- new.build_from_hash(attributes)
100
- end
101
-
102
- # Builds the object from hash
103
- # @param [Hash] attributes Model attributes in the form of hash
104
- # @return [Object] Returns the model itself
105
- def build_from_hash(attributes)
106
- return nil unless attributes.is_a?(Hash)
107
- attributes = attributes.transform_keys(&:to_sym)
108
- self.class.openapi_types.each_pair do |key, type|
109
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
110
- self.send("#{key}=", nil)
111
- elsif type =~ /\AArray<(.*)>/i
112
- # check to ensure the input is an array given that the attribute
113
- # is documented as an array but the input is not
114
- if attributes[self.class.attribute_map[key]].is_a?(Array)
115
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
116
- end
117
- elsif !attributes[self.class.attribute_map[key]].nil?
118
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
- end
120
- end
121
-
122
- self
123
- end
124
-
125
- # Deserializes the data based on type
126
- # @param string type Data type
127
- # @param string value Value to be deserialized
128
- # @return [Object] Deserialized data
129
- def _deserialize(type, value)
130
- case type.to_sym
131
- when :Time
132
- Time.parse(value)
133
- when :Date
134
- Date.parse(value)
135
- when :String
136
- value.to_s
137
- when :Integer
138
- value.to_i
139
- when :Float
140
- value.to_f
141
- when :Boolean
142
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
- true
144
- else
145
- false
146
- end
147
- when :Object
148
- # generic object (usually a Hash), return directly
149
- value
150
- when /\AArray<(?<inner_type>.+)>\z/
151
- inner_type = Regexp.last_match[:inner_type]
152
- value.map { |v| _deserialize(inner_type, v) }
153
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
- k_type = Regexp.last_match[:k_type]
155
- v_type = Regexp.last_match[:v_type]
156
- {}.tap do |hash|
157
- value.each do |k, v|
158
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
- end
160
- end
161
- else # model
162
- # models (e.g. Pet) or oneOf
163
- klass = SnapTrade.const_get(type)
164
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
165
- end
166
- end
167
-
168
- # Returns the string representation of the object
169
- # @return [String] String presentation of the object
170
- def to_s
171
- to_hash.to_s
172
- end
173
-
174
- # to_body is an alias to to_hash (backward compatibility)
175
- # @return [Hash] Returns the object in the form of hash
176
- def to_body
177
- to_hash
178
- end
179
-
180
- # Returns the object in the form of hash
181
- # @return [Hash] Returns the object in the form of hash
182
- def to_hash
183
- hash = {}
184
- self.class.attribute_map.each_pair do |attr, param|
185
- value = self.send(attr)
186
- if value.nil?
187
- is_nullable = self.class.openapi_nullable.include?(attr)
188
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
- end
190
-
191
- hash[param] = _to_hash(value)
192
- end
193
- hash
194
- end
195
-
196
- # Outputs non-array value in the form of hash
197
- # For object, use to_hash. Otherwise, just return the value
198
- # @param [Object] value Any valid value
199
- # @return [Hash] Returns the value in the form of hash
200
- def _to_hash(value)
201
- if value.is_a?(Array)
202
- value.compact.map { |v| _to_hash(v) }
203
- elsif value.is_a?(Hash)
204
- {}.tap do |hash|
205
- value.each { |k, v| hash[k] = _to_hash(v) }
206
- end
207
- elsif value.respond_to? :to_hash
208
- value.to_hash
209
- else
210
- value
211
- end
212
- end
213
-
214
- end
215
-
216
- end
@@ -1,37 +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 BrokerageAuthorizationTypeType
15
- READ = "read".freeze
16
- TRADE = "trade".freeze
17
-
18
- def self.all_vars
19
- @all_vars ||= [READ, TRADE].freeze
20
- end
21
-
22
- # Builds the enum from string
23
- # @param [String] The enum value in the form of the string
24
- # @return [String] The enum value
25
- def self.build_from_hash(value)
26
- new.build_from_hash(value)
27
- end
28
-
29
- # Builds the enum from string
30
- # @param [String] The enum value in the form of the string
31
- # @return [String] The enum value
32
- def build_from_hash(value)
33
- return value if BrokerageAuthorizationTypeType.all_vars.include?(value)
34
- raise "Invalid ENUM value #{value} for class #BrokerageAuthorizationTypeType"
35
- end
36
- end
37
- end
@@ -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
- class BrokerageSymbolOptionSymbol
15
- attr_accessor :id
16
-
17
- attr_accessor :ticker
18
-
19
- attr_accessor :option_type
20
-
21
- attr_accessor :strike_price
22
-
23
- attr_accessor :expiration_date
24
-
25
- attr_accessor :is_mini_option
26
-
27
- attr_accessor :underlying_symbol
28
-
29
- attr_accessor :local_id
30
-
31
- attr_accessor :exchange_id
32
-
33
- # Attribute mapping from ruby-style variable name to JSON key.
34
- def self.attribute_map
35
- {
36
- :'id' => :'id',
37
- :'ticker' => :'ticker',
38
- :'option_type' => :'option_type',
39
- :'strike_price' => :'strike_price',
40
- :'expiration_date' => :'expiration_date',
41
- :'is_mini_option' => :'is_mini_option',
42
- :'underlying_symbol' => :'underlying_symbol',
43
- :'local_id' => :'local_id',
44
- :'exchange_id' => :'exchange_id'
45
- }
46
- end
47
-
48
- # Returns all the JSON keys this model knows about
49
- def self.acceptable_attributes
50
- attribute_map.values
51
- end
52
-
53
- # Attribute type mapping.
54
- def self.openapi_types
55
- {
56
- :'id' => :'String',
57
- :'ticker' => :'String',
58
- :'option_type' => :'OptionType',
59
- :'strike_price' => :'Float',
60
- :'expiration_date' => :'String',
61
- :'is_mini_option' => :'Boolean',
62
- :'underlying_symbol' => :'UnderlyingSymbol',
63
- :'local_id' => :'String',
64
- :'exchange_id' => :'String'
65
- }
66
- end
67
-
68
- # List of attributes with nullable: true
69
- def self.openapi_nullable
70
- Set.new([
71
- ])
72
- end
73
-
74
- # List of class defined in allOf (OpenAPI v3)
75
- def self.openapi_all_of
76
- [
77
- :'OptionsSymbol'
78
- ]
79
- end
80
-
81
- # Initializes the object
82
- # @param [Hash] attributes Model attributes in the form of hash
83
- def initialize(attributes = {})
84
- if (!attributes.is_a?(Hash))
85
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageSymbolOptionSymbol` initialize method"
86
- end
87
-
88
- # check to see if the attribute exists and convert string to symbol for hash key
89
- attributes = attributes.each_with_object({}) { |(k, v), h|
90
- if (!self.class.attribute_map.key?(k.to_sym))
91
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageSymbolOptionSymbol`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
- end
93
- h[k.to_sym] = v
94
- }
95
-
96
- if attributes.key?(:'id')
97
- self.id = attributes[:'id']
98
- end
99
-
100
- if attributes.key?(:'ticker')
101
- self.ticker = attributes[:'ticker']
102
- end
103
-
104
- if attributes.key?(:'option_type')
105
- self.option_type = attributes[:'option_type']
106
- end
107
-
108
- if attributes.key?(:'strike_price')
109
- self.strike_price = attributes[:'strike_price']
110
- end
111
-
112
- if attributes.key?(:'expiration_date')
113
- self.expiration_date = attributes[:'expiration_date']
114
- end
115
-
116
- if attributes.key?(:'is_mini_option')
117
- self.is_mini_option = attributes[:'is_mini_option']
118
- end
119
-
120
- if attributes.key?(:'underlying_symbol')
121
- self.underlying_symbol = attributes[:'underlying_symbol']
122
- end
123
-
124
- if attributes.key?(:'local_id')
125
- self.local_id = attributes[:'local_id']
126
- end
127
-
128
- if attributes.key?(:'exchange_id')
129
- self.exchange_id = attributes[:'exchange_id']
130
- end
131
- end
132
-
133
- # Show invalid properties with the reasons. Usually used together with valid?
134
- # @return Array for valid properties with the reasons
135
- def list_invalid_properties
136
- invalid_properties = Array.new
137
- if @id.nil?
138
- invalid_properties.push('invalid value for "id", id cannot be nil.')
139
- end
140
-
141
- if @ticker.nil?
142
- invalid_properties.push('invalid value for "ticker", ticker cannot be nil.')
143
- end
144
-
145
- if @option_type.nil?
146
- invalid_properties.push('invalid value for "option_type", option_type cannot be nil.')
147
- end
148
-
149
- if @strike_price.nil?
150
- invalid_properties.push('invalid value for "strike_price", strike_price cannot be nil.')
151
- end
152
-
153
- if @expiration_date.nil?
154
- invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
155
- end
156
-
157
- if @underlying_symbol.nil?
158
- invalid_properties.push('invalid value for "underlying_symbol", underlying_symbol cannot be nil.')
159
- end
160
-
161
- invalid_properties
162
- end
163
-
164
- # Check to see if the all the properties in the model are valid
165
- # @return true if the model is valid
166
- def valid?
167
- return false if @id.nil?
168
- return false if @ticker.nil?
169
- return false if @option_type.nil?
170
- return false if @strike_price.nil?
171
- return false if @expiration_date.nil?
172
- return false if @underlying_symbol.nil?
173
- true
174
- end
175
-
176
- # Checks equality by comparing each attribute.
177
- # @param [Object] Object to be compared
178
- def ==(o)
179
- return true if self.equal?(o)
180
- self.class == o.class &&
181
- id == o.id &&
182
- ticker == o.ticker &&
183
- option_type == o.option_type &&
184
- strike_price == o.strike_price &&
185
- expiration_date == o.expiration_date &&
186
- is_mini_option == o.is_mini_option &&
187
- underlying_symbol == o.underlying_symbol &&
188
- local_id == o.local_id &&
189
- exchange_id == o.exchange_id
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
- [id, ticker, option_type, strike_price, expiration_date, is_mini_option, underlying_symbol, local_id, exchange_id].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