shotstack 0.2.2 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/Rakefile +10 -0
  4. data/lib/shotstack/api/create_api.rb +158 -0
  5. data/lib/shotstack/api/edit_api.rb +20 -20
  6. data/lib/shotstack/api/ingest_api.rb +338 -0
  7. data/lib/shotstack/api/serve_api.rb +76 -8
  8. data/lib/shotstack/api_client.rb +28 -24
  9. data/lib/shotstack/api_error.rb +3 -2
  10. data/lib/shotstack/configuration.rb +55 -9
  11. data/lib/shotstack/models/asset.rb +3 -3
  12. data/lib/shotstack/models/asset_render_response.rb +18 -20
  13. data/lib/shotstack/models/asset_response.rb +18 -20
  14. data/lib/shotstack/models/asset_response_attributes.rb +23 -21
  15. data/lib/shotstack/models/asset_response_data.rb +20 -20
  16. data/lib/shotstack/models/audio_asset.rb +57 -21
  17. data/lib/shotstack/models/audio_enhancement.rb +43 -0
  18. data/lib/shotstack/models/clip.rb +27 -25
  19. data/lib/shotstack/models/crop.rb +40 -28
  20. data/lib/shotstack/models/destinations.rb +78 -243
  21. data/lib/shotstack/models/did_generated_asset.rb +273 -0
  22. data/lib/shotstack/models/did_generated_asset_options.rb +54 -0
  23. data/lib/shotstack/models/did_text_to_avatar_options.rb +313 -0
  24. data/lib/shotstack/models/dolby_enhancement.rb +239 -0
  25. data/lib/shotstack/models/dolby_enhancement_options.rb +257 -0
  26. data/lib/shotstack/models/edit.rb +22 -22
  27. data/lib/shotstack/models/eleven_labs_generated_asset.rb +273 -0
  28. data/lib/shotstack/models/eleven_labs_generated_asset_options.rb +54 -0
  29. data/lib/shotstack/models/eleven_labs_text_to_speech_options.rb +303 -0
  30. data/lib/shotstack/models/enhancements.rb +215 -0
  31. data/lib/shotstack/models/flip_transformation.rb +16 -20
  32. data/lib/shotstack/models/font.rb +18 -20
  33. data/lib/shotstack/models/generated_asset.rb +48 -0
  34. data/lib/shotstack/models/generated_asset_error_response.rb +225 -0
  35. data/lib/shotstack/models/generated_asset_error_response_data.rb +257 -0
  36. data/lib/shotstack/models/generated_asset_response.rb +222 -0
  37. data/lib/shotstack/models/generated_asset_response_attributes.rb +376 -0
  38. data/lib/shotstack/models/generated_asset_response_data.rb +256 -0
  39. data/lib/shotstack/models/google_cloud_storage_destination.rb +232 -0
  40. data/lib/shotstack/models/google_cloud_storage_destination_options.rb +243 -0
  41. data/lib/shotstack/models/google_drive_destination.rb +239 -0
  42. data/lib/shotstack/models/google_drive_destination_options.rb +233 -0
  43. data/lib/shotstack/models/hey_gen_generated_asset.rb +273 -0
  44. data/lib/shotstack/models/hey_gen_generated_asset_options.rb +54 -0
  45. data/lib/shotstack/models/hey_gen_text_to_avatar_options.rb +396 -0
  46. data/lib/shotstack/models/html_asset.rb +20 -22
  47. data/lib/shotstack/models/image_asset.rb +18 -20
  48. data/lib/shotstack/models/ingest_error_response.rb +225 -0
  49. data/lib/shotstack/models/ingest_error_response_data.rb +257 -0
  50. data/lib/shotstack/models/luma_asset.rb +18 -20
  51. data/lib/shotstack/models/merge_field.rb +20 -20
  52. data/lib/shotstack/models/mux_destination.rb +18 -22
  53. data/lib/shotstack/models/mux_destination_options.rb +50 -25
  54. data/lib/shotstack/models/offset.rb +28 -24
  55. data/lib/shotstack/models/open_ai_generated_asset.rb +273 -0
  56. data/lib/shotstack/models/open_ai_generated_asset_options.rb +54 -0
  57. data/lib/shotstack/models/open_ai_text_generator_options.rb +313 -0
  58. data/lib/shotstack/models/output.rb +27 -29
  59. data/lib/shotstack/models/outputs.rb +227 -0
  60. data/lib/shotstack/models/outputs_response.rb +218 -0
  61. data/lib/shotstack/models/poster.rb +18 -20
  62. data/lib/shotstack/models/probe_response.rb +22 -20
  63. data/lib/shotstack/models/queued_response.rb +22 -20
  64. data/lib/shotstack/models/queued_response_data.rb +20 -20
  65. data/lib/shotstack/models/queued_source_response.rb +222 -0
  66. data/lib/shotstack/models/queued_source_response_data.rb +240 -0
  67. data/lib/shotstack/models/range.rb +26 -22
  68. data/lib/shotstack/models/render_response.rb +22 -20
  69. data/lib/shotstack/models/render_response_data.rb +22 -20
  70. data/lib/shotstack/models/rendition.rb +429 -0
  71. data/lib/shotstack/models/rendition_response_attributes.rb +336 -0
  72. data/lib/shotstack/models/rotate_transformation.rb +16 -20
  73. data/lib/shotstack/models/s3_destination.rb +18 -22
  74. data/lib/shotstack/models/s3_destination_options.rb +21 -21
  75. data/lib/shotstack/models/shotstack_destination.rb +19 -23
  76. data/lib/shotstack/models/shotstack_generated_asset.rb +273 -0
  77. data/lib/shotstack/models/shotstack_generated_asset_options.rb +60 -0
  78. data/lib/shotstack/models/shotstack_image_to_video_options.rb +298 -0
  79. data/lib/shotstack/models/shotstack_text_generator_options.rb +274 -0
  80. data/lib/shotstack/models/shotstack_text_to_image_options.rb +308 -0
  81. data/lib/shotstack/models/shotstack_text_to_speech_options.rb +339 -0
  82. data/lib/shotstack/models/size.rb +36 -32
  83. data/lib/shotstack/models/skew_transformation.rb +16 -20
  84. data/lib/shotstack/models/soundtrack.rb +18 -20
  85. data/lib/shotstack/models/source.rb +244 -0
  86. data/lib/shotstack/models/source_list_response.rb +225 -0
  87. data/lib/shotstack/models/source_response.rb +222 -0
  88. data/lib/shotstack/models/source_response_attributes.rb +373 -0
  89. data/lib/shotstack/models/source_response_data.rb +256 -0
  90. data/lib/shotstack/models/speed.rb +254 -0
  91. data/lib/shotstack/models/stability_ai_generated_asset.rb +273 -0
  92. data/lib/shotstack/models/stability_ai_generated_asset_options.rb +54 -0
  93. data/lib/shotstack/models/stability_ai_text_to_image_options.rb +390 -0
  94. data/lib/shotstack/models/template.rb +18 -20
  95. data/lib/shotstack/models/template_data_response.rb +23 -21
  96. data/lib/shotstack/models/template_data_response_data.rb +24 -20
  97. data/lib/shotstack/models/template_list_response.rb +24 -22
  98. data/lib/shotstack/models/template_list_response_data.rb +20 -20
  99. data/lib/shotstack/models/template_list_response_item.rb +20 -20
  100. data/lib/shotstack/models/template_render.rb +18 -20
  101. data/lib/shotstack/models/template_response.rb +22 -20
  102. data/lib/shotstack/models/template_response_data.rb +20 -20
  103. data/lib/shotstack/models/thumbnail.rb +20 -20
  104. data/lib/shotstack/models/timeline.rb +19 -21
  105. data/lib/shotstack/models/title_asset.rb +18 -20
  106. data/lib/shotstack/models/track.rb +18 -20
  107. data/lib/shotstack/models/transcription.rb +250 -0
  108. data/lib/shotstack/models/transfer.rb +259 -0
  109. data/lib/shotstack/models/transfer_response.rb +222 -0
  110. data/lib/shotstack/models/transfer_response_attributes.rb +280 -0
  111. data/lib/shotstack/models/transfer_response_data.rb +225 -0
  112. data/lib/shotstack/models/transformation.rb +16 -20
  113. data/lib/shotstack/models/transition.rb +16 -20
  114. data/lib/shotstack/models/upload_response.rb +222 -0
  115. data/lib/shotstack/models/upload_response_attributes.rb +257 -0
  116. data/lib/shotstack/models/upload_response_data.rb +256 -0
  117. data/lib/shotstack/models/video_asset.rb +57 -21
  118. data/lib/shotstack/version.rb +3 -3
  119. data/lib/shotstack.rb +61 -2
  120. data/shotstack.gemspec +8 -8
  121. metadata +69 -16
@@ -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,259 +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\">ShotstackDestination</a></li> <li><a href=\"#tocs_muxdestination\">MuxDestination</a></li> <li><a href=\"#tocs_s3destination\">S3Destination</a></li> </ul>
18
- class Destinations
19
- # The destination to send rendered assets to - set to `s3` for S3.
20
- attr_accessor :provider
21
-
22
- # Set to `true` to [opt-out](https://shotstack.io/docs/guide/serving-assets/self-host) 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' => :'S3DestinationOptions'
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
- :'S3Destination',
61
- :'ShotstackDestination'
62
- ]
63
- end
64
-
65
- # discriminator's property name in OpenAPI v3
66
- def self.openapi_discriminator_name
67
- :'destinations'
68
- end
69
-
70
- # Initializes the object
71
- # @param [Hash] attributes Model attributes in the form of hash
72
- def initialize(attributes = {})
73
- if (!attributes.is_a?(Hash))
74
- 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
+ ]
75
28
  end
76
29
 
77
- # check to see if the attribute exists and convert string to symbol for hash key
78
- attributes = attributes.each_with_object({}) { |(k, v), h|
79
- if (!self.class.attribute_map.key?(k.to_sym))
80
- 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
81
- end
82
- h[k.to_sym] = v
83
- }
84
-
85
- if attributes.key?(:'provider')
86
- self.provider = attributes[:'provider']
87
- else
88
- self.provider = 's3'
89
- end
90
-
91
- if attributes.key?(:'exclude')
92
- self.exclude = attributes[:'exclude']
93
- end
94
-
95
- if attributes.key?(:'options')
96
- self.options = attributes[:'options']
97
- end
98
- end
99
-
100
- # Show invalid properties with the reasons. Usually used together with valid?
101
- # @return Array for valid properties with the reasons
102
- def list_invalid_properties
103
- invalid_properties = Array.new
104
- if @provider.nil?
105
- invalid_properties.push('invalid value for "provider", provider cannot be nil.')
106
- end
107
-
108
- invalid_properties
109
- end
110
-
111
- # Check to see if the all the properties in the model are valid
112
- # @return true if the model is valid
113
- def valid?
114
- return false if @provider.nil?
115
- _any_of_found = false
116
- self.class.openapi_any_of.each do |_class|
117
- _any_of = Shotstack.const_get(_class).build_from_hash(self.to_hash)
118
- if _any_of.valid?
119
- _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
120
47
  end
121
- end
122
48
 
123
- if !_any_of_found
124
- return false
49
+ openapi_any_of.include?(:AnyType) ? data : nil
125
50
  end
126
51
 
127
- true
128
- end
129
-
130
- # Checks equality by comparing each attribute.
131
- # @param [Object] Object to be compared
132
- def ==(o)
133
- return true if self.equal?(o)
134
- self.class == o.class &&
135
- provider == o.provider &&
136
- exclude == o.exclude &&
137
- options == o.options
138
- end
139
-
140
- # @see the `==` method
141
- # @param [Object] Object to be compared
142
- def eql?(o)
143
- self == o
144
- end
145
-
146
- # Calculates hash code according to all attributes.
147
- # @return [Integer] Hash code
148
- def hash
149
- [provider, exclude, options].hash
150
- end
151
-
152
- # Builds the object from hash
153
- # @param [Hash] attributes Model attributes in the form of hash
154
- # @return [Object] Returns the model itself
155
- def self.build_from_hash(attributes)
156
- new.build_from_hash(attributes)
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 build_from_hash(attributes)
163
- return nil unless attributes.is_a?(Hash)
164
- self.class.openapi_types.each_pair do |key, type|
165
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
166
- self.send("#{key}=", nil)
167
- elsif type =~ /\AArray<(.*)>/i
168
- # check to ensure the input is an array given that the attribute
169
- # is documented as an array but the input is not
170
- if attributes[self.class.attribute_map[key]].is_a?(Array)
171
- 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) }
172
79
  end
173
- elsif !attributes[self.class.attribute_map[key]].nil?
174
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
175
- end
176
- end
177
-
178
- self
179
- end
180
-
181
- # Deserializes the data based on type
182
- # @param string type Data type
183
- # @param string value Value to be deserialized
184
- # @return [Object] Deserialized data
185
- def _deserialize(type, value)
186
- case type.to_sym
187
- when :Time
188
- Time.parse(value)
189
- when :Date
190
- Date.parse(value)
191
- when :String
192
- value.to_s
193
- when :Integer
194
- value.to_i
195
- when :Float
196
- value.to_f
197
- when :Boolean
198
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
- true
200
- else
201
- false
202
- end
203
- when :Object
204
- # generic object (usually a Hash), return directly
205
- value
206
- when /\AArray<(?<inner_type>.+)>\z/
207
- inner_type = Regexp.last_match[:inner_type]
208
- value.map { |v| _deserialize(inner_type, v) }
209
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
210
- k_type = Regexp.last_match[:k_type]
211
- v_type = Regexp.last_match[:v_type]
212
- {}.tap do |hash|
213
- value.each do |k, v|
214
- 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
215
97
  end
216
- end
217
- else # model
218
- # models (e.g. Pet) or oneOf
219
- klass = Shotstack.const_get(type)
220
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
- end
222
- end
223
-
224
- # Returns the string representation of the object
225
- # @return [String] String presentation of the object
226
- def to_s
227
- to_hash.to_s
228
- end
229
-
230
- # to_body is an alias to to_hash (backward compatibility)
231
- # @return [Hash] Returns the object in the form of hash
232
- def to_body
233
- to_hash
234
- end
235
-
236
- # Returns the object in the form of hash
237
- # @return [Hash] Returns the object in the form of hash
238
- def to_hash
239
- hash = {}
240
- self.class.attribute_map.each_pair do |attr, param|
241
- value = self.send(attr)
242
- if value.nil?
243
- is_nullable = self.class.openapi_nullable.include?(attr)
244
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
98
  end
246
99
 
247
- 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"
248
103
  end
249
- hash
250
104
  end
251
-
252
- # Outputs non-array value in the form of hash
253
- # For object, use to_hash. Otherwise, just return the value
254
- # @param [Object] value Any valid value
255
- # @return [Hash] Returns the value in the form of hash
256
- def _to_hash(value)
257
- if value.is_a?(Array)
258
- value.compact.map { |v| _to_hash(v) }
259
- elsif value.is_a?(Hash)
260
- {}.tap do |hash|
261
- value.each { |k, v| hash[k] = _to_hash(v) }
262
- end
263
- elsif value.respond_to? :to_hash
264
- value.to_hash
265
- else
266
- value
267
- end
268
- end
269
-
270
105
  end
271
106
 
272
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