snaptrade 2.0.218 → 3.0.0

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -3
  3. data/README.md +20 -549
  4. data/lib/snaptrade/api/account_information_api.rb +0 -231
  5. data/lib/snaptrade/api/connections_api.rb +0 -201
  6. data/lib/snaptrade/api/experimental_endpoints_api.rb +123 -0
  7. data/lib/snaptrade/api/reference_data_api.rb +0 -316
  8. data/lib/snaptrade/api/trading_api.rb +0 -290
  9. data/lib/snaptrade/models/connection_account.rb +51 -0
  10. data/lib/snaptrade/models/{connections_session_events200_response_inner.rb → connection_account_sync_status.rb} +35 -77
  11. data/lib/snaptrade/models/investment_account.rb +372 -0
  12. data/lib/snaptrade/models/investment_account_market_value.rb +228 -0
  13. data/lib/snaptrade/models/kind.rb +2 -2
  14. data/lib/snaptrade/models/stock_instrument.rb +1 -1
  15. data/lib/snaptrade/models/stock_instrument_kind.rb +36 -0
  16. data/lib/snaptrade/version.rb +1 -1
  17. data/lib/snaptrade.rb +5 -7
  18. data/spec/api/account_information_api_spec.rb +0 -28
  19. data/spec/api/connections_api_spec.rb +0 -28
  20. data/spec/api/experimental_endpoints_api_spec.rb +14 -0
  21. data/spec/api/reference_data_api_spec.rb +0 -45
  22. data/spec/api/trading_api_spec.rb +0 -30
  23. data/spec/getting_started_spec.rb +6 -6
  24. data/spec/models/connection_account_spec.rb +38 -0
  25. data/spec/models/connection_account_sync_status_spec.rb +47 -0
  26. data/spec/models/investment_account_market_value_spec.rb +35 -0
  27. data/spec/models/investment_account_spec.rb +101 -0
  28. data/spec/models/stock_instrument_kind_spec.rb +23 -0
  29. metadata +212 -206
  30. data/lib/snaptrade/api/options_api.rb +0 -137
  31. data/lib/snaptrade/api/transactions_and_reporting_api.rb +0 -302
  32. data/spec/api/options_api_spec.rb +0 -44
  33. data/spec/api/transactions_and_reporting_api_spec.rb +0 -66
  34. data/spec/models/connections_session_events200_response_inner_spec.rb +0 -65
@@ -0,0 +1,51 @@
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
+ # A single account under a connection, from the `kind`-discriminated union used by `Connections_listConnectionAccounts`. Use `kind` to determine which schema is present. Only `investment` is implemented today; `deposit` and `line_of_credit` will be added as additional variants in a future release.
15
+ module ConnectionAccount
16
+ class << self
17
+ # List of class defined in oneOf (OpenAPI v3)
18
+ def openapi_one_of
19
+ [
20
+ :'InvestmentAccount'
21
+ ]
22
+ end
23
+
24
+ # Discriminator's property name (OpenAPI v3)
25
+ def openapi_discriminator_name
26
+ :'kind'
27
+ end
28
+
29
+ # Discriminator's mapping (OpenAPI v3)
30
+ def openapi_discriminator_mapping
31
+ {
32
+ :'investment' => :'InvestmentAccount'
33
+ }
34
+ end
35
+
36
+ # Builds the object
37
+ # @param [Mixed] Data to be matched against the list of oneOf items
38
+ # @return [Object] Returns the model or the data itself
39
+ def build(data)
40
+ discriminator_value = data[openapi_discriminator_name]
41
+ return nil if discriminator_value.nil?
42
+
43
+ klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
44
+ return nil unless klass
45
+
46
+ SnapTrade.const_get(klass).build_from_hash(data)
47
+ end
48
+ end
49
+ end
50
+
51
+ end
@@ -11,33 +11,26 @@ require 'date'
11
11
  require 'time'
12
12
 
13
13
  module SnapTrade
14
- class ConnectionsSessionEvents200ResponseInner
15
- attr_accessor :id
14
+ # Contains status updates for the account sync process between SnapTrade and the brokerage, used only by `Connections_listConnectionAccounts`. Each property is optional -- a brokerage may not report sync status for every data type. `orders`/`positions`/`balances` are the timestamp of the last successful sync of that data type (null if never synced).
15
+ class ConnectionAccountSyncStatus
16
+ attr_accessor :transactions
16
17
 
17
- attr_accessor :session_event_type
18
+ # The last time orders were successfully synced by SnapTrade.
19
+ attr_accessor :orders
18
20
 
19
- attr_accessor :session_id
21
+ # The last time positions were successfully synced by SnapTrade.
22
+ attr_accessor :positions
20
23
 
21
- # SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.
22
- attr_accessor :user_id
23
-
24
- # Time
25
- attr_accessor :created_date
26
-
27
- attr_accessor :brokerage_status_code
28
-
29
- attr_accessor :brokerage_authorization_id
24
+ # The last time balances were successfully synced by SnapTrade.
25
+ attr_accessor :balances
30
26
 
31
27
  # Attribute mapping from ruby-style variable name to JSON key.
32
28
  def self.attribute_map
33
29
  {
34
- :'id' => :'id',
35
- :'session_event_type' => :'session_event_type',
36
- :'session_id' => :'session_id',
37
- :'user_id' => :'user_id',
38
- :'created_date' => :'created_date',
39
- :'brokerage_status_code' => :'brokerage_status_code',
40
- :'brokerage_authorization_id' => :'brokerage_authorization_id'
30
+ :'transactions' => :'transactions',
31
+ :'orders' => :'orders',
32
+ :'positions' => :'positions',
33
+ :'balances' => :'balances'
41
34
  }
42
35
  end
43
36
 
@@ -49,71 +42,51 @@ module SnapTrade
49
42
  # Attribute type mapping.
50
43
  def self.openapi_types
51
44
  {
52
- :'id' => :'String',
53
- :'session_event_type' => :'SessionEventType',
54
- :'session_id' => :'String',
55
- :'user_id' => :'String',
56
- :'created_date' => :'String',
57
- :'brokerage_status_code' => :'Integer',
58
- :'brokerage_authorization_id' => :'String'
45
+ :'transactions' => :'TransactionsStatus',
46
+ :'orders' => :'Time',
47
+ :'positions' => :'Time',
48
+ :'balances' => :'Time'
59
49
  }
60
50
  end
61
51
 
62
52
  # List of attributes with nullable: true
63
53
  def self.openapi_nullable
64
54
  Set.new([
65
- :'brokerage_status_code',
55
+ :'orders',
56
+ :'positions',
57
+ :'balances'
66
58
  ])
67
59
  end
68
60
 
69
- # List of class defined in anyOf (OpenAPI v3)
70
- def self.openapi_any_of
71
- [
72
- :'SessionEvent'
73
- ]
74
- end
75
-
76
61
  # Initializes the object
77
62
  # @param [Hash] attributes Model attributes in the form of hash
78
63
  def initialize(attributes = {})
79
64
  if (!attributes.is_a?(Hash))
80
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ConnectionsSessionEvents200ResponseInner` initialize method"
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ConnectionAccountSyncStatus` initialize method"
81
66
  end
82
67
 
83
68
  # check to see if the attribute exists and convert string to symbol for hash key
84
69
  attributes = attributes.each_with_object({}) { |(k, v), h|
85
70
  if (!self.class.attribute_map.key?(k.to_sym))
86
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ConnectionsSessionEvents200ResponseInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ConnectionAccountSyncStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
72
  end
88
73
  h[k.to_sym] = v
89
74
  }
90
75
 
91
- if attributes.key?(:'id')
92
- self.id = attributes[:'id']
93
- end
94
-
95
- if attributes.key?(:'session_event_type')
96
- self.session_event_type = attributes[:'session_event_type']
97
- end
98
-
99
- if attributes.key?(:'session_id')
100
- self.session_id = attributes[:'session_id']
101
- end
102
-
103
- if attributes.key?(:'user_id')
104
- self.user_id = attributes[:'user_id']
76
+ if attributes.key?(:'transactions')
77
+ self.transactions = attributes[:'transactions']
105
78
  end
106
79
 
107
- if attributes.key?(:'created_date')
108
- self.created_date = attributes[:'created_date']
80
+ if attributes.key?(:'orders')
81
+ self.orders = attributes[:'orders']
109
82
  end
110
83
 
111
- if attributes.key?(:'brokerage_status_code')
112
- self.brokerage_status_code = attributes[:'brokerage_status_code']
84
+ if attributes.key?(:'positions')
85
+ self.positions = attributes[:'positions']
113
86
  end
114
87
 
115
- if attributes.key?(:'brokerage_authorization_id')
116
- self.brokerage_authorization_id = attributes[:'brokerage_authorization_id']
88
+ if attributes.key?(:'balances')
89
+ self.balances = attributes[:'balances']
117
90
  end
118
91
  end
119
92
 
@@ -127,18 +100,6 @@ module SnapTrade
127
100
  # Check to see if the all the properties in the model are valid
128
101
  # @return true if the model is valid
129
102
  def valid?
130
- _any_of_found = false
131
- self.class.openapi_any_of.each do |_class|
132
- _any_of = SnapTrade.const_get(_class).build_from_hash(self.to_hash)
133
- if _any_of.valid?
134
- _any_of_found = true
135
- end
136
- end
137
-
138
- if !_any_of_found
139
- return false
140
- end
141
-
142
103
  true
143
104
  end
144
105
 
@@ -147,13 +108,10 @@ module SnapTrade
147
108
  def ==(o)
148
109
  return true if self.equal?(o)
149
110
  self.class == o.class &&
150
- id == o.id &&
151
- session_event_type == o.session_event_type &&
152
- session_id == o.session_id &&
153
- user_id == o.user_id &&
154
- created_date == o.created_date &&
155
- brokerage_status_code == o.brokerage_status_code &&
156
- brokerage_authorization_id == o.brokerage_authorization_id
111
+ transactions == o.transactions &&
112
+ orders == o.orders &&
113
+ positions == o.positions &&
114
+ balances == o.balances
157
115
  end
158
116
 
159
117
  # @see the `==` method
@@ -165,7 +123,7 @@ module SnapTrade
165
123
  # Calculates hash code according to all attributes.
166
124
  # @return [Integer] Hash code
167
125
  def hash
168
- [id, session_event_type, session_id, user_id, created_date, brokerage_status_code, brokerage_authorization_id].hash
126
+ [transactions, orders, positions, balances].hash
169
127
  end
170
128
 
171
129
  # Builds the object from hash
@@ -0,0 +1,372 @@
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
+ # An investment/brokerage account under a connection. `opening_date`, `funding_date`, and `market_value` are real-time or cached depending on the caller's plan -- see `Connections_listConnectionAccounts`.
15
+ class InvestmentAccount
16
+ # Discriminator for the account kind.
17
+ attr_accessor :kind
18
+
19
+ # Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
20
+ attr_accessor :id
21
+
22
+ # Unique identifier for the connection (brokerage_authorization_id). This is the UUID used to reference the connection in SnapTrade.
23
+ attr_accessor :connection_id
24
+
25
+ # A display name for the account. Either assigned by the user or by the brokerage itself.
26
+ attr_accessor :display_name
27
+
28
+ # The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons.
29
+ attr_accessor :number
30
+
31
+ # A stable and unique account identifier provided by the institution. Will be set to null if not provided. When present, can be used to check if a user has connected the same brokerage account across multiple connections.
32
+ attr_accessor :institution_account_id
33
+
34
+ # Unique identifier for the institution (brokerage) that holds the account.
35
+ attr_accessor :institution_id
36
+
37
+ # Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was opened at the brokerage.
38
+ attr_accessor :opening_date
39
+
40
+ attr_accessor :sync_status
41
+
42
+ # The account type as provided by the brokerage.
43
+ attr_accessor :raw_type
44
+
45
+ # Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was funded.
46
+ attr_accessor :funding_date
47
+
48
+ # Indicates whether the account is a paper (simulated) trading account.
49
+ attr_accessor :is_paper
50
+
51
+ attr_accessor :market_value
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'kind' => :'kind',
57
+ :'id' => :'id',
58
+ :'connection_id' => :'connection_id',
59
+ :'display_name' => :'display_name',
60
+ :'number' => :'number',
61
+ :'institution_account_id' => :'institution_account_id',
62
+ :'institution_id' => :'institution_id',
63
+ :'opening_date' => :'opening_date',
64
+ :'sync_status' => :'sync_status',
65
+ :'raw_type' => :'raw_type',
66
+ :'funding_date' => :'funding_date',
67
+ :'is_paper' => :'is_paper',
68
+ :'market_value' => :'market_value'
69
+ }
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'kind' => :'Kind',
81
+ :'id' => :'String',
82
+ :'connection_id' => :'String',
83
+ :'display_name' => :'String',
84
+ :'number' => :'String',
85
+ :'institution_account_id' => :'String',
86
+ :'institution_id' => :'String',
87
+ :'opening_date' => :'Time',
88
+ :'sync_status' => :'ConnectionAccountSyncStatus',
89
+ :'raw_type' => :'String',
90
+ :'funding_date' => :'Time',
91
+ :'is_paper' => :'Boolean',
92
+ :'market_value' => :'InvestmentAccountMarketValue'
93
+ }
94
+ end
95
+
96
+ # List of attributes with nullable: true
97
+ def self.openapi_nullable
98
+ Set.new([
99
+ :'display_name',
100
+ :'institution_account_id',
101
+ :'opening_date',
102
+ :'raw_type',
103
+ :'funding_date',
104
+ :'market_value'
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::InvestmentAccount` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::InvestmentAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
119
+ end
120
+ h[k.to_sym] = v
121
+ }
122
+
123
+ if attributes.key?(:'kind')
124
+ self.kind = attributes[:'kind']
125
+ end
126
+
127
+ if attributes.key?(:'id')
128
+ self.id = attributes[:'id']
129
+ end
130
+
131
+ if attributes.key?(:'connection_id')
132
+ self.connection_id = attributes[:'connection_id']
133
+ end
134
+
135
+ if attributes.key?(:'display_name')
136
+ self.display_name = attributes[:'display_name']
137
+ end
138
+
139
+ if attributes.key?(:'number')
140
+ self.number = attributes[:'number']
141
+ end
142
+
143
+ if attributes.key?(:'institution_account_id')
144
+ self.institution_account_id = attributes[:'institution_account_id']
145
+ end
146
+
147
+ if attributes.key?(:'institution_id')
148
+ self.institution_id = attributes[:'institution_id']
149
+ end
150
+
151
+ if attributes.key?(:'opening_date')
152
+ self.opening_date = attributes[:'opening_date']
153
+ end
154
+
155
+ if attributes.key?(:'sync_status')
156
+ self.sync_status = attributes[:'sync_status']
157
+ end
158
+
159
+ if attributes.key?(:'raw_type')
160
+ self.raw_type = attributes[:'raw_type']
161
+ end
162
+
163
+ if attributes.key?(:'funding_date')
164
+ self.funding_date = attributes[:'funding_date']
165
+ end
166
+
167
+ if attributes.key?(:'is_paper')
168
+ self.is_paper = attributes[:'is_paper']
169
+ end
170
+
171
+ if attributes.key?(:'market_value')
172
+ self.market_value = attributes[:'market_value']
173
+ end
174
+ end
175
+
176
+ # Show invalid properties with the reasons. Usually used together with valid?
177
+ # @return Array for valid properties with the reasons
178
+ def list_invalid_properties
179
+ invalid_properties = Array.new
180
+ if @kind.nil?
181
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
182
+ end
183
+
184
+ if @id.nil?
185
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
186
+ end
187
+
188
+ if @connection_id.nil?
189
+ invalid_properties.push('invalid value for "connection_id", connection_id cannot be nil.')
190
+ end
191
+
192
+ if @number.nil?
193
+ invalid_properties.push('invalid value for "number", number cannot be nil.')
194
+ end
195
+
196
+ if @sync_status.nil?
197
+ invalid_properties.push('invalid value for "sync_status", sync_status cannot be nil.')
198
+ end
199
+
200
+ if @is_paper.nil?
201
+ invalid_properties.push('invalid value for "is_paper", is_paper cannot be nil.')
202
+ end
203
+
204
+ invalid_properties
205
+ end
206
+
207
+ # Check to see if the all the properties in the model are valid
208
+ # @return true if the model is valid
209
+ def valid?
210
+ return false if @kind.nil?
211
+ return false if @id.nil?
212
+ return false if @connection_id.nil?
213
+ return false if @number.nil?
214
+ return false if @sync_status.nil?
215
+ return false if @is_paper.nil?
216
+ true
217
+ end
218
+
219
+ # Checks equality by comparing each attribute.
220
+ # @param [Object] Object to be compared
221
+ def ==(o)
222
+ return true if self.equal?(o)
223
+ self.class == o.class &&
224
+ kind == o.kind &&
225
+ id == o.id &&
226
+ connection_id == o.connection_id &&
227
+ display_name == o.display_name &&
228
+ number == o.number &&
229
+ institution_account_id == o.institution_account_id &&
230
+ institution_id == o.institution_id &&
231
+ opening_date == o.opening_date &&
232
+ sync_status == o.sync_status &&
233
+ raw_type == o.raw_type &&
234
+ funding_date == o.funding_date &&
235
+ is_paper == o.is_paper &&
236
+ market_value == o.market_value
237
+ end
238
+
239
+ # @see the `==` method
240
+ # @param [Object] Object to be compared
241
+ def eql?(o)
242
+ self == o
243
+ end
244
+
245
+ # Calculates hash code according to all attributes.
246
+ # @return [Integer] Hash code
247
+ def hash
248
+ [kind, id, connection_id, display_name, number, institution_account_id, institution_id, opening_date, sync_status, raw_type, funding_date, is_paper, market_value].hash
249
+ end
250
+
251
+ # Builds the object from hash
252
+ # @param [Hash] attributes Model attributes in the form of hash
253
+ # @return [Object] Returns the model itself
254
+ def self.build_from_hash(attributes)
255
+ new.build_from_hash(attributes)
256
+ end
257
+
258
+ # Builds the object from hash
259
+ # @param [Hash] attributes Model attributes in the form of hash
260
+ # @return [Object] Returns the model itself
261
+ def build_from_hash(attributes)
262
+ return nil unless attributes.is_a?(Hash)
263
+ attributes = attributes.transform_keys(&:to_sym)
264
+ self.class.openapi_types.each_pair do |key, type|
265
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
266
+ self.send("#{key}=", nil)
267
+ elsif type =~ /\AArray<(.*)>/i
268
+ # check to ensure the input is an array given that the attribute
269
+ # is documented as an array but the input is not
270
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
271
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
272
+ end
273
+ elsif !attributes[self.class.attribute_map[key]].nil?
274
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
275
+ end
276
+ end
277
+
278
+ self
279
+ end
280
+
281
+ # Deserializes the data based on type
282
+ # @param string type Data type
283
+ # @param string value Value to be deserialized
284
+ # @return [Object] Deserialized data
285
+ def _deserialize(type, value)
286
+ case type.to_sym
287
+ when :Time
288
+ Time.parse(value)
289
+ when :Date
290
+ Date.parse(value)
291
+ when :String
292
+ value.to_s
293
+ when :Integer
294
+ value.to_i
295
+ when :Float
296
+ value.to_f
297
+ when :Boolean
298
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
299
+ true
300
+ else
301
+ false
302
+ end
303
+ when :Object
304
+ # generic object (usually a Hash), return directly
305
+ value
306
+ when /\AArray<(?<inner_type>.+)>\z/
307
+ inner_type = Regexp.last_match[:inner_type]
308
+ value.map { |v| _deserialize(inner_type, v) }
309
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
310
+ k_type = Regexp.last_match[:k_type]
311
+ v_type = Regexp.last_match[:v_type]
312
+ {}.tap do |hash|
313
+ value.each do |k, v|
314
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
315
+ end
316
+ end
317
+ else # model
318
+ # models (e.g. Pet) or oneOf
319
+ klass = SnapTrade.const_get(type)
320
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
321
+ end
322
+ end
323
+
324
+ # Returns the string representation of the object
325
+ # @return [String] String presentation of the object
326
+ def to_s
327
+ to_hash.to_s
328
+ end
329
+
330
+ # to_body is an alias to to_hash (backward compatibility)
331
+ # @return [Hash] Returns the object in the form of hash
332
+ def to_body
333
+ to_hash
334
+ end
335
+
336
+ # Returns the object in the form of hash
337
+ # @return [Hash] Returns the object in the form of hash
338
+ def to_hash
339
+ hash = {}
340
+ self.class.attribute_map.each_pair do |attr, param|
341
+ value = self.send(attr)
342
+ if value.nil?
343
+ is_nullable = self.class.openapi_nullable.include?(attr)
344
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
345
+ end
346
+
347
+ hash[param] = _to_hash(value)
348
+ end
349
+ hash
350
+ end
351
+
352
+ # Outputs non-array value in the form of hash
353
+ # For object, use to_hash. Otherwise, just return the value
354
+ # @param [Object] value Any valid value
355
+ # @return [Hash] Returns the value in the form of hash
356
+ def _to_hash(value)
357
+ if value.is_a?(Array)
358
+ value.compact.map { |v| _to_hash(v) }
359
+ elsif value.is_a?(Hash)
360
+ {}.tap do |hash|
361
+ value.each { |k, v| hash[k] = _to_hash(v) }
362
+ end
363
+ elsif value.respond_to? :to_hash
364
+ value.to_hash
365
+ else
366
+ value
367
+ end
368
+ end
369
+
370
+ end
371
+
372
+ end