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