snaptrade 2.0.68 → 2.0.70

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f0cc945f4abf3788ed7455ac4e25ecb41eb9409f0175c19036de164d9ab9007
4
- data.tar.gz: 560688fa12785e3e8fd73669b24a8b351148e89f99875dc7a4992795212ebc4b
3
+ metadata.gz: da123b4dad2c9f58ab7798b61dbb8ef30a91d460b07812d6b543379566060604
4
+ data.tar.gz: 6d6cc15423db03518ce7f72bcc41c2b7c9b83480031dcaf00e93ea61088868a4
5
5
  SHA512:
6
- metadata.gz: d77c0267c67a1e6f69a3f40a2d32999a12f9b2d22ae470384ef82fa98ac3cc6929caa87ea2ac7dfd3fb04481a4eb6f8e4f27ed634a1b1e160287631580a01308
7
- data.tar.gz: 0776cf6b250c874c222c01f815f83129314302294224621cac6cdde934eaae2ba096c7471cb3d911fc204526a935279fd8fc1d4b21d7853473fa52dcaf27c4dc
6
+ metadata.gz: 7b86acfca1bba55bb392ac96f1a0af69832463a8a58c4d91e667e4249e20d408d901e4011884c93742f2922e0673a84319810d6f2690f3cb447b4aa10266ee8e
7
+ data.tar.gz: 11a7c70a57fabbbe2ebce450c78e1bf0e24c7a5742444ae539deee0e5f6f0ed80e446dbe3918ba04a89288b163deb6badc71dde655c01da6e04732bfaabd732b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snaptrade (2.0.68)
4
+ snaptrade (2.0.70)
5
5
  faraday (>= 1.0.1, < 3.0)
6
6
  faraday-multipart (~> 1.0, >= 1.0.4)
7
7
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Connect brokerage accounts to your app for live positions and trading
8
8
 
9
- [![npm](https://img.shields.io/badge/gem-v2.0.68-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.68)
9
+ [![npm](https://img.shields.io/badge/gem-v2.0.70-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.70)
10
10
  [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/)
11
11
 
12
12
  </div>
@@ -73,7 +73,7 @@ Connect brokerage accounts to your app for live positions and trading
73
73
  Add to Gemfile:
74
74
 
75
75
  ```ruby
76
- gem 'snaptrade', '~> 2.0.68'
76
+ gem 'snaptrade', '~> 2.0.70'
77
77
  ```
78
78
 
79
79
  ## Getting Started<a id="getting-started"></a>
@@ -1663,6 +1663,14 @@ result = snaptrade.trading.place_force_order(
1663
1663
  stop: 31.33,
1664
1664
  units: 10.5,
1665
1665
  notional_value: None,
1666
+ order_class: "BRACKET",
1667
+ stop_loss: {
1668
+ "stop_price" => "48.55",
1669
+ "limit_price" => "48.50",
1670
+ },
1671
+ take_profit: {
1672
+ "limit_price" => "49.95",
1673
+ },
1666
1674
  )
1667
1675
  p result
1668
1676
  ```
@@ -1718,6 +1726,15 @@ provided. If placing an Option order, this field represents the number of
1718
1726
  contracts to buy or sell. (e.g., 1 contract = 100 shares).
1719
1727
 
1720
1728
  ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb)<a id="notional_value-manualtradeformnotionalvaluelibsnaptrademodelsmanual_trade_form_notional_valuerb"></a>
1729
+ ##### order_class: [`OrderClass`](./lib/snaptrade/models/order_class.rb)<a id="order_class-orderclasslibsnaptrademodelsorder_classrb"></a>
1730
+ The class of order intended to be placed. Defaults to SIMPLE for regular, one
1731
+ legged trades. Set to BRACKET if looking to place a bracket
1732
+ (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop
1733
+ loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and
1734
+ Tradestation, contact us for more details
1735
+
1736
+ ##### stop_loss: [`ManualTradeFormWithOptionsStopLoss`](./lib/snaptrade/models/manual_trade_form_with_options_stop_loss.rb)<a id="stop_loss-manualtradeformwithoptionsstoplosslibsnaptrademodelsmanual_trade_form_with_options_stop_lossrb"></a>
1737
+ ##### take_profit: [`ManualTradeFormWithOptionsTakeProfit`](./lib/snaptrade/models/manual_trade_form_with_options_take_profit.rb)<a id="take_profit-manualtradeformwithoptionstakeprofitlibsnaptrademodelsmanual_trade_form_with_options_take_profitrb"></a>
1721
1738
  #### 🔄 Return<a id="🔄-return"></a>
1722
1739
 
1723
1740
  [AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb)
@@ -428,9 +428,12 @@ module SnapTrade
428
428
  # @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
429
429
  # @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
430
430
  # @param notional_value [ManualTradeFormNotionalValue]
431
+ # @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
432
+ # @param stop_loss [ManualTradeFormWithOptionsStopLoss]
433
+ # @param take_profit [ManualTradeFormWithOptionsTakeProfit]
431
434
  # @param body [ManualTradeFormWithOptions]
432
435
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
433
- def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
436
+ def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
434
437
  _body = {}
435
438
  _body[:account_id] = account_id if account_id != SENTINEL
436
439
  _body[:action] = action if action != SENTINEL
@@ -442,6 +445,9 @@ module SnapTrade
442
445
  _body[:stop] = stop if stop != SENTINEL
443
446
  _body[:units] = units if units != SENTINEL
444
447
  _body[:notional_value] = notional_value if notional_value != SENTINEL
448
+ _body[:order_class] = order_class if order_class != SENTINEL
449
+ _body[:stop_loss] = stop_loss if stop_loss != SENTINEL
450
+ _body[:take_profit] = take_profit if take_profit != SENTINEL
445
451
  manual_trade_form_with_options = _body
446
452
  data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
447
453
  data
@@ -467,9 +473,12 @@ module SnapTrade
467
473
  # @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
468
474
  # @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
469
475
  # @param notional_value [ManualTradeFormNotionalValue]
476
+ # @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
477
+ # @param stop_loss [ManualTradeFormWithOptionsStopLoss]
478
+ # @param take_profit [ManualTradeFormWithOptionsTakeProfit]
470
479
  # @param body [ManualTradeFormWithOptions]
471
480
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
472
- def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
481
+ def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
473
482
  _body = {}
474
483
  _body[:account_id] = account_id if account_id != SENTINEL
475
484
  _body[:action] = action if action != SENTINEL
@@ -481,6 +490,9 @@ module SnapTrade
481
490
  _body[:stop] = stop if stop != SENTINEL
482
491
  _body[:units] = units if units != SENTINEL
483
492
  _body[:notional_value] = notional_value if notional_value != SENTINEL
493
+ _body[:order_class] = order_class if order_class != SENTINEL
494
+ _body[:stop_loss] = stop_loss if stop_loss != SENTINEL
495
+ _body[:take_profit] = take_profit if take_profit != SENTINEL
484
496
  manual_trade_form_with_options = _body
485
497
  place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
486
498
  end
@@ -44,6 +44,9 @@ module SnapTrade
44
44
  # This field is deprecated.
45
45
  attr_accessor :cash_restrictions
46
46
 
47
+ # The account type as provided by the brokerage
48
+ attr_accessor :raw_type
49
+
47
50
  # Attribute mapping from ruby-style variable name to JSON key.
48
51
  def self.attribute_map
49
52
  {
@@ -57,7 +60,8 @@ module SnapTrade
57
60
  :'balance' => :'balance',
58
61
  :'meta' => :'meta',
59
62
  :'portfolio_group' => :'portfolio_group',
60
- :'cash_restrictions' => :'cash_restrictions'
63
+ :'cash_restrictions' => :'cash_restrictions',
64
+ :'raw_type' => :'raw_type'
61
65
  }
62
66
  end
63
67
 
@@ -79,7 +83,8 @@ module SnapTrade
79
83
  :'balance' => :'AccountBalance',
80
84
  :'meta' => :'Hash<String, Object>',
81
85
  :'portfolio_group' => :'String',
82
- :'cash_restrictions' => :'Array<String>'
86
+ :'cash_restrictions' => :'Array<String>',
87
+ :'raw_type' => :'String'
83
88
  }
84
89
  end
85
90
 
@@ -87,6 +92,7 @@ module SnapTrade
87
92
  def self.openapi_nullable
88
93
  Set.new([
89
94
  :'name',
95
+ :'raw_type'
90
96
  ])
91
97
  end
92
98
 
@@ -152,6 +158,10 @@ module SnapTrade
152
158
  self.cash_restrictions = value
153
159
  end
154
160
  end
161
+
162
+ if attributes.key?(:'raw_type')
163
+ self.raw_type = attributes[:'raw_type']
164
+ end
155
165
  end
156
166
 
157
167
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -217,7 +227,8 @@ module SnapTrade
217
227
  balance == o.balance &&
218
228
  meta == o.meta &&
219
229
  portfolio_group == o.portfolio_group &&
220
- cash_restrictions == o.cash_restrictions
230
+ cash_restrictions == o.cash_restrictions &&
231
+ raw_type == o.raw_type
221
232
  end
222
233
 
223
234
  # @see the `==` method
@@ -229,7 +240,7 @@ module SnapTrade
229
240
  # Calculates hash code according to all attributes.
230
241
  # @return [Integer] Hash code
231
242
  def hash
232
- [id, brokerage_authorization, name, number, institution_name, created_date, sync_status, balance, meta, portfolio_group, cash_restrictions].hash
243
+ [id, brokerage_authorization, name, number, institution_name, created_date, sync_status, balance, meta, portfolio_group, cash_restrictions, raw_type].hash
233
244
  end
234
245
 
235
246
  # Builds the object from hash
@@ -42,6 +42,13 @@ module SnapTrade
42
42
 
43
43
  attr_accessor :notional_value
44
44
 
45
+ # The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
46
+ attr_accessor :order_class
47
+
48
+ attr_accessor :stop_loss
49
+
50
+ attr_accessor :take_profit
51
+
45
52
  # Attribute mapping from ruby-style variable name to JSON key.
46
53
  def self.attribute_map
47
54
  {
@@ -54,7 +61,10 @@ module SnapTrade
54
61
  :'price' => :'price',
55
62
  :'stop' => :'stop',
56
63
  :'units' => :'units',
57
- :'notional_value' => :'notional_value'
64
+ :'notional_value' => :'notional_value',
65
+ :'order_class' => :'order_class',
66
+ :'stop_loss' => :'stop_loss',
67
+ :'take_profit' => :'take_profit'
58
68
  }
59
69
  end
60
70
 
@@ -75,7 +85,10 @@ module SnapTrade
75
85
  :'price' => :'Float',
76
86
  :'stop' => :'Float',
77
87
  :'units' => :'Float',
78
- :'notional_value' => :'ManualTradeFormNotionalValue'
88
+ :'notional_value' => :'ManualTradeFormNotionalValue',
89
+ :'order_class' => :'OrderClass',
90
+ :'stop_loss' => :'ManualTradeFormWithOptionsStopLoss',
91
+ :'take_profit' => :'ManualTradeFormWithOptionsTakeProfit'
79
92
  }
80
93
  end
81
94
 
@@ -87,7 +100,10 @@ module SnapTrade
87
100
  :'price',
88
101
  :'stop',
89
102
  :'units',
90
- :'notional_value'
103
+ :'notional_value',
104
+ :'order_class',
105
+ :'stop_loss',
106
+ :'take_profit'
91
107
  ])
92
108
  end
93
109
 
@@ -145,6 +161,18 @@ module SnapTrade
145
161
  if attributes.key?(:'notional_value')
146
162
  self.notional_value = attributes[:'notional_value']
147
163
  end
164
+
165
+ if attributes.key?(:'order_class')
166
+ self.order_class = attributes[:'order_class']
167
+ end
168
+
169
+ if attributes.key?(:'stop_loss')
170
+ self.stop_loss = attributes[:'stop_loss']
171
+ end
172
+
173
+ if attributes.key?(:'take_profit')
174
+ self.take_profit = attributes[:'take_profit']
175
+ end
148
176
  end
149
177
 
150
178
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -194,7 +222,10 @@ module SnapTrade
194
222
  price == o.price &&
195
223
  stop == o.stop &&
196
224
  units == o.units &&
197
- notional_value == o.notional_value
225
+ notional_value == o.notional_value &&
226
+ order_class == o.order_class &&
227
+ stop_loss == o.stop_loss &&
228
+ take_profit == o.take_profit
198
229
  end
199
230
 
200
231
  # @see the `==` method
@@ -206,7 +237,7 @@ module SnapTrade
206
237
  # Calculates hash code according to all attributes.
207
238
  # @return [Integer] Hash code
208
239
  def hash
209
- [account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value].hash
240
+ [account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value, order_class, stop_loss, take_profit].hash
210
241
  end
211
242
 
212
243
  # Builds the object from hash
@@ -0,0 +1,233 @@
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 ManualTradeFormWithOptionsStopLoss
15
+ attr_accessor :stop_price
16
+
17
+ attr_accessor :limit_price
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'stop_price' => :'stop_price',
23
+ :'limit_price' => :'limit_price'
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
+ :'stop_price' => :'String',
36
+ :'limit_price' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ :'limit_price'
44
+ ])
45
+ end
46
+
47
+ # List of class defined in allOf (OpenAPI v3)
48
+ def self.openapi_all_of
49
+ [
50
+ :'StopLoss'
51
+ ]
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ManualTradeFormWithOptionsStopLoss` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ManualTradeFormWithOptionsStopLoss`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'stop_price')
70
+ self.stop_price = attributes[:'stop_price']
71
+ end
72
+
73
+ if attributes.key?(:'limit_price')
74
+ self.limit_price = attributes[:'limit_price']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
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
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ stop_price == o.stop_price &&
97
+ limit_price == o.limit_price
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(o)
103
+ self == o
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Integer] Hash code
108
+ def hash
109
+ [stop_price, limit_price].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def self.build_from_hash(attributes)
116
+ new.build_from_hash(attributes)
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ attributes = attributes.transform_keys(&:to_sym)
125
+ self.class.openapi_types.each_pair do |key, type|
126
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
127
+ self.send("#{key}=", nil)
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :Time
149
+ Time.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :Boolean
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ # models (e.g. Pet) or oneOf
180
+ klass = SnapTrade.const_get(type)
181
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ end
232
+
233
+ end