shotstack 0.2.1 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.md +387 -23
  4. data/Rakefile +10 -0
  5. data/lib/shotstack/api/create_api.rb +158 -0
  6. data/lib/shotstack/api/edit_api.rb +20 -20
  7. data/lib/shotstack/api/ingest_api.rb +338 -0
  8. data/lib/shotstack/api/serve_api.rb +76 -8
  9. data/lib/shotstack/api_client.rb +28 -24
  10. data/lib/shotstack/api_error.rb +3 -2
  11. data/lib/shotstack/configuration.rb +55 -9
  12. data/lib/shotstack/models/asset.rb +4 -4
  13. data/lib/shotstack/models/asset_render_response.rb +23 -20
  14. data/lib/shotstack/models/asset_response.rb +23 -20
  15. data/lib/shotstack/models/asset_response_attributes.rb +38 -21
  16. data/lib/shotstack/models/asset_response_data.rb +30 -20
  17. data/lib/shotstack/models/audio_asset.rb +57 -23
  18. data/lib/shotstack/models/audio_enhancement.rb +43 -0
  19. data/lib/shotstack/models/clip.rb +29 -33
  20. data/lib/shotstack/models/crop.rb +40 -28
  21. data/lib/shotstack/models/destinations.rb +78 -244
  22. data/lib/shotstack/models/did_generated_asset.rb +273 -0
  23. data/lib/shotstack/models/did_generated_asset_options.rb +54 -0
  24. data/lib/shotstack/models/did_text_to_avatar_options.rb +313 -0
  25. data/lib/shotstack/models/dolby_enhancement.rb +239 -0
  26. data/lib/shotstack/models/dolby_enhancement_options.rb +257 -0
  27. data/lib/shotstack/models/edit.rb +22 -24
  28. data/lib/shotstack/models/eleven_labs_generated_asset.rb +273 -0
  29. data/lib/shotstack/models/eleven_labs_generated_asset_options.rb +54 -0
  30. data/lib/shotstack/models/eleven_labs_text_to_speech_options.rb +303 -0
  31. data/lib/shotstack/models/enhancements.rb +215 -0
  32. data/lib/shotstack/models/flip_transformation.rb +16 -24
  33. data/lib/shotstack/models/font.rb +18 -20
  34. data/lib/shotstack/models/generated_asset.rb +48 -0
  35. data/lib/shotstack/models/generated_asset_error_response.rb +225 -0
  36. data/lib/shotstack/models/generated_asset_error_response_data.rb +257 -0
  37. data/lib/shotstack/models/generated_asset_response.rb +222 -0
  38. data/lib/shotstack/models/generated_asset_response_attributes.rb +376 -0
  39. data/lib/shotstack/models/generated_asset_response_data.rb +256 -0
  40. data/lib/shotstack/models/google_cloud_storage_destination.rb +232 -0
  41. data/lib/shotstack/models/google_cloud_storage_destination_options.rb +243 -0
  42. data/lib/shotstack/models/google_drive_destination.rb +239 -0
  43. data/lib/shotstack/models/google_drive_destination_options.rb +233 -0
  44. data/lib/shotstack/models/hey_gen_generated_asset.rb +273 -0
  45. data/lib/shotstack/models/hey_gen_generated_asset_options.rb +54 -0
  46. data/lib/shotstack/models/hey_gen_text_to_avatar_options.rb +396 -0
  47. data/lib/shotstack/models/html_asset.rb +20 -26
  48. data/lib/shotstack/models/image_asset.rb +18 -20
  49. data/lib/shotstack/models/ingest_error_response.rb +225 -0
  50. data/lib/shotstack/models/ingest_error_response_data.rb +257 -0
  51. data/lib/shotstack/models/luma_asset.rb +18 -20
  52. data/lib/shotstack/models/merge_field.rb +20 -20
  53. data/lib/shotstack/models/mux_destination.rb +18 -22
  54. data/lib/shotstack/models/mux_destination_options.rb +50 -25
  55. data/lib/shotstack/models/offset.rb +46 -46
  56. data/lib/shotstack/models/open_ai_generated_asset.rb +273 -0
  57. data/lib/shotstack/models/open_ai_generated_asset_options.rb +54 -0
  58. data/lib/shotstack/models/open_ai_text_generator_options.rb +313 -0
  59. data/lib/shotstack/models/output.rb +40 -35
  60. data/lib/shotstack/models/outputs.rb +227 -0
  61. data/lib/shotstack/models/outputs_response.rb +218 -0
  62. data/lib/shotstack/models/poster.rb +18 -20
  63. data/lib/shotstack/models/probe_response.rb +22 -20
  64. data/lib/shotstack/models/queued_response.rb +22 -20
  65. data/lib/shotstack/models/queued_response_data.rb +20 -20
  66. data/lib/shotstack/models/queued_source_response.rb +222 -0
  67. data/lib/shotstack/models/queued_source_response_data.rb +240 -0
  68. data/lib/shotstack/models/range.rb +26 -22
  69. data/lib/shotstack/models/render_response.rb +22 -20
  70. data/lib/shotstack/models/render_response_data.rb +24 -35
  71. data/lib/shotstack/models/rendition.rb +429 -0
  72. data/lib/shotstack/models/rendition_response_attributes.rb +336 -0
  73. data/lib/shotstack/models/rotate_transformation.rb +16 -22
  74. data/lib/shotstack/models/s3_destination.rb +232 -0
  75. data/lib/shotstack/models/s3_destination_options.rb +270 -0
  76. data/lib/shotstack/models/shotstack_destination.rb +19 -25
  77. data/lib/shotstack/models/shotstack_generated_asset.rb +273 -0
  78. data/lib/shotstack/models/shotstack_generated_asset_options.rb +60 -0
  79. data/lib/shotstack/models/shotstack_image_to_video_options.rb +298 -0
  80. data/lib/shotstack/models/shotstack_text_generator_options.rb +274 -0
  81. data/lib/shotstack/models/shotstack_text_to_image_options.rb +308 -0
  82. data/lib/shotstack/models/shotstack_text_to_speech_options.rb +339 -0
  83. data/lib/shotstack/models/size.rb +39 -35
  84. data/lib/shotstack/models/skew_transformation.rb +16 -24
  85. data/lib/shotstack/models/soundtrack.rb +18 -22
  86. data/lib/shotstack/models/source.rb +244 -0
  87. data/lib/shotstack/models/source_list_response.rb +225 -0
  88. data/lib/shotstack/models/source_response.rb +222 -0
  89. data/lib/shotstack/models/source_response_attributes.rb +373 -0
  90. data/lib/shotstack/models/source_response_data.rb +256 -0
  91. data/lib/shotstack/models/speed.rb +254 -0
  92. data/lib/shotstack/models/stability_ai_generated_asset.rb +273 -0
  93. data/lib/shotstack/models/stability_ai_generated_asset_options.rb +54 -0
  94. data/lib/shotstack/models/stability_ai_text_to_image_options.rb +390 -0
  95. data/lib/shotstack/models/template.rb +18 -20
  96. data/lib/shotstack/models/template_data_response.rb +24 -22
  97. data/lib/shotstack/models/template_data_response_data.rb +25 -22
  98. data/lib/shotstack/models/template_list_response.rb +24 -22
  99. data/lib/shotstack/models/template_list_response_data.rb +20 -20
  100. data/lib/shotstack/models/template_list_response_item.rb +20 -30
  101. data/lib/shotstack/models/template_render.rb +19 -21
  102. data/lib/shotstack/models/template_response.rb +23 -21
  103. data/lib/shotstack/models/template_response_data.rb +20 -20
  104. data/lib/shotstack/models/thumbnail.rb +20 -20
  105. data/lib/shotstack/models/timeline.rb +19 -25
  106. data/lib/shotstack/models/title_asset.rb +19 -27
  107. data/lib/shotstack/models/track.rb +18 -20
  108. data/lib/shotstack/models/transcription.rb +250 -0
  109. data/lib/shotstack/models/transfer.rb +259 -0
  110. data/lib/shotstack/models/transfer_response.rb +222 -0
  111. data/lib/shotstack/models/transfer_response_attributes.rb +280 -0
  112. data/lib/shotstack/models/transfer_response_data.rb +225 -0
  113. data/lib/shotstack/models/transformation.rb +16 -20
  114. data/lib/shotstack/models/transition.rb +16 -20
  115. data/lib/shotstack/models/upload_response.rb +222 -0
  116. data/lib/shotstack/models/upload_response_attributes.rb +257 -0
  117. data/lib/shotstack/models/upload_response_data.rb +256 -0
  118. data/lib/shotstack/models/video_asset.rb +102 -22
  119. data/lib/shotstack/version.rb +3 -3
  120. data/lib/shotstack.rb +63 -2
  121. data/shotstack.gemspec +8 -8
  122. metadata +80 -24
@@ -1,12 +1,12 @@
1
1
  =begin
2
2
  #Shotstack
3
3
 
4
- #Shotstack is a video, image and audio editing service that allows for the automated generation of videos, images and audio using JSON and a RESTful API. You arrange and configure an edit and POST it to the API which will render your media and provide a file location when complete. For more details visit [shotstack.io](https://shotstack.io) or checkout our [getting started](https://shotstack.io/docs/guide/) documentation. There are two main API's, one for editing and generating assets (Edit API) and one for managing hosted assets (Serve API). The Edit API base URL is: <b>https://api.shotstack.io/{version}</b> The Serve API base URL is: <b>https://api.shotstack.io/serve/{version}</b>
4
+ # Official Ruby SDK for the Shotstack Cloud Video Editing API
5
5
 
6
6
  The version of the OpenAPI document: v1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -14,260 +14,94 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Shotstack
17
- # A destination is a location where output files can be sent to for serving or hosting. By default all rendered assets are automatically sent to the [Shotstack hosting destination](https://shotstack.io/docs/guide/serving-assets/hosting). You can add other destinations to send assets to. The following destinations are available: <ul> <li><a href=\"#tocs_shotstackdestination\">DestinationShotstack</a></li> <li><a href=\"#tocs_muxdestination\">DestinationMux</a></li> </ul>
18
- class Destinations
19
- # The destination to send rendered assets to - set to `mux` for Mux.
20
- attr_accessor :provider
21
-
22
- # Set to `true` to opt-out from the Shotstack hosting and CDN service. All files must be downloaded within 24 hours of rendering.
23
- attr_accessor :exclude
24
-
25
- attr_accessor :options
26
-
27
- # Attribute mapping from ruby-style variable name to JSON key.
28
- def self.attribute_map
29
- {
30
- :'provider' => :'provider',
31
- :'exclude' => :'exclude',
32
- :'options' => :'options'
33
- }
34
- end
35
-
36
- # Returns all the JSON keys this model knows about
37
- def self.acceptable_attributes
38
- attribute_map.values
39
- end
40
-
41
- # Attribute type mapping.
42
- def self.openapi_types
43
- {
44
- :'provider' => :'String',
45
- :'exclude' => :'Boolean',
46
- :'options' => :'MuxDestinationOptions'
47
- }
48
- end
49
-
50
- # List of attributes with nullable: true
51
- def self.openapi_nullable
52
- Set.new([
53
- ])
54
- end
55
-
56
- # List of class defined in anyOf (OpenAPI v3)
57
- def self.openapi_any_of
58
- [
59
- :'MuxDestination',
60
- :'ShotstackDestination'
61
- ]
62
- end
63
-
64
- # discriminator's property name in OpenAPI v3
65
- def self.openapi_discriminator_name
66
- :'destinations'
67
- end
68
-
69
- # Initializes the object
70
- # @param [Hash] attributes Model attributes in the form of hash
71
- def initialize(attributes = {})
72
- if (!attributes.is_a?(Hash))
73
- fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Destinations` initialize method"
17
+ # A destination is a location where assets can be sent to for serving or hosting. Videos, images and audio files that are rendered by the [Edit API](#shotstack-edit) and [source](#tocs_source) and [rendition](#tocs_rendition) files generated by the [Ingest API](#shotstack-ingest) can be sent to destinations. You can also fetch a file from any public URL and [transfer](#transfer-asset) it to a destination. A file can be sent to one or more destinations including 3rd party destinations. By default all ingested and generated assets are automatically sent to the [Shotstack hosting destination](https://shotstack.io/docs/guide/serving-assets/hosting/). You can [opt-out](https://shotstack.io/docs/guide/serving-assets/self-host/) from by setting the Shotstack destination **exclude** property to **true**. The following destinations are available: <ul> <li><a href=\"#tocs_shotstackdestination\">ShotstackDestination</a></li> <li><a href=\"#tocs_muxdestination\">MuxDestination</a></li> <li><a href=\"#tocs_s3destination\">S3Destination</a></li> <li><a href=\"#tocs_googlecloudstoragedestination\">GoogleCloudStorageDestination</a></li> </ul>
18
+ module Destinations
19
+ class << self
20
+ # List of class defined in anyOf (OpenAPI v3)
21
+ def openapi_any_of
22
+ [
23
+ :'GoogleCloudStorageDestination',
24
+ :'MuxDestination',
25
+ :'S3Destination',
26
+ :'ShotstackDestination'
27
+ ]
74
28
  end
75
29
 
76
- # check to see if the attribute exists and convert string to symbol for hash key
77
- attributes = attributes.each_with_object({}) { |(k, v), h|
78
- if (!self.class.attribute_map.key?(k.to_sym))
79
- fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Destinations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
- end
81
- h[k.to_sym] = v
82
- }
83
-
84
- if attributes.key?(:'provider')
85
- self.provider = attributes[:'provider']
86
- else
87
- self.provider = 'mux'
88
- end
89
-
90
- if attributes.key?(:'exclude')
91
- self.exclude = attributes[:'exclude']
92
- else
93
- self.exclude = false
94
- end
95
-
96
- if attributes.key?(:'options')
97
- self.options = attributes[:'options']
98
- end
99
- end
100
-
101
- # Show invalid properties with the reasons. Usually used together with valid?
102
- # @return Array for valid properties with the reasons
103
- def list_invalid_properties
104
- invalid_properties = Array.new
105
- if @provider.nil?
106
- invalid_properties.push('invalid value for "provider", provider cannot be nil.')
107
- end
108
-
109
- invalid_properties
110
- end
111
-
112
- # Check to see if the all the properties in the model are valid
113
- # @return true if the model is valid
114
- def valid?
115
- return false if @provider.nil?
116
- _any_of_found = false
117
- self.class.openapi_any_of.each do |_class|
118
- _any_of = Shotstack.const_get(_class).build_from_hash(self.to_hash)
119
- if _any_of.valid?
120
- _any_of_found = true
30
+ # Builds the object
31
+ # @param [Mixed] Data to be matched against the list of anyOf items
32
+ # @return [Object] Returns the model or the data itself
33
+ def build(data)
34
+ # Go through the list of anyOf items and attempt to identify the appropriate one.
35
+ # Note:
36
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
37
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
38
+ # - TODO: scalar values are de facto behaving as if they were nullable.
39
+ # - TODO: logging when debugging is set.
40
+ openapi_any_of.each do |klass|
41
+ begin
42
+ next if klass == :AnyType # "nullable: true"
43
+ typed_data = find_and_cast_into_type(klass, data)
44
+ return typed_data if typed_data
45
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
46
+ end
121
47
  end
122
- end
123
48
 
124
- if !_any_of_found
125
- return false
49
+ openapi_any_of.include?(:AnyType) ? data : nil
126
50
  end
127
51
 
128
- true
129
- end
130
-
131
- # Checks equality by comparing each attribute.
132
- # @param [Object] Object to be compared
133
- def ==(o)
134
- return true if self.equal?(o)
135
- self.class == o.class &&
136
- provider == o.provider &&
137
- exclude == o.exclude &&
138
- options == o.options
139
- end
140
-
141
- # @see the `==` method
142
- # @param [Object] Object to be compared
143
- def eql?(o)
144
- self == o
145
- end
146
-
147
- # Calculates hash code according to all attributes.
148
- # @return [Integer] Hash code
149
- def hash
150
- [provider, exclude, options].hash
151
- end
152
-
153
- # Builds the object from hash
154
- # @param [Hash] attributes Model attributes in the form of hash
155
- # @return [Object] Returns the model itself
156
- def self.build_from_hash(attributes)
157
- new.build_from_hash(attributes)
158
- end
159
-
160
- # Builds the object from hash
161
- # @param [Hash] attributes Model attributes in the form of hash
162
- # @return [Object] Returns the model itself
163
- def build_from_hash(attributes)
164
- return nil unless attributes.is_a?(Hash)
165
- self.class.openapi_types.each_pair do |key, type|
166
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
167
- self.send("#{key}=", nil)
168
- elsif type =~ /\AArray<(.*)>/i
169
- # check to ensure the input is an array given that the attribute
170
- # is documented as an array but the input is not
171
- if attributes[self.class.attribute_map[key]].is_a?(Array)
172
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
52
+ private
53
+
54
+ SchemaMismatchError = Class.new(StandardError)
55
+
56
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
57
+ def find_and_cast_into_type(klass, data)
58
+ return if data.nil?
59
+
60
+ case klass.to_s
61
+ when 'Boolean'
62
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
63
+ when 'Float'
64
+ return data if data.instance_of?(Float)
65
+ when 'Integer'
66
+ return data if data.instance_of?(Integer)
67
+ when 'Time'
68
+ return Time.parse(data)
69
+ when 'Date'
70
+ return Date.parse(data)
71
+ when 'String'
72
+ return data if data.instance_of?(String)
73
+ when 'Object' # "type: object"
74
+ return data if data.instance_of?(Hash)
75
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
76
+ if data.instance_of?(Array)
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
173
79
  end
174
- elsif !attributes[self.class.attribute_map[key]].nil?
175
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
- end
177
- end
178
-
179
- self
180
- end
181
-
182
- # Deserializes the data based on type
183
- # @param string type Data type
184
- # @param string value Value to be deserialized
185
- # @return [Object] Deserialized data
186
- def _deserialize(type, value)
187
- case type.to_sym
188
- when :Time
189
- Time.parse(value)
190
- when :Date
191
- Date.parse(value)
192
- when :String
193
- value.to_s
194
- when :Integer
195
- value.to_i
196
- when :Float
197
- value.to_f
198
- when :Boolean
199
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
- true
201
- else
202
- false
203
- end
204
- when :Object
205
- # generic object (usually a Hash), return directly
206
- value
207
- when /\AArray<(?<inner_type>.+)>\z/
208
- inner_type = Regexp.last_match[:inner_type]
209
- value.map { |v| _deserialize(inner_type, v) }
210
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
- k_type = Regexp.last_match[:k_type]
212
- v_type = Regexp.last_match[:v_type]
213
- {}.tap do |hash|
214
- value.each do |k, v|
215
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
80
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
81
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
82
+ sub_type = Regexp.last_match[:sub_type]
83
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
84
+ end
85
+ else # model
86
+ const = Shotstack.const_get(klass)
87
+ if const
88
+ if const.respond_to?(:openapi_any_of) # nested anyOf model
89
+ model = const.build(data)
90
+ return model if model
91
+ else
92
+ # raise if data contains keys that are not known to the model
93
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
94
+ model = const.build_from_hash(data)
95
+ return model if model
96
+ end
216
97
  end
217
- end
218
- else # model
219
- # models (e.g. Pet) or oneOf
220
- klass = Shotstack.const_get(type)
221
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
- end
223
- end
224
-
225
- # Returns the string representation of the object
226
- # @return [String] String presentation of the object
227
- def to_s
228
- to_hash.to_s
229
- end
230
-
231
- # to_body is an alias to to_hash (backward compatibility)
232
- # @return [Hash] Returns the object in the form of hash
233
- def to_body
234
- to_hash
235
- end
236
-
237
- # Returns the object in the form of hash
238
- # @return [Hash] Returns the object in the form of hash
239
- def to_hash
240
- hash = {}
241
- self.class.attribute_map.each_pair do |attr, param|
242
- value = self.send(attr)
243
- if value.nil?
244
- is_nullable = self.class.openapi_nullable.include?(attr)
245
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
98
  end
247
99
 
248
- hash[param] = _to_hash(value)
100
+ raise # if no match by now, raise
101
+ rescue
102
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
249
103
  end
250
- hash
251
104
  end
252
-
253
- # Outputs non-array value in the form of hash
254
- # For object, use to_hash. Otherwise, just return the value
255
- # @param [Object] value Any valid value
256
- # @return [Hash] Returns the value in the form of hash
257
- def _to_hash(value)
258
- if value.is_a?(Array)
259
- value.compact.map { |v| _to_hash(v) }
260
- elsif value.is_a?(Hash)
261
- {}.tap do |hash|
262
- value.each { |k, v| hash[k] = _to_hash(v) }
263
- end
264
- elsif value.respond_to? :to_hash
265
- value.to_hash
266
- else
267
- value
268
- end
269
- end
270
-
271
105
  end
272
106
 
273
107
  end
@@ -0,0 +1,273 @@
1
+ =begin
2
+ #Shotstack
3
+
4
+ # Official Ruby SDK for the Shotstack Cloud Video Editing API
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Shotstack
17
+ # Generate assets using D-ID. D-ID provide a text-to-avatar service. The D-ID provider works on a bring-your-own-key basis, credentials are required and must be added via the [dashboard](https://dashboard.shotstack.io/integrations/d-id), not in the request.
18
+ class DIDGeneratedAsset
19
+ # The name of the provider - set to `d-id` for D-ID.
20
+ attr_accessor :provider
21
+
22
+ attr_accessor :options
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'provider' => :'provider',
50
+ :'options' => :'options'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'provider' => :'String',
63
+ :'options' => :'DIDGeneratedAssetOptions'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::DIDGeneratedAsset` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::DIDGeneratedAsset`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'provider')
89
+ self.provider = attributes[:'provider']
90
+ else
91
+ self.provider = 'd-id'
92
+ end
93
+
94
+ if attributes.key?(:'options')
95
+ self.options = attributes[:'options']
96
+ else
97
+ self.options = nil
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
105
+ invalid_properties = Array.new
106
+ if @provider.nil?
107
+ invalid_properties.push('invalid value for "provider", provider cannot be nil.')
108
+ end
109
+
110
+ if @options.nil?
111
+ invalid_properties.push('invalid value for "options", options cannot be nil.')
112
+ end
113
+
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ warn '[DEPRECATED] the `valid?` method is obsolete'
121
+ return false if @provider.nil?
122
+ provider_validator = EnumAttributeValidator.new('String', ["d-id"])
123
+ return false unless provider_validator.valid?(@provider)
124
+ return false if @options.nil?
125
+ true
126
+ end
127
+
128
+ # Custom attribute writer method checking allowed values (enum).
129
+ # @param [Object] provider Object to be assigned
130
+ def provider=(provider)
131
+ validator = EnumAttributeValidator.new('String', ["d-id"])
132
+ unless validator.valid?(provider)
133
+ fail ArgumentError, "invalid value for \"provider\", must be one of #{validator.allowable_values}."
134
+ end
135
+ @provider = provider
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ provider == o.provider &&
144
+ options == o.options
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [provider, options].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ attributes = attributes.transform_keys(&:to_sym)
165
+ transformed_hash = {}
166
+ openapi_types.each_pair do |key, type|
167
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = nil
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[attribute_map[key]].is_a?(Array)
173
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
174
+ end
175
+ elsif !attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
177
+ end
178
+ end
179
+ new(transformed_hash)
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def self._deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = Shotstack.const_get(type)
221
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ end
@@ -0,0 +1,54 @@
1
+ =begin
2
+ #Shotstack
3
+
4
+ # Official Ruby SDK for the Shotstack Cloud Video Editing API
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Shotstack
17
+ # Generate assets using the third party D-ID provider AI services. The following AI generation services are available: <ul> <li><a href=\"#tocs_didtexttoavataroptions\">DidTextToAvatarOptions</a></li> </ul>
18
+ module DIDGeneratedAssetOptions
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'DIDTextToAvatarOptions'
24
+ ]
25
+ end
26
+
27
+ # Discriminator's property name (OpenAPI v3)
28
+ def openapi_discriminator_name
29
+ :'type'
30
+ end
31
+
32
+ # Discriminator's mapping (OpenAPI v3)
33
+ def openapi_discriminator_mapping
34
+ {
35
+ :'text-to-avatar' => :'DIDTextToAvatarOptions'
36
+ }
37
+ end
38
+
39
+ # Builds the object
40
+ # @param [Mixed] Data to be matched against the list of oneOf items
41
+ # @return [Object] Returns the model or the data itself
42
+ def build(data)
43
+ discriminator_value = data[openapi_discriminator_name]
44
+ return nil if discriminator_value.nil?
45
+
46
+ klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
47
+ return nil unless klass
48
+
49
+ Shotstack.const_get(klass).build_from_hash(data)
50
+ end
51
+ end
52
+ end
53
+
54
+ end