mux_ruby 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +4 -4
  4. data/docs/Asset.md +1 -1
  5. data/docs/AssetsApi.md +73 -0
  6. data/docs/CreateAssetRequest.md +1 -1
  7. data/docs/CreateLiveStreamRequest.md +4 -2
  8. data/docs/CreatePlaybackRestrictionRequest.md +18 -0
  9. data/docs/CreateSimulcastTargetRequest.md +1 -1
  10. data/docs/CreateTrackRequest.md +1 -1
  11. data/docs/DeliveryUsageApi.md +4 -2
  12. data/docs/DimensionsApi.md +4 -4
  13. data/docs/ErrorsApi.md +4 -4
  14. data/docs/FiltersApi.md +4 -4
  15. data/docs/InputSettings.md +1 -1
  16. data/docs/LiveStream.md +7 -3
  17. data/docs/LiveStreamEmbeddedSubtitleSettings.md +1 -1
  18. data/docs/LiveStreamsApi.md +73 -0
  19. data/docs/MetricsApi.md +18 -18
  20. data/docs/PlaybackRestriction.md +24 -0
  21. data/docs/PlaybackRestrictionResponse.md +15 -0
  22. data/docs/PlaybackRestrictionsApi.md +367 -0
  23. data/docs/RealTimeApi.md +6 -6
  24. data/docs/ReferrerDomainRestriction.md +20 -0
  25. data/docs/SimulcastTarget.md +1 -1
  26. data/docs/Track.md +1 -1
  27. data/docs/UpdateAssetRequest.md +18 -0
  28. data/docs/UpdateLiveStreamRequest.md +22 -0
  29. data/docs/UpdateReferrerDomainRestrictionRequest.md +15 -0
  30. data/docs/VideoViewsApi.md +4 -4
  31. data/gen/generator-config.json +1 -1
  32. data/lib/mux_ruby/api/assets_api.rb +71 -0
  33. data/lib/mux_ruby/api/delivery_usage_api.rb +5 -2
  34. data/lib/mux_ruby/api/dimensions_api.rb +4 -4
  35. data/lib/mux_ruby/api/errors_api.rb +4 -4
  36. data/lib/mux_ruby/api/filters_api.rb +4 -4
  37. data/lib/mux_ruby/api/live_streams_api.rb +71 -0
  38. data/lib/mux_ruby/api/metrics_api.rb +18 -18
  39. data/lib/mux_ruby/api/playback_restrictions_api.rb +345 -0
  40. data/lib/mux_ruby/api/real_time_api.rb +6 -6
  41. data/lib/mux_ruby/api/video_views_api.rb +4 -4
  42. data/lib/mux_ruby/models/asset.rb +1 -1
  43. data/lib/mux_ruby/models/create_asset_request.rb +1 -1
  44. data/lib/mux_ruby/models/create_live_stream_request.rb +47 -3
  45. data/lib/mux_ruby/models/create_playback_restriction_request.rb +218 -0
  46. data/lib/mux_ruby/models/create_simulcast_target_request.rb +1 -1
  47. data/lib/mux_ruby/models/create_track_request.rb +1 -1
  48. data/lib/mux_ruby/models/input_settings.rb +1 -1
  49. data/lib/mux_ruby/models/input_settings_overlay_settings.rb +1 -1
  50. data/lib/mux_ruby/models/live_stream.rb +38 -4
  51. data/lib/mux_ruby/models/live_stream_embedded_subtitle_settings.rb +1 -1
  52. data/lib/mux_ruby/models/playback_restriction.rb +248 -0
  53. data/lib/mux_ruby/models/playback_restriction_response.rb +209 -0
  54. data/lib/mux_ruby/models/referrer_domain_restriction.rb +234 -0
  55. data/lib/mux_ruby/models/simulcast_target.rb +1 -1
  56. data/lib/mux_ruby/models/track.rb +1 -1
  57. data/lib/mux_ruby/models/update_asset_request.rb +219 -0
  58. data/lib/mux_ruby/models/update_live_stream_request.rb +297 -0
  59. data/lib/mux_ruby/models/update_referrer_domain_restriction_request.rb +209 -0
  60. data/lib/mux_ruby/version.rb +1 -1
  61. data/lib/mux_ruby.rb +8 -0
  62. data/spec/api/playback_restrictions_api_spec.rb +97 -0
  63. data/spec/models/create_playback_restriction_request_spec.rb +34 -0
  64. data/spec/models/playback_restriction_response_spec.rb +28 -0
  65. data/spec/models/playback_restriction_spec.rb +52 -0
  66. data/spec/models/referrer_domain_restriction_spec.rb +40 -0
  67. data/spec/models/update_asset_request_spec.rb +34 -0
  68. data/spec/models/update_live_stream_request_spec.rb +50 -0
  69. data/spec/models/update_referrer_domain_restriction_request_spec.rb +28 -0
  70. metadata +129 -97
@@ -0,0 +1,218 @@
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 CreatePlaybackRestrictionRequest
18
+ attr_accessor :referrer
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'referrer' => :'referrer'
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
+ :'referrer' => :'ReferrerDomainRestriction'
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::CreatePlaybackRestrictionRequest` 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::CreatePlaybackRestrictionRequest`. 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?(:'referrer')
61
+ self.referrer = attributes[:'referrer']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ referrer == o.referrer
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [referrer].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.openapi_types.each_pair do |key, type|
111
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
112
+ self.send("#{key}=", nil)
113
+ elsif type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
117
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
118
+ end
119
+ elsif !attributes[self.class.attribute_map[key]].nil?
120
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
121
+ end
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :Time
134
+ Time.parse(value)
135
+ when :Date
136
+ Date.parse(value)
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :Boolean
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ # models (e.g. Pet) or oneOf
165
+ klass = MuxRuby.const_get(type)
166
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
167
+ end
168
+ end
169
+
170
+ # Returns the string representation of the object
171
+ # @return [String] String presentation of the object
172
+ def to_s
173
+ to_hash.to_s
174
+ end
175
+
176
+ # to_body is an alias to to_hash (backward compatibility)
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_body
179
+ to_hash
180
+ end
181
+
182
+ # Returns the object in the form of hash
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_hash
185
+ hash = {}
186
+ self.class.attribute_map.each_pair do |attr, param|
187
+ value = self.send(attr)
188
+ if value.nil?
189
+ is_nullable = self.class.openapi_nullable.include?(attr)
190
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
191
+ end
192
+
193
+ hash[param] = _to_hash(value)
194
+ end
195
+ hash
196
+ end
197
+
198
+ # Outputs non-array value in the form of hash
199
+ # For object, use to_hash. Otherwise, just return the value
200
+ # @param [Object] value Any valid value
201
+ # @return [Hash] Returns the value in the form of hash
202
+ def _to_hash(value)
203
+ if value.is_a?(Array)
204
+ value.compact.map { |v| _to_hash(v) }
205
+ elsif value.is_a?(Hash)
206
+ {}.tap do |hash|
207
+ value.each { |k, v| hash[k] = _to_hash(v) }
208
+ end
209
+ elsif value.respond_to? :to_hash
210
+ value.to_hash
211
+ else
212
+ value
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end
@@ -15,7 +15,7 @@ require 'time'
15
15
 
16
16
  module MuxRuby
17
17
  class CreateSimulcastTargetRequest
18
- # Arbitrary metadata set by you when creating a simulcast target.
18
+ # Arbitrary user-supplied metadata set by you when creating a simulcast target.
19
19
  attr_accessor :passthrough
20
20
 
21
21
  # Stream Key represents a stream identifier on the third party live streaming service to send the parent live stream to.
@@ -30,7 +30,7 @@ module MuxRuby
30
30
  # Indicates the track provides Subtitles for the Deaf or Hard-of-hearing (SDH).
31
31
  attr_accessor :closed_captions
32
32
 
33
- # Arbitrary metadata set for the track either when creating the asset or track.
33
+ # Arbitrary user-supplied metadata set for the track either when creating the asset or track.
34
34
  attr_accessor :passthrough
35
35
 
36
36
  class EnumAttributeValidator
@@ -16,7 +16,7 @@ require 'time'
16
16
  module MuxRuby
17
17
  # An array of objects that each describe an input file to be used to create the asset. As a shortcut, `input` can also be a string URL for a file when only one input file is used. See `input[].url` for requirements.
18
18
  class InputSettings
19
- # The web address of the file that Mux should download and use. * For subtitles text tracks, the url is the location of subtitle/captions file. Mux supports [SubRip Text (SRT)](https://en.wikipedia.org/wiki/SubRip) and [Web Video Text Tracks](https://www.w3.org/TR/webvtt1/) format for ingesting Subtitles and Closed Captions. * For Watermarking or Overlay, the url is the location of the watermark image. * When creating clips from existing Mux assets, the url is defined with `mux://assets/{asset_id}` template where `asset_id` is the Asset Identifier for creating the clip from.
19
+ # The URL of the file that Mux should download and use. * For subtitles text tracks, the URL is the location of subtitle/captions file. Mux supports [SubRip Text (SRT)](https://en.wikipedia.org/wiki/SubRip) and [Web Video Text Tracks](https://www.w3.org/TR/webvtt1/) format for ingesting Subtitles and Closed Captions. * For Watermarking or Overlay, the URL is the location of the watermark image. * When creating clips from existing Mux assets, the URL is defined with `mux://assets/{asset_id}` template where `asset_id` is the Asset Identifier for creating the clip from.
20
20
  attr_accessor :url
21
21
 
22
22
  attr_accessor :overlay_settings
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module MuxRuby
17
- # An object that describes how the image file referenced in url should be placed over the video (i.e. watermarking).
17
+ # An object that describes how the image file referenced in URL should be placed over the video (i.e. watermarking). Ensure that the URL is active and persists the entire lifespan of the video object.
18
18
  class InputSettingsOverlaySettings
19
19
  # Where the vertical positioning of the overlay/watermark should begin from. Defaults to `\"top\"`
20
20
  attr_accessor :vertical_align
@@ -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
@@ -18,7 +18,7 @@ module MuxRuby
18
18
  # A name for this live stream closed caption track.
19
19
  attr_accessor :name
20
20
 
21
- # Arbitrary metadata set for the live stream closed caption track. Max 255 characters.
21
+ # Arbitrary user-supplied metadata set for the live stream closed caption track. Max 255 characters.
22
22
  attr_accessor :passthrough
23
23
 
24
24
  # The language of the closed caption stream. Value must be BCP 47 compliant.
@@ -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