mux_ruby 3.3.1 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +13 -7
  4. data/docs/Asset.md +1 -1
  5. data/docs/AssetNonStandardInputReasons.md +2 -2
  6. data/docs/AssetResponse.md +1 -1
  7. data/docs/AssetsApi.md +8 -0
  8. data/docs/Broadcast.md +30 -0
  9. data/docs/BroadcastLayout.md +15 -0
  10. data/docs/BroadcastResolution.md +15 -0
  11. data/docs/BroadcastResponse.md +18 -0
  12. data/docs/BroadcastStatus.md +15 -0
  13. data/docs/CreateBroadcastRequest.md +26 -0
  14. data/docs/CreateLiveStreamRequest.md +3 -1
  15. data/docs/CreatePlaybackIDResponse.md +1 -1
  16. data/docs/CreatePlaybackRestrictionRequest.md +1 -1
  17. data/docs/CreateSimulcastTargetRequest.md +1 -1
  18. data/docs/CreateSpaceRequest.md +22 -0
  19. data/docs/CreateTrackResponse.md +1 -1
  20. data/docs/DirectUploadsApi.md +6 -0
  21. data/docs/GetAssetPlaybackIDResponse.md +1 -1
  22. data/docs/GetLiveStreamPlaybackIDResponse.md +1 -1
  23. data/docs/IncidentResponse.md +1 -1
  24. data/docs/InputSettings.md +3 -3
  25. data/docs/ListSpacesResponse.md +18 -0
  26. data/docs/LiveStream.md +3 -1
  27. data/docs/LiveStreamResponse.md +1 -1
  28. data/docs/LiveStreamsApi.md +16 -4
  29. data/docs/MetricsApi.md +3 -3
  30. data/docs/PlaybackRestrictionResponse.md +1 -1
  31. data/docs/PlaybackRestrictionsApi.md +6 -6
  32. data/docs/RealTimeApi.md +2 -2
  33. data/docs/SigningKeyResponse.md +1 -1
  34. data/docs/SimulcastTargetResponse.md +1 -1
  35. data/docs/Space.md +30 -0
  36. data/docs/SpaceResponse.md +18 -0
  37. data/docs/SpaceStatus.md +15 -0
  38. data/docs/SpaceType.md +15 -0
  39. data/docs/SpacesApi.md +658 -0
  40. data/docs/StartSpaceBroadcastResponse.md +18 -0
  41. data/docs/StopSpaceBroadcastResponse.md +18 -0
  42. data/docs/Track.md +9 -7
  43. data/docs/UpdateLiveStreamRequest.md +3 -1
  44. data/docs/UpdateReferrerDomainRestrictionRequest.md +37 -5
  45. data/docs/UploadResponse.md +1 -1
  46. data/docs/VideoViewResponse.md +1 -1
  47. data/gen/generator-config.json +1 -1
  48. data/gen/templates/README.mustache +9 -3
  49. data/lib/mux_ruby/api/assets_api.rb +8 -0
  50. data/lib/mux_ruby/api/direct_uploads_api.rb +6 -0
  51. data/lib/mux_ruby/api/live_streams_api.rb +14 -2
  52. data/lib/mux_ruby/api/metrics_api.rb +5 -5
  53. data/lib/mux_ruby/api/playback_restrictions_api.rb +9 -9
  54. data/lib/mux_ruby/api/real_time_api.rb +2 -2
  55. data/lib/mux_ruby/api/spaces_api.rb +619 -0
  56. data/lib/mux_ruby/models/abridged_video_view.rb +7 -0
  57. data/lib/mux_ruby/models/asset.rb +1 -1
  58. data/lib/mux_ruby/models/asset_non_standard_input_reasons.rb +2 -2
  59. data/lib/mux_ruby/models/broadcast.rb +305 -0
  60. data/lib/mux_ruby/models/broadcast_layout.rb +37 -0
  61. data/lib/mux_ruby/models/broadcast_resolution.rb +41 -0
  62. data/lib/mux_ruby/models/broadcast_response.rb +223 -0
  63. data/lib/mux_ruby/models/broadcast_status.rb +37 -0
  64. data/lib/mux_ruby/models/create_broadcast_request.rb +266 -0
  65. data/lib/mux_ruby/models/create_live_stream_request.rb +40 -4
  66. data/lib/mux_ruby/models/create_simulcast_target_request.rb +1 -1
  67. data/lib/mux_ruby/models/create_space_request.rb +242 -0
  68. data/lib/mux_ruby/models/input_settings.rb +3 -3
  69. data/lib/mux_ruby/models/list_spaces_response.rb +225 -0
  70. data/lib/mux_ruby/models/live_stream.rb +40 -4
  71. data/lib/mux_ruby/models/space.rb +301 -0
  72. data/lib/mux_ruby/models/space_response.rb +223 -0
  73. data/lib/mux_ruby/models/space_status.rb +37 -0
  74. data/lib/mux_ruby/models/space_type.rb +36 -0
  75. data/lib/mux_ruby/models/start_space_broadcast_response.rb +218 -0
  76. data/lib/mux_ruby/models/stop_space_broadcast_response.rb +218 -0
  77. data/lib/mux_ruby/models/track.rb +32 -10
  78. data/lib/mux_ruby/models/update_live_stream_request.rb +40 -4
  79. data/lib/mux_ruby/models/update_referrer_domain_restriction_request.rb +74 -179
  80. data/lib/mux_ruby/models/video_view.rb +103 -0
  81. data/lib/mux_ruby/version.rb +1 -1
  82. data/lib/mux_ruby.rb +15 -0
  83. data/spec/api/spaces_api_spec.rb +149 -0
  84. data/spec/models/broadcast_layout_spec.rb +28 -0
  85. data/spec/models/broadcast_resolution_spec.rb +28 -0
  86. data/spec/models/broadcast_response_spec.rb +34 -0
  87. data/spec/models/broadcast_spec.rb +70 -0
  88. data/spec/models/broadcast_status_spec.rb +28 -0
  89. data/spec/models/create_broadcast_request_spec.rb +58 -0
  90. data/spec/models/create_space_request_spec.rb +46 -0
  91. data/spec/models/list_spaces_response_spec.rb +34 -0
  92. data/spec/models/space_response_spec.rb +34 -0
  93. data/spec/models/space_spec.rb +70 -0
  94. data/spec/models/space_status_spec.rb +28 -0
  95. data/spec/models/space_type_spec.rb +28 -0
  96. data/spec/models/start_space_broadcast_response_spec.rb +34 -0
  97. data/spec/models/stop_space_broadcast_response_spec.rb +34 -0
  98. metadata +159 -99
@@ -0,0 +1,225 @@
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 ListSpacesResponse
18
+ attr_accessor :data
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'data' => :'data'
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
+ :'data' => :'Array<Space>'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::ListSpacesResponse` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::ListSpacesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'data')
61
+ if (value = attributes[:'data']).is_a?(Array)
62
+ self.data = value
63
+ end
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ invalid_properties = Array.new
71
+ if @data.nil?
72
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
73
+ end
74
+
75
+ invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ return false if @data.nil?
82
+ true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ data == o.data
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Integer] Hash code
101
+ def hash
102
+ [data].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def self.build_from_hash(attributes)
109
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = MuxRuby.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -64,6 +64,9 @@ module MuxRuby
64
64
  # True means this live stream is a test live stream. Test live streams can be used to help evaluate the Mux Video APIs for free. There is no limit on the number of test live streams, but they are watermarked with the Mux logo, and limited to 5 minutes. The test live stream is disabled after the stream is active for 5 mins and the recorded asset also deleted after 24 hours.
65
65
  attr_accessor :test
66
66
 
67
+ # The time in seconds a live stream may be continuously active before being disconnected. Defaults to 12 hours.
68
+ attr_accessor :max_continuous_duration
69
+
67
70
  class EnumAttributeValidator
68
71
  attr_reader :datatype
69
72
  attr_reader :allowable_values
@@ -105,7 +108,8 @@ module MuxRuby
105
108
  :'low_latency' => :'low_latency',
106
109
  :'simulcast_targets' => :'simulcast_targets',
107
110
  :'latency_mode' => :'latency_mode',
108
- :'test' => :'test'
111
+ :'test' => :'test',
112
+ :'max_continuous_duration' => :'max_continuous_duration'
109
113
  }
110
114
  end
111
115
 
@@ -133,7 +137,8 @@ module MuxRuby
133
137
  :'low_latency' => :'Boolean',
134
138
  :'simulcast_targets' => :'Array<SimulcastTarget>',
135
139
  :'latency_mode' => :'String',
136
- :'test' => :'Boolean'
140
+ :'test' => :'Boolean',
141
+ :'max_continuous_duration' => :'Integer'
137
142
  }
138
143
  end
139
144
 
@@ -235,12 +240,26 @@ module MuxRuby
235
240
  if attributes.key?(:'test')
236
241
  self.test = attributes[:'test']
237
242
  end
243
+
244
+ if attributes.key?(:'max_continuous_duration')
245
+ self.max_continuous_duration = attributes[:'max_continuous_duration']
246
+ else
247
+ self.max_continuous_duration = 43200
248
+ end
238
249
  end
239
250
 
240
251
  # Show invalid properties with the reasons. Usually used together with valid?
241
252
  # @return Array for valid properties with the reasons
242
253
  def list_invalid_properties
243
254
  invalid_properties = Array.new
255
+ if !@max_continuous_duration.nil? && @max_continuous_duration > 43200
256
+ invalid_properties.push('invalid value for "max_continuous_duration", must be smaller than or equal to 43200.')
257
+ end
258
+
259
+ if !@max_continuous_duration.nil? && @max_continuous_duration < 60
260
+ invalid_properties.push('invalid value for "max_continuous_duration", must be greater than or equal to 60.')
261
+ end
262
+
244
263
  invalid_properties
245
264
  end
246
265
 
@@ -249,6 +268,8 @@ module MuxRuby
249
268
  def valid?
250
269
  latency_mode_validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
251
270
  return false unless latency_mode_validator.valid?(@latency_mode)
271
+ return false if !@max_continuous_duration.nil? && @max_continuous_duration > 43200
272
+ return false if !@max_continuous_duration.nil? && @max_continuous_duration < 60
252
273
  true
253
274
  end
254
275
 
@@ -262,6 +283,20 @@ module MuxRuby
262
283
  @latency_mode = latency_mode
263
284
  end
264
285
 
286
+ # Custom attribute writer method with validation
287
+ # @param [Object] max_continuous_duration Value to be assigned
288
+ def max_continuous_duration=(max_continuous_duration)
289
+ if !max_continuous_duration.nil? && max_continuous_duration > 43200
290
+ fail ArgumentError, 'invalid value for "max_continuous_duration", must be smaller than or equal to 43200.'
291
+ end
292
+
293
+ if !max_continuous_duration.nil? && max_continuous_duration < 60
294
+ fail ArgumentError, 'invalid value for "max_continuous_duration", must be greater than or equal to 60.'
295
+ end
296
+
297
+ @max_continuous_duration = max_continuous_duration
298
+ end
299
+
265
300
  # Checks equality by comparing each attribute.
266
301
  # @param [Object] Object to be compared
267
302
  def ==(o)
@@ -283,7 +318,8 @@ module MuxRuby
283
318
  low_latency == o.low_latency &&
284
319
  simulcast_targets == o.simulcast_targets &&
285
320
  latency_mode == o.latency_mode &&
286
- test == o.test
321
+ test == o.test &&
322
+ max_continuous_duration == o.max_continuous_duration
287
323
  end
288
324
 
289
325
  # @see the `==` method
@@ -295,7 +331,7 @@ module MuxRuby
295
331
  # Calculates hash code according to all attributes.
296
332
  # @return [Integer] Hash code
297
333
  def hash
298
- [id, created_at, stream_key, active_asset_id, recent_asset_ids, status, playback_ids, new_asset_settings, passthrough, audio_only, embedded_subtitles, reconnect_window, reduced_latency, low_latency, simulcast_targets, latency_mode, test].hash
334
+ [id, created_at, stream_key, active_asset_id, recent_asset_ids, status, playback_ids, new_asset_settings, passthrough, audio_only, embedded_subtitles, reconnect_window, reduced_latency, low_latency, simulcast_targets, latency_mode, test, max_continuous_duration].hash
299
335
  end
300
336
 
301
337
  # Builds the object from hash
@@ -0,0 +1,301 @@
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 Space
18
+ # Unique identifier for the space. Max 255 characters.
19
+ attr_accessor :id
20
+
21
+ # Time the space was created, defined as a Unix timestamp (seconds since epoch).
22
+ attr_accessor :created_at
23
+
24
+ attr_accessor :type
25
+
26
+ attr_accessor :status
27
+
28
+ # Arbitrary user-supplied metadata that will be included in the space details and related webhooks. Max: 255 characters.
29
+ attr_accessor :passthrough
30
+
31
+ # An array of broadcast destinations.
32
+ attr_accessor :broadcasts
33
+
34
+ # Unique identifier for the current lifecycle of the space. Only set when the space is `active` and is set to a new value each time the space transitions from `idle` to `active`. This value is useful for logging and debugging issues. Max 255 characters.
35
+ attr_accessor :active_session_id
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'id' => :'id',
41
+ :'created_at' => :'created_at',
42
+ :'type' => :'type',
43
+ :'status' => :'status',
44
+ :'passthrough' => :'passthrough',
45
+ :'broadcasts' => :'broadcasts',
46
+ :'active_session_id' => :'active_session_id'
47
+ }
48
+ end
49
+
50
+ # Returns all the JSON keys this model knows about
51
+ def self.acceptable_attributes
52
+ attribute_map.values
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.openapi_types
57
+ {
58
+ :'id' => :'String',
59
+ :'created_at' => :'String',
60
+ :'type' => :'SpaceType',
61
+ :'status' => :'SpaceStatus',
62
+ :'passthrough' => :'String',
63
+ :'broadcasts' => :'Array<Broadcast>',
64
+ :'active_session_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
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::Space` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::Space`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'id')
90
+ self.id = attributes[:'id']
91
+ end
92
+
93
+ if attributes.key?(:'created_at')
94
+ self.created_at = attributes[:'created_at']
95
+ end
96
+
97
+ if attributes.key?(:'type')
98
+ self.type = attributes[:'type']
99
+ else
100
+ self.type = 'server'
101
+ end
102
+
103
+ if attributes.key?(:'status')
104
+ self.status = attributes[:'status']
105
+ end
106
+
107
+ if attributes.key?(:'passthrough')
108
+ self.passthrough = attributes[:'passthrough']
109
+ end
110
+
111
+ if attributes.key?(:'broadcasts')
112
+ if (value = attributes[:'broadcasts']).is_a?(Array)
113
+ self.broadcasts = value
114
+ end
115
+ end
116
+
117
+ if attributes.key?(:'active_session_id')
118
+ self.active_session_id = attributes[:'active_session_id']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ if @id.nil?
127
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
128
+ end
129
+
130
+ if @created_at.nil?
131
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
132
+ end
133
+
134
+ if @type.nil?
135
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
136
+ end
137
+
138
+ if @status.nil?
139
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
140
+ end
141
+
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ return false if @id.nil?
149
+ return false if @created_at.nil?
150
+ return false if @type.nil?
151
+ return false if @status.nil?
152
+ true
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
+ id == o.id &&
161
+ created_at == o.created_at &&
162
+ type == o.type &&
163
+ status == o.status &&
164
+ passthrough == o.passthrough &&
165
+ broadcasts == o.broadcasts &&
166
+ active_session_id == o.active_session_id
167
+ end
168
+
169
+ # @see the `==` method
170
+ # @param [Object] Object to be compared
171
+ def eql?(o)
172
+ self == o
173
+ end
174
+
175
+ # Calculates hash code according to all attributes.
176
+ # @return [Integer] Hash code
177
+ def hash
178
+ [id, created_at, type, status, passthrough, broadcasts, active_session_id].hash
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def self.build_from_hash(attributes)
185
+ new.build_from_hash(attributes)
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def build_from_hash(attributes)
192
+ return nil unless attributes.is_a?(Hash)
193
+ self.class.openapi_types.each_pair do |key, type|
194
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
195
+ self.send("#{key}=", nil)
196
+ elsif type =~ /\AArray<(.*)>/i
197
+ # check to ensure the input is an array given that the attribute
198
+ # is documented as an array but the input is not
199
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
200
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
201
+ end
202
+ elsif !attributes[self.class.attribute_map[key]].nil?
203
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
204
+ end
205
+ end
206
+
207
+ self
208
+ end
209
+
210
+ # Deserializes the data based on type
211
+ # @param string type Data type
212
+ # @param string value Value to be deserialized
213
+ # @return [Object] Deserialized data
214
+ def _deserialize(type, value)
215
+ case type.to_sym
216
+ when :Time
217
+ Time.parse(value)
218
+ when :Date
219
+ Date.parse(value)
220
+ when :String
221
+ value.to_s
222
+ when :Integer
223
+ value.to_i
224
+ when :Float
225
+ value.to_f
226
+ when :Boolean
227
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
228
+ true
229
+ else
230
+ false
231
+ end
232
+ when :Object
233
+ # generic object (usually a Hash), return directly
234
+ value
235
+ when /\AArray<(?<inner_type>.+)>\z/
236
+ inner_type = Regexp.last_match[:inner_type]
237
+ value.map { |v| _deserialize(inner_type, v) }
238
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
239
+ k_type = Regexp.last_match[:k_type]
240
+ v_type = Regexp.last_match[:v_type]
241
+ {}.tap do |hash|
242
+ value.each do |k, v|
243
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
244
+ end
245
+ end
246
+ else # model
247
+ # models (e.g. Pet) or oneOf
248
+ klass = MuxRuby.const_get(type)
249
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
250
+ end
251
+ end
252
+
253
+ # Returns the string representation of the object
254
+ # @return [String] String presentation of the object
255
+ def to_s
256
+ to_hash.to_s
257
+ end
258
+
259
+ # to_body is an alias to to_hash (backward compatibility)
260
+ # @return [Hash] Returns the object in the form of hash
261
+ def to_body
262
+ to_hash
263
+ end
264
+
265
+ # Returns the object in the form of hash
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_hash
268
+ hash = {}
269
+ self.class.attribute_map.each_pair do |attr, param|
270
+ value = self.send(attr)
271
+ if value.nil?
272
+ is_nullable = self.class.openapi_nullable.include?(attr)
273
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
274
+ end
275
+
276
+ hash[param] = _to_hash(value)
277
+ end
278
+ hash
279
+ end
280
+
281
+ # Outputs non-array value in the form of hash
282
+ # For object, use to_hash. Otherwise, just return the value
283
+ # @param [Object] value Any valid value
284
+ # @return [Hash] Returns the value in the form of hash
285
+ def _to_hash(value)
286
+ if value.is_a?(Array)
287
+ value.compact.map { |v| _to_hash(v) }
288
+ elsif value.is_a?(Hash)
289
+ {}.tap do |hash|
290
+ value.each { |k, v| hash[k] = _to_hash(v) }
291
+ end
292
+ elsif value.respond_to? :to_hash
293
+ value.to_hash
294
+ else
295
+ value
296
+ end
297
+ end
298
+
299
+ end
300
+
301
+ end