mux_ruby 2.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -3
  3. data/README.md +4 -4
  4. data/docs/Asset.md +1 -1
  5. data/docs/AssetNonStandardInputReasons.md +2 -0
  6. data/docs/AssetsApi.md +73 -0
  7. data/docs/CreateAssetRequest.md +1 -1
  8. data/docs/CreateLiveStreamRequest.md +6 -2
  9. data/docs/CreatePlaybackRestrictionRequest.md +18 -0
  10. data/docs/CreateSimulcastTargetRequest.md +1 -1
  11. data/docs/CreateTrackRequest.md +1 -1
  12. data/docs/DeliveryUsageApi.md +4 -2
  13. data/docs/DimensionsApi.md +4 -4
  14. data/docs/ErrorsApi.md +4 -4
  15. data/docs/ExportsApi.md +1 -1
  16. data/docs/FiltersApi.md +6 -6
  17. data/docs/GetLiveStreamPlaybackIDResponse.md +18 -0
  18. data/docs/InputSettings.md +1 -1
  19. data/docs/LiveStream.md +7 -3
  20. data/docs/LiveStreamEmbeddedSubtitleSettings.md +24 -0
  21. data/docs/LiveStreamsApi.md +217 -0
  22. data/docs/MetricsApi.md +20 -20
  23. data/docs/PlaybackRestriction.md +24 -0
  24. data/docs/PlaybackRestrictionResponse.md +15 -0
  25. data/docs/PlaybackRestrictionsApi.md +367 -0
  26. data/docs/RealTimeApi.md +6 -6
  27. data/docs/ReferrerDomainRestriction.md +20 -0
  28. data/docs/SimulcastTarget.md +1 -1
  29. data/docs/Track.md +1 -1
  30. data/docs/UpdateAssetRequest.md +18 -0
  31. data/docs/UpdateLiveStreamEmbeddedSubtitlesRequest.md +18 -0
  32. data/docs/UpdateLiveStreamRequest.md +22 -0
  33. data/docs/UpdateReferrerDomainRestrictionRequest.md +15 -0
  34. data/docs/VideoViewsApi.md +4 -4
  35. data/examples/data/exercise-errors.rb +0 -2
  36. data/examples/video/exercise-assets.rb +1 -0
  37. data/gen/generator-config.json +1 -1
  38. data/lib/mux_ruby/api/assets_api.rb +71 -0
  39. data/lib/mux_ruby/api/delivery_usage_api.rb +5 -2
  40. data/lib/mux_ruby/api/dimensions_api.rb +4 -4
  41. data/lib/mux_ruby/api/errors_api.rb +4 -4
  42. data/lib/mux_ruby/api/exports_api.rb +2 -2
  43. data/lib/mux_ruby/api/filters_api.rb +8 -8
  44. data/lib/mux_ruby/api/live_streams_api.rb +209 -0
  45. data/lib/mux_ruby/api/metrics_api.rb +20 -20
  46. data/lib/mux_ruby/api/playback_restrictions_api.rb +345 -0
  47. data/lib/mux_ruby/api/real_time_api.rb +6 -6
  48. data/lib/mux_ruby/api/video_views_api.rb +4 -4
  49. data/lib/mux_ruby/models/asset.rb +1 -1
  50. data/lib/mux_ruby/models/asset_non_standard_input_reasons.rb +23 -1
  51. data/lib/mux_ruby/models/create_asset_request.rb +1 -1
  52. data/lib/mux_ruby/models/create_live_stream_request.rb +59 -3
  53. data/lib/mux_ruby/models/create_playback_restriction_request.rb +218 -0
  54. data/lib/mux_ruby/models/create_simulcast_target_request.rb +1 -1
  55. data/lib/mux_ruby/models/create_track_request.rb +1 -1
  56. data/lib/mux_ruby/models/get_live_stream_playback_id_response.rb +218 -0
  57. data/lib/mux_ruby/models/input_settings.rb +1 -1
  58. data/lib/mux_ruby/models/input_settings_overlay_settings.rb +1 -1
  59. data/lib/mux_ruby/models/live_stream.rb +38 -4
  60. data/lib/mux_ruby/models/live_stream_embedded_subtitle_settings.rb +287 -0
  61. data/lib/mux_ruby/models/playback_restriction.rb +248 -0
  62. data/lib/mux_ruby/models/playback_restriction_response.rb +209 -0
  63. data/lib/mux_ruby/models/referrer_domain_restriction.rb +234 -0
  64. data/lib/mux_ruby/models/simulcast_target.rb +1 -1
  65. data/lib/mux_ruby/models/track.rb +1 -13
  66. data/lib/mux_ruby/models/update_asset_request.rb +219 -0
  67. data/lib/mux_ruby/models/update_live_stream_embedded_subtitles_request.rb +221 -0
  68. data/lib/mux_ruby/models/update_live_stream_request.rb +297 -0
  69. data/lib/mux_ruby/models/update_referrer_domain_restriction_request.rb +209 -0
  70. data/lib/mux_ruby/version.rb +1 -1
  71. data/lib/mux_ruby.rb +11 -0
  72. data/spec/api/playback_restrictions_api_spec.rb +97 -0
  73. data/spec/models/create_playback_restriction_request_spec.rb +34 -0
  74. data/spec/models/get_live_stream_playback_id_response_spec.rb +34 -0
  75. data/spec/models/live_stream_embedded_subtitle_settings_spec.rb +56 -0
  76. data/spec/models/playback_restriction_response_spec.rb +28 -0
  77. data/spec/models/playback_restriction_spec.rb +52 -0
  78. data/spec/models/referrer_domain_restriction_spec.rb +40 -0
  79. data/spec/models/update_asset_request_spec.rb +34 -0
  80. data/spec/models/update_live_stream_embedded_subtitles_request_spec.rb +34 -0
  81. data/spec/models/update_live_stream_request_spec.rb +50 -0
  82. data/spec/models/update_referrer_domain_restriction_request_spec.rb +28 -0
  83. metadata +137 -93
@@ -0,0 +1,221 @@
1
+ =begin
2
+ #Mux API
3
+
4
+ #Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: devex@mux.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MuxRuby
17
+ class UpdateLiveStreamEmbeddedSubtitlesRequest
18
+ # Describe the embedded closed caption contents of the incoming live stream.
19
+ attr_accessor :embedded_subtitles
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'embedded_subtitles' => :'embedded_subtitles'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'embedded_subtitles' => :'Array<LiveStreamEmbeddedSubtitleSettings>'
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 `MuxRuby::UpdateLiveStreamEmbeddedSubtitlesRequest` 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 `MuxRuby::UpdateLiveStreamEmbeddedSubtitlesRequest`. 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?(:'embedded_subtitles')
62
+ if (value = attributes[:'embedded_subtitles']).is_a?(Array)
63
+ self.embedded_subtitles = value
64
+ end
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ embedded_subtitles == o.embedded_subtitles
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Integer] Hash code
97
+ def hash
98
+ [embedded_subtitles].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def self.build_from_hash(attributes)
105
+ new.build_from_hash(attributes)
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ self.class.openapi_types.each_pair do |key, type|
114
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
115
+ self.send("#{key}=", nil)
116
+ elsif type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = MuxRuby.const_get(type)
169
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
@@ -0,0 +1,297 @@
1
+ =begin
2
+ #Mux API
3
+
4
+ #Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: devex@mux.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MuxRuby
17
+ class UpdateLiveStreamRequest
18
+ # Arbitrary user-supplied metadata set for the live stream. Max 255 characters. In order to clear this value, the field should be included with an empty-string value.
19
+ attr_accessor :passthrough
20
+
21
+ # Latency is the time from when the streamer transmits a frame of video to when you see it in the player. Set this as an alternative to setting low latency or reduced latency flags. The Low Latency value is a beta feature. Note: Reconnect windows are incompatible with Reduced Latency and Low Latency and will always be set to zero (0) seconds. Read more here: https://mux.com/blog/introducing-low-latency-live-streaming/
22
+ attr_accessor :latency_mode
23
+
24
+ # When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset.
25
+ attr_accessor :reconnect_window
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'passthrough' => :'passthrough',
53
+ :'latency_mode' => :'latency_mode',
54
+ :'reconnect_window' => :'reconnect_window'
55
+ }
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'passthrough' => :'String',
67
+ :'latency_mode' => :'String',
68
+ :'reconnect_window' => :'Float'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::UpdateLiveStreamRequest` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::UpdateLiveStreamRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'passthrough')
94
+ self.passthrough = attributes[:'passthrough']
95
+ end
96
+
97
+ if attributes.key?(:'latency_mode')
98
+ self.latency_mode = attributes[:'latency_mode']
99
+ end
100
+
101
+ if attributes.key?(:'reconnect_window')
102
+ self.reconnect_window = attributes[:'reconnect_window']
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if !@reconnect_window.nil? && @reconnect_window > 300
111
+ invalid_properties.push('invalid value for "reconnect_window", must be smaller than or equal to 300.')
112
+ end
113
+
114
+ if !@reconnect_window.nil? && @reconnect_window < 0.1
115
+ invalid_properties.push('invalid value for "reconnect_window", must be greater than or equal to 0.1.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ latency_mode_validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
125
+ return false unless latency_mode_validator.valid?(@latency_mode)
126
+ return false if !@reconnect_window.nil? && @reconnect_window > 300
127
+ return false if !@reconnect_window.nil? && @reconnect_window < 0.1
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method checking allowed values (enum).
132
+ # @param [Object] latency_mode Object to be assigned
133
+ def latency_mode=(latency_mode)
134
+ validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
135
+ unless validator.valid?(latency_mode)
136
+ fail ArgumentError, "invalid value for \"latency_mode\", must be one of #{validator.allowable_values}."
137
+ end
138
+ @latency_mode = latency_mode
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] reconnect_window Value to be assigned
143
+ def reconnect_window=(reconnect_window)
144
+ if !reconnect_window.nil? && reconnect_window > 300
145
+ fail ArgumentError, 'invalid value for "reconnect_window", must be smaller than or equal to 300.'
146
+ end
147
+
148
+ if !reconnect_window.nil? && reconnect_window < 0.1
149
+ fail ArgumentError, 'invalid value for "reconnect_window", must be greater than or equal to 0.1.'
150
+ end
151
+
152
+ @reconnect_window = reconnect_window
153
+ end
154
+
155
+ # Checks equality by comparing each attribute.
156
+ # @param [Object] Object to be compared
157
+ def ==(o)
158
+ return true if self.equal?(o)
159
+ self.class == o.class &&
160
+ passthrough == o.passthrough &&
161
+ latency_mode == o.latency_mode &&
162
+ reconnect_window == o.reconnect_window
163
+ end
164
+
165
+ # @see the `==` method
166
+ # @param [Object] Object to be compared
167
+ def eql?(o)
168
+ self == o
169
+ end
170
+
171
+ # Calculates hash code according to all attributes.
172
+ # @return [Integer] Hash code
173
+ def hash
174
+ [passthrough, latency_mode, reconnect_window].hash
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ new.build_from_hash(attributes)
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ self.class.openapi_types.each_pair do |key, type|
190
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
191
+ self.send("#{key}=", nil)
192
+ elsif type =~ /\AArray<(.*)>/i
193
+ # check to ensure the input is an array given that the attribute
194
+ # is documented as an array but the input is not
195
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
196
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
197
+ end
198
+ elsif !attributes[self.class.attribute_map[key]].nil?
199
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
200
+ end
201
+ end
202
+
203
+ self
204
+ end
205
+
206
+ # Deserializes the data based on type
207
+ # @param string type Data type
208
+ # @param string value Value to be deserialized
209
+ # @return [Object] Deserialized data
210
+ def _deserialize(type, value)
211
+ case type.to_sym
212
+ when :Time
213
+ Time.parse(value)
214
+ when :Date
215
+ Date.parse(value)
216
+ when :String
217
+ value.to_s
218
+ when :Integer
219
+ value.to_i
220
+ when :Float
221
+ value.to_f
222
+ when :Boolean
223
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
224
+ true
225
+ else
226
+ false
227
+ end
228
+ when :Object
229
+ # generic object (usually a Hash), return directly
230
+ value
231
+ when /\AArray<(?<inner_type>.+)>\z/
232
+ inner_type = Regexp.last_match[:inner_type]
233
+ value.map { |v| _deserialize(inner_type, v) }
234
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
235
+ k_type = Regexp.last_match[:k_type]
236
+ v_type = Regexp.last_match[:v_type]
237
+ {}.tap do |hash|
238
+ value.each do |k, v|
239
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
240
+ end
241
+ end
242
+ else # model
243
+ # models (e.g. Pet) or oneOf
244
+ klass = MuxRuby.const_get(type)
245
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ if value.nil?
268
+ is_nullable = self.class.openapi_nullable.include?(attr)
269
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
270
+ end
271
+
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ # Outputs non-array value in the form of hash
278
+ # For object, use to_hash. Otherwise, just return the value
279
+ # @param [Object] value Any valid value
280
+ # @return [Hash] Returns the value in the form of hash
281
+ def _to_hash(value)
282
+ if value.is_a?(Array)
283
+ value.compact.map { |v| _to_hash(v) }
284
+ elsif value.is_a?(Hash)
285
+ {}.tap do |hash|
286
+ value.each { |k, v| hash[k] = _to_hash(v) }
287
+ end
288
+ elsif value.respond_to? :to_hash
289
+ value.to_hash
290
+ else
291
+ value
292
+ end
293
+ end
294
+
295
+ end
296
+
297
+ end