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
@@ -38,24 +38,30 @@ module MuxRuby
38
38
 
39
39
  attr_accessor :new_asset_settings
40
40
 
41
- # Arbitrary metadata set for the asset. Max 255 characters.
41
+ # Arbitrary user-supplied metadata set for the asset. Max 255 characters.
42
42
  attr_accessor :passthrough
43
43
 
44
44
  # The live stream only processes the audio track if the value is set to true. Mux drops the video track if broadcasted.
45
45
  attr_accessor :audio_only
46
46
 
47
+ # Describes the embedded closed caption configuration of the incoming live stream.
48
+ attr_accessor :embedded_subtitles
49
+
47
50
  # 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. **Min**: 0.1s. **Max**: 300s (5 minutes).
48
51
  attr_accessor :reconnect_window
49
52
 
50
- # Latency is the time from when the streamer does something in real life to when you see it happen in the player. Set this if you want lower latency for your live stream. **Note**: Reconnect windows are incompatible with Reduced Latency and will always be set to zero (0) seconds. See the [Reduce live stream latency guide](https://docs.mux.com/guides/video/reduce-live-stream-latency) to understand the tradeoffs.
53
+ # This field is deprecated. Please use latency_mode instead. Latency is the time from when the streamer transmits a frame of video to when you see it in the player. Set this if you want lower latency for your live stream. **Note**: Reconnect windows are incompatible with Reduced Latency and will always be set to zero (0) seconds. See the [Reduce live stream latency guide](https://docs.mux.com/guides/video/reduce-live-stream-latency) to understand the tradeoffs.
51
54
  attr_accessor :reduced_latency
52
55
 
53
- # Latency is the time from when the streamer does something in real life to when you see it happen in the player. Setting this option will enable compatibility with the LL-HLS specification for low-latency streaming. This typically has lower latency than Reduced Latency streams, and cannot be combined with Reduced Latency. Note: Reconnect windows are incompatible with Low Latency and will always be set to zero (0) seconds.
56
+ # This field is deprecated. Please use latency_mode instead. Latency is the time from when the streamer transmits a frame of video to when you see it in the player. Setting this option will enable compatibility with the LL-HLS specification for low-latency streaming. This typically has lower latency than Reduced Latency streams, and cannot be combined with Reduced Latency. Note: Reconnect windows are incompatible with Low Latency and will always be set to zero (0) seconds.
54
57
  attr_accessor :low_latency
55
58
 
56
59
  # Each Simulcast Target contains configuration details to broadcast (or \"restream\") a live stream to a third-party streaming service. [See the Stream live to 3rd party platforms guide](https://docs.mux.com/guides/video/stream-live-to-3rd-party-platforms).
57
60
  attr_accessor :simulcast_targets
58
61
 
62
+ # 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/
63
+ attr_accessor :latency_mode
64
+
59
65
  # 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.
60
66
  attr_accessor :test
61
67
 
@@ -94,10 +100,12 @@ module MuxRuby
94
100
  :'new_asset_settings' => :'new_asset_settings',
95
101
  :'passthrough' => :'passthrough',
96
102
  :'audio_only' => :'audio_only',
103
+ :'embedded_subtitles' => :'embedded_subtitles',
97
104
  :'reconnect_window' => :'reconnect_window',
98
105
  :'reduced_latency' => :'reduced_latency',
99
106
  :'low_latency' => :'low_latency',
100
107
  :'simulcast_targets' => :'simulcast_targets',
108
+ :'latency_mode' => :'latency_mode',
101
109
  :'test' => :'test'
102
110
  }
103
111
  end
@@ -120,10 +128,12 @@ module MuxRuby
120
128
  :'new_asset_settings' => :'CreateAssetRequest',
121
129
  :'passthrough' => :'String',
122
130
  :'audio_only' => :'Boolean',
131
+ :'embedded_subtitles' => :'Array<LiveStreamEmbeddedSubtitleSettings>',
123
132
  :'reconnect_window' => :'Float',
124
133
  :'reduced_latency' => :'Boolean',
125
134
  :'low_latency' => :'Boolean',
126
135
  :'simulcast_targets' => :'Array<SimulcastTarget>',
136
+ :'latency_mode' => :'String',
127
137
  :'test' => :'Boolean'
128
138
  }
129
139
  end
@@ -193,6 +203,12 @@ module MuxRuby
193
203
  self.audio_only = attributes[:'audio_only']
194
204
  end
195
205
 
206
+ if attributes.key?(:'embedded_subtitles')
207
+ if (value = attributes[:'embedded_subtitles']).is_a?(Array)
208
+ self.embedded_subtitles = value
209
+ end
210
+ end
211
+
196
212
  if attributes.key?(:'reconnect_window')
197
213
  self.reconnect_window = attributes[:'reconnect_window']
198
214
  else
@@ -213,6 +229,10 @@ module MuxRuby
213
229
  end
214
230
  end
215
231
 
232
+ if attributes.key?(:'latency_mode')
233
+ self.latency_mode = attributes[:'latency_mode']
234
+ end
235
+
216
236
  if attributes.key?(:'test')
217
237
  self.test = attributes[:'test']
218
238
  end
@@ -230,6 +250,8 @@ module MuxRuby
230
250
  def valid?
231
251
  status_validator = EnumAttributeValidator.new('String', ["active", "idle", "disabled"])
232
252
  return false unless status_validator.valid?(@status)
253
+ latency_mode_validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
254
+ return false unless latency_mode_validator.valid?(@latency_mode)
233
255
  true
234
256
  end
235
257
 
@@ -243,6 +265,16 @@ module MuxRuby
243
265
  @status = status
244
266
  end
245
267
 
268
+ # Custom attribute writer method checking allowed values (enum).
269
+ # @param [Object] latency_mode Object to be assigned
270
+ def latency_mode=(latency_mode)
271
+ validator = EnumAttributeValidator.new('String', ["low", "reduced", "standard"])
272
+ unless validator.valid?(latency_mode)
273
+ fail ArgumentError, "invalid value for \"latency_mode\", must be one of #{validator.allowable_values}."
274
+ end
275
+ @latency_mode = latency_mode
276
+ end
277
+
246
278
  # Checks equality by comparing each attribute.
247
279
  # @param [Object] Object to be compared
248
280
  def ==(o)
@@ -258,10 +290,12 @@ module MuxRuby
258
290
  new_asset_settings == o.new_asset_settings &&
259
291
  passthrough == o.passthrough &&
260
292
  audio_only == o.audio_only &&
293
+ embedded_subtitles == o.embedded_subtitles &&
261
294
  reconnect_window == o.reconnect_window &&
262
295
  reduced_latency == o.reduced_latency &&
263
296
  low_latency == o.low_latency &&
264
297
  simulcast_targets == o.simulcast_targets &&
298
+ latency_mode == o.latency_mode &&
265
299
  test == o.test
266
300
  end
267
301
 
@@ -274,7 +308,7 @@ module MuxRuby
274
308
  # Calculates hash code according to all attributes.
275
309
  # @return [Integer] Hash code
276
310
  def hash
277
- [id, created_at, stream_key, active_asset_id, recent_asset_ids, status, playback_ids, new_asset_settings, passthrough, audio_only, reconnect_window, reduced_latency, low_latency, simulcast_targets, test].hash
311
+ [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
278
312
  end
279
313
 
280
314
  # Builds the object from hash
@@ -0,0 +1,287 @@
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 LiveStreamEmbeddedSubtitleSettings
18
+ # A name for this live stream closed caption track.
19
+ attr_accessor :name
20
+
21
+ # Arbitrary user-supplied metadata set for the live stream closed caption track. Max 255 characters.
22
+ attr_accessor :passthrough
23
+
24
+ # The language of the closed caption stream. Value must be BCP 47 compliant.
25
+ attr_accessor :language_code
26
+
27
+ # CEA-608 caption channel to read data from.
28
+ attr_accessor :language_channel
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'name' => :'name',
56
+ :'passthrough' => :'passthrough',
57
+ :'language_code' => :'language_code',
58
+ :'language_channel' => :'language_channel'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'name' => :'String',
71
+ :'passthrough' => :'String',
72
+ :'language_code' => :'String',
73
+ :'language_channel' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::LiveStreamEmbeddedSubtitleSettings` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::LiveStreamEmbeddedSubtitleSettings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'name')
99
+ self.name = attributes[:'name']
100
+ end
101
+
102
+ if attributes.key?(:'passthrough')
103
+ self.passthrough = attributes[:'passthrough']
104
+ end
105
+
106
+ if attributes.key?(:'language_code')
107
+ self.language_code = attributes[:'language_code']
108
+ else
109
+ self.language_code = 'en'
110
+ end
111
+
112
+ if attributes.key?(:'language_channel')
113
+ self.language_channel = attributes[:'language_channel']
114
+ else
115
+ self.language_channel = 'cc1'
116
+ end
117
+ end
118
+
119
+ # Show invalid properties with the reasons. Usually used together with valid?
120
+ # @return Array for valid properties with the reasons
121
+ def list_invalid_properties
122
+ invalid_properties = Array.new
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ language_channel_validator = EnumAttributeValidator.new('String', ["cc1"])
130
+ return false unless language_channel_validator.valid?(@language_channel)
131
+ true
132
+ end
133
+
134
+ # Custom attribute writer method checking allowed values (enum).
135
+ # @param [Object] language_channel Object to be assigned
136
+ def language_channel=(language_channel)
137
+ validator = EnumAttributeValidator.new('String', ["cc1"])
138
+ unless validator.valid?(language_channel)
139
+ fail ArgumentError, "invalid value for \"language_channel\", must be one of #{validator.allowable_values}."
140
+ end
141
+ @language_channel = language_channel
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(o)
147
+ return true if self.equal?(o)
148
+ self.class == o.class &&
149
+ name == o.name &&
150
+ passthrough == o.passthrough &&
151
+ language_code == o.language_code &&
152
+ language_channel == o.language_channel
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Integer] Hash code
163
+ def hash
164
+ [name, passthrough, language_code, language_channel].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def self.build_from_hash(attributes)
171
+ new.build_from_hash(attributes)
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ self.class.openapi_types.each_pair do |key, type|
180
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
181
+ self.send("#{key}=", nil)
182
+ elsif type =~ /\AArray<(.*)>/i
183
+ # check to ensure the input is an array given that the attribute
184
+ # is documented as an array but the input is not
185
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
186
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
187
+ end
188
+ elsif !attributes[self.class.attribute_map[key]].nil?
189
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
190
+ end
191
+ end
192
+
193
+ self
194
+ end
195
+
196
+ # Deserializes the data based on type
197
+ # @param string type Data type
198
+ # @param string value Value to be deserialized
199
+ # @return [Object] Deserialized data
200
+ def _deserialize(type, value)
201
+ case type.to_sym
202
+ when :Time
203
+ Time.parse(value)
204
+ when :Date
205
+ Date.parse(value)
206
+ when :String
207
+ value.to_s
208
+ when :Integer
209
+ value.to_i
210
+ when :Float
211
+ value.to_f
212
+ when :Boolean
213
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
214
+ true
215
+ else
216
+ false
217
+ end
218
+ when :Object
219
+ # generic object (usually a Hash), return directly
220
+ value
221
+ when /\AArray<(?<inner_type>.+)>\z/
222
+ inner_type = Regexp.last_match[:inner_type]
223
+ value.map { |v| _deserialize(inner_type, v) }
224
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
225
+ k_type = Regexp.last_match[:k_type]
226
+ v_type = Regexp.last_match[:v_type]
227
+ {}.tap do |hash|
228
+ value.each do |k, v|
229
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
230
+ end
231
+ end
232
+ else # model
233
+ # models (e.g. Pet) or oneOf
234
+ klass = MuxRuby.const_get(type)
235
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
236
+ end
237
+ end
238
+
239
+ # Returns the string representation of the object
240
+ # @return [String] String presentation of the object
241
+ def to_s
242
+ to_hash.to_s
243
+ end
244
+
245
+ # to_body is an alias to to_hash (backward compatibility)
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_body
248
+ to_hash
249
+ end
250
+
251
+ # Returns the object in the form of hash
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_hash
254
+ hash = {}
255
+ self.class.attribute_map.each_pair do |attr, param|
256
+ value = self.send(attr)
257
+ if value.nil?
258
+ is_nullable = self.class.openapi_nullable.include?(attr)
259
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
260
+ end
261
+
262
+ hash[param] = _to_hash(value)
263
+ end
264
+ hash
265
+ end
266
+
267
+ # Outputs non-array value in the form of hash
268
+ # For object, use to_hash. Otherwise, just return the value
269
+ # @param [Object] value Any valid value
270
+ # @return [Hash] Returns the value in the form of hash
271
+ def _to_hash(value)
272
+ if value.is_a?(Array)
273
+ value.compact.map { |v| _to_hash(v) }
274
+ elsif value.is_a?(Hash)
275
+ {}.tap do |hash|
276
+ value.each { |k, v| hash[k] = _to_hash(v) }
277
+ end
278
+ elsif value.respond_to? :to_hash
279
+ value.to_hash
280
+ else
281
+ value
282
+ end
283
+ end
284
+
285
+ end
286
+
287
+ end
@@ -0,0 +1,248 @@
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 PlaybackRestriction
18
+ # Unique identifier for the Playback Restriction. Max 255 characters.
19
+ attr_accessor :id
20
+
21
+ # Time the Playback Restriction was created, defined as a Unix timestamp (seconds since epoch).
22
+ attr_accessor :created_at
23
+
24
+ # Time the Playback Restriction was last updated, defined as a Unix timestamp (seconds since epoch).
25
+ attr_accessor :updated_at
26
+
27
+ attr_accessor :referrer
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'id' => :'id',
33
+ :'created_at' => :'created_at',
34
+ :'updated_at' => :'updated_at',
35
+ :'referrer' => :'referrer'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'id' => :'String',
48
+ :'created_at' => :'String',
49
+ :'updated_at' => :'String',
50
+ :'referrer' => :'ReferrerDomainRestriction'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MuxRuby::PlaybackRestriction` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MuxRuby::PlaybackRestriction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'id')
76
+ self.id = attributes[:'id']
77
+ end
78
+
79
+ if attributes.key?(:'created_at')
80
+ self.created_at = attributes[:'created_at']
81
+ end
82
+
83
+ if attributes.key?(:'updated_at')
84
+ self.updated_at = attributes[:'updated_at']
85
+ end
86
+
87
+ if attributes.key?(:'referrer')
88
+ self.referrer = attributes[:'referrer']
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = Array.new
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ id == o.id &&
111
+ created_at == o.created_at &&
112
+ updated_at == o.updated_at &&
113
+ referrer == o.referrer
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [id, created_at, updated_at, referrer].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ new.build_from_hash(attributes)
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ self.class.openapi_types.each_pair do |key, type|
141
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
142
+ self.send("#{key}=", nil)
143
+ elsif type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
147
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
148
+ end
149
+ elsif !attributes[self.class.attribute_map[key]].nil?
150
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
151
+ end
152
+ end
153
+
154
+ self
155
+ end
156
+
157
+ # Deserializes the data based on type
158
+ # @param string type Data type
159
+ # @param string value Value to be deserialized
160
+ # @return [Object] Deserialized data
161
+ def _deserialize(type, value)
162
+ case type.to_sym
163
+ when :Time
164
+ Time.parse(value)
165
+ when :Date
166
+ Date.parse(value)
167
+ when :String
168
+ value.to_s
169
+ when :Integer
170
+ value.to_i
171
+ when :Float
172
+ value.to_f
173
+ when :Boolean
174
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175
+ true
176
+ else
177
+ false
178
+ end
179
+ when :Object
180
+ # generic object (usually a Hash), return directly
181
+ value
182
+ when /\AArray<(?<inner_type>.+)>\z/
183
+ inner_type = Regexp.last_match[:inner_type]
184
+ value.map { |v| _deserialize(inner_type, v) }
185
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186
+ k_type = Regexp.last_match[:k_type]
187
+ v_type = Regexp.last_match[:v_type]
188
+ {}.tap do |hash|
189
+ value.each do |k, v|
190
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191
+ end
192
+ end
193
+ else # model
194
+ # models (e.g. Pet) or oneOf
195
+ klass = MuxRuby.const_get(type)
196
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ if value.nil?
219
+ is_nullable = self.class.openapi_nullable.include?(attr)
220
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
+ end
222
+
223
+ hash[param] = _to_hash(value)
224
+ end
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.compact.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to? :to_hash
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end
245
+
246
+ end
247
+
248
+ end