shotstack 0.1.4 → 0.1.8

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shotstack.rb +12 -2
  3. data/lib/shotstack/api/edit_api.rb +155 -0
  4. data/lib/shotstack/api/endpoints_api.rb +10 -8
  5. data/lib/shotstack/api/serve_api.rb +224 -0
  6. data/lib/shotstack/api_client.rb +50 -46
  7. data/lib/shotstack/api_error.rb +2 -2
  8. data/lib/shotstack/configuration.rb +50 -9
  9. data/lib/shotstack/models/asset_render_response.rb +222 -0
  10. data/lib/shotstack/models/asset_response.rb +219 -0
  11. data/lib/shotstack/models/asset_response_attributes.rb +334 -0
  12. data/lib/shotstack/models/asset_response_data.rb +229 -0
  13. data/lib/shotstack/models/audio_asset.rb +68 -12
  14. data/lib/shotstack/models/clip.rb +23 -11
  15. data/lib/shotstack/models/crop.rb +346 -0
  16. data/lib/shotstack/models/destinations.rb +17 -0
  17. data/lib/shotstack/models/edit.rb +72 -14
  18. data/lib/shotstack/models/font.rb +21 -9
  19. data/lib/shotstack/models/html_asset.rb +26 -14
  20. data/lib/shotstack/models/image_asset.rb +34 -13
  21. data/lib/shotstack/models/luma_asset.rb +24 -12
  22. data/lib/shotstack/models/offset.rb +20 -8
  23. data/lib/shotstack/models/output.rb +111 -26
  24. data/lib/shotstack/models/poster.rb +20 -8
  25. data/lib/shotstack/models/queued_response.rb +21 -8
  26. data/lib/shotstack/models/queued_response_data.rb +21 -8
  27. data/lib/shotstack/models/range.rb +260 -0
  28. data/lib/shotstack/models/render_response.rb +21 -8
  29. data/lib/shotstack/models/render_response_data.rb +25 -12
  30. data/lib/shotstack/models/shotstack_destination.rb +240 -0
  31. data/lib/shotstack/models/size.rb +278 -0
  32. data/lib/shotstack/models/soundtrack.rb +20 -8
  33. data/lib/shotstack/models/thumbnail.rb +21 -9
  34. data/lib/shotstack/models/timeline.rb +37 -13
  35. data/lib/shotstack/models/title_asset.rb +20 -8
  36. data/lib/shotstack/models/track.rb +20 -8
  37. data/lib/shotstack/models/transition.rb +26 -14
  38. data/lib/shotstack/models/video_asset.rb +33 -12
  39. data/lib/shotstack/version.rb +3 -3
  40. data/shotstack.gemspec +4 -5
  41. metadata +22 -27
@@ -1,16 +1,17 @@
1
1
  =begin
2
2
  #Shotstack
3
3
 
4
- #The Shotstack API is a video editing service that allows for the automated creation of videos using JSON. You can configure an edit and POST it to the Shotstack API which will render your video and provide a file location when complete. For more details check https://shotstack.io
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.gitbook.io/docs/guides/getting-started) 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>
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: 4.2.1
9
+ OpenAPI Generator version: 5.0.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module Shotstack
16
17
  # Offsets the position of an asset horizontally or vertically by a relative distance.
@@ -29,6 +30,11 @@ module Shotstack
29
30
  }
30
31
  end
31
32
 
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
32
38
  # Attribute type mapping.
33
39
  def self.openapi_types
34
40
  {
@@ -166,7 +172,9 @@ module Shotstack
166
172
  def build_from_hash(attributes)
167
173
  return nil unless attributes.is_a?(Hash)
168
174
  self.class.openapi_types.each_pair do |key, type|
169
- if type =~ /\AArray<(.*)>/i
175
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
176
+ self.send("#{key}=", nil)
177
+ elsif type =~ /\AArray<(.*)>/i
170
178
  # check to ensure the input is an array given that the attribute
171
179
  # is documented as an array but the input is not
172
180
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -174,7 +182,7 @@ module Shotstack
174
182
  end
175
183
  elsif !attributes[self.class.attribute_map[key]].nil?
176
184
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
- end # or else data not found in attributes(hash), not an issue as the data can be optional
185
+ end
178
186
  end
179
187
 
180
188
  self
@@ -186,8 +194,8 @@ module Shotstack
186
194
  # @return [Object] Deserialized data
187
195
  def _deserialize(type, value)
188
196
  case type.to_sym
189
- when :DateTime
190
- DateTime.parse(value)
197
+ when :Time
198
+ Time.parse(value)
191
199
  when :Date
192
200
  Date.parse(value)
193
201
  when :String
@@ -217,7 +225,9 @@ module Shotstack
217
225
  end
218
226
  end
219
227
  else # model
220
- Shotstack.const_get(type).build_from_hash(value)
228
+ # models (e.g. Pet) or oneOf
229
+ klass = Shotstack.const_get(type)
230
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
231
  end
222
232
  end
223
233
 
@@ -243,7 +253,7 @@ module Shotstack
243
253
  is_nullable = self.class.openapi_nullable.include?(attr)
244
254
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
255
  end
246
-
256
+
247
257
  hash[param] = _to_hash(value)
248
258
  end
249
259
  hash
@@ -266,5 +276,7 @@ module Shotstack
266
276
  value
267
277
  end
268
278
  end
279
+
269
280
  end
281
+
270
282
  end
@@ -1,36 +1,50 @@
1
1
  =begin
2
2
  #Shotstack
3
3
 
4
- #The Shotstack API is a video editing service that allows for the automated creation of videos using JSON. You can configure an edit and POST it to the Shotstack API which will render your video and provide a file location when complete. For more details check https://shotstack.io
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.gitbook.io/docs/guides/getting-started) 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>
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: 4.2.1
9
+ OpenAPI Generator version: 5.0.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module Shotstack
16
- # The video output format.
17
+ # The output format, render range and type of media to generate.
17
18
  class Output
18
- # `mp4` video or animated `gif`
19
+ # The output format and type of media file to generate. <ul> <li>`mp4` - mp4 video file</li> <li>`gif` - animated gif</li> <li>`jpg` - jpg image file</li> <li>`png` - png image file</li> <li>`bmp` - bmp image file</li> <li>`mp3` - mp3 audio file (audio only)</li> </ul>
19
20
  attr_accessor :format
20
21
 
21
- # The output resolution of the video. <ul> <li>`preview` - 512px x 288px @ 15fps</li> <li>`mobile` - 640px x 360px @ 25fps</li> <li>`sd` - 1024px x 576px @ 25fps</li> <li>`hd` - 1280px x 720px @ 25fps</li> <li>`1080` - 1920px x 1080px @ 25fps</li> </ul>
22
+ # The output resolution of the video or image. <ul> <li>`preview` - 512px x 288px @ 15fps</li> <li>`mobile` - 640px x 360px @ 25fps</li> <li>`sd` - 1024px x 576px @ 25fps</li> <li>`hd` - 1280px x 720px @ 25fps</li> <li>`1080` - 1920px x 1080px @ 25fps</li> </ul>
22
23
  attr_accessor :resolution
23
24
 
24
- # The aspect ratio (shape) of the video. Useful for social media sites. Options are: <ul> <li>`16:9` - regular landscape/horizontal aspect ratio (default)</li> <li>`9:16` - vertical/portrait aspect ratio.</li> <li>`1:1` - square aspect ratio.</li> </ul>
25
+ # The aspect ratio (shape) of the video or image. Useful for social media output formats. Options are: <ul> <li>`16:9` - regular landscape/horizontal aspect ratio (default)</li> <li>`9:16` - vertical/portrait aspect ratio</li> <li>`1:1` - square aspect ratio</li> <li>`4:5` - short vertical/portrait aspect ratio</li> <li>`4:3` - legacy TV aspect ratio</li> </ul>
25
26
  attr_accessor :aspect_ratio
26
27
 
27
- # Override the resolution and scale the video to render at a different size. When using scaleTo the video should be edited at the resolution dimensions, i.e. use font sizes that look best at HD, then use scaleTo to output the video at SD and the text will be scaled to the correct size. This is useful if you want to create multiple video sizes. <ul> <li>`preview` - 512px x 288px @ 15fps</li> <li>`mobile` - 640px x 360px @ 25fps</li> <li>`sd` - 1024px x 576px @25fps</li> <li>`hd` - 1280px x 720px @25fps</li> <li>`1080` - 1920px x 1080px @25fps</li> </ul>
28
+ attr_accessor :size
29
+
30
+ # Override the default frames per second. Useful for when the source footage is recorded at 30fps, i.e. on mobile devices. Lower frame rates can be used to add cinematic quality (24fps) or to create smaller file size/faster render times or animated gifs (12 or 15fps). Default is 25fps. <ul> <li>`12` - 12fps</li> <li>`15` - 15fps</li> <li>`24` - 24fps</li> <li>`25` - 25fps</li> <li>`30` - 30fps</li> </ul>
31
+ attr_accessor :fps
32
+
33
+ # Override the resolution and scale the video or image to render at a different size. When using scaleTo the asset should be edited at the resolution dimensions, i.e. use font sizes that look best at HD, then use scaleTo to output the file at SD and the text will be scaled to the correct size. This is useful if you want to create multiple asset sizes. <ul> <li>`preview` - 512px x 288px @ 15fps</li> <li>`mobile` - 640px x 360px @ 25fps</li> <li>`sd` - 1024px x 576px @25fps</li> <li>`hd` - 1280px x 720px @25fps</li> <li>`1080` - 1920px x 1080px @25fps</li> </ul>
28
34
  attr_accessor :scale_to
29
35
 
36
+ # Adjust the output quality of the video, image or audio. Adjusting quality affects render speed, download speeds and storage requirements due to file size. The default `medium` provides the most optimized choice for all three factors. <ul> <li>`low` - slightly reduced quality, smaller file size</li> <li>`medium` - optimized quality, render speeds and file size</li> <li>`high` - slightly increased quality, larger file size</li> </ul>
37
+ attr_accessor :quality
38
+
39
+ attr_accessor :range
40
+
30
41
  attr_accessor :poster
31
42
 
32
43
  attr_accessor :thumbnail
33
44
 
45
+ # 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. [DestinationShotstack](/#tocs_shotstackdestination) is currently the only option with plans to add more in the future such as S3, YouTube, Vimeo and Mux. If you do not require hosting you can opt-out using the `exclude` property.
46
+ attr_accessor :destinations
47
+
34
48
  class EnumAttributeValidator
35
49
  attr_reader :datatype
36
50
  attr_reader :allowable_values
@@ -59,21 +73,36 @@ module Shotstack
59
73
  :'format' => :'format',
60
74
  :'resolution' => :'resolution',
61
75
  :'aspect_ratio' => :'aspectRatio',
76
+ :'size' => :'size',
77
+ :'fps' => :'fps',
62
78
  :'scale_to' => :'scaleTo',
79
+ :'quality' => :'quality',
80
+ :'range' => :'range',
63
81
  :'poster' => :'poster',
64
- :'thumbnail' => :'thumbnail'
82
+ :'thumbnail' => :'thumbnail',
83
+ :'destinations' => :'destinations'
65
84
  }
66
85
  end
67
86
 
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ attribute_map.values
90
+ end
91
+
68
92
  # Attribute type mapping.
69
93
  def self.openapi_types
70
94
  {
71
95
  :'format' => :'String',
72
96
  :'resolution' => :'String',
73
97
  :'aspect_ratio' => :'String',
98
+ :'size' => :'Size',
99
+ :'fps' => :'Integer',
74
100
  :'scale_to' => :'String',
101
+ :'quality' => :'String',
102
+ :'range' => :'Range',
75
103
  :'poster' => :'Poster',
76
- :'thumbnail' => :'Thumbnail'
104
+ :'thumbnail' => :'Thumbnail',
105
+ :'destinations' => :'Array<Destinations>'
77
106
  }
78
107
  end
79
108
 
@@ -110,10 +139,30 @@ module Shotstack
110
139
  self.aspect_ratio = attributes[:'aspect_ratio']
111
140
  end
112
141
 
142
+ if attributes.key?(:'size')
143
+ self.size = attributes[:'size']
144
+ end
145
+
146
+ if attributes.key?(:'fps')
147
+ self.fps = attributes[:'fps']
148
+ else
149
+ self.fps = 25
150
+ end
151
+
113
152
  if attributes.key?(:'scale_to')
114
153
  self.scale_to = attributes[:'scale_to']
115
154
  end
116
155
 
156
+ if attributes.key?(:'quality')
157
+ self.quality = attributes[:'quality']
158
+ else
159
+ self.quality = 'medium'
160
+ end
161
+
162
+ if attributes.key?(:'range')
163
+ self.range = attributes[:'range']
164
+ end
165
+
117
166
  if attributes.key?(:'poster')
118
167
  self.poster = attributes[:'poster']
119
168
  end
@@ -121,6 +170,12 @@ module Shotstack
121
170
  if attributes.key?(:'thumbnail')
122
171
  self.thumbnail = attributes[:'thumbnail']
123
172
  end
173
+
174
+ if attributes.key?(:'destinations')
175
+ if (value = attributes[:'destinations']).is_a?(Array)
176
+ self.destinations = value
177
+ end
178
+ end
124
179
  end
125
180
 
126
181
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -131,10 +186,6 @@ module Shotstack
131
186
  invalid_properties.push('invalid value for "format", format cannot be nil.')
132
187
  end
133
188
 
134
- if @resolution.nil?
135
- invalid_properties.push('invalid value for "resolution", resolution cannot be nil.')
136
- end
137
-
138
189
  invalid_properties
139
190
  end
140
191
 
@@ -142,22 +193,25 @@ module Shotstack
142
193
  # @return true if the model is valid
143
194
  def valid?
144
195
  return false if @format.nil?
145
- format_validator = EnumAttributeValidator.new('String', ["mp4", "gif"])
196
+ format_validator = EnumAttributeValidator.new('String', ["mp4", "gif", "mp3", "jpg", "png", "bmp"])
146
197
  return false unless format_validator.valid?(@format)
147
- return false if @resolution.nil?
148
198
  resolution_validator = EnumAttributeValidator.new('String', ["preview", "mobile", "sd", "hd", "1080"])
149
199
  return false unless resolution_validator.valid?(@resolution)
150
- aspect_ratio_validator = EnumAttributeValidator.new('String', ["16:9", "9:16", "1:1"])
200
+ aspect_ratio_validator = EnumAttributeValidator.new('String', ["16:9", "9:16", "1:1", "4:5", "4:3"])
151
201
  return false unless aspect_ratio_validator.valid?(@aspect_ratio)
202
+ fps_validator = EnumAttributeValidator.new('Integer', [12, 15, 24, 25, 30])
203
+ return false unless fps_validator.valid?(@fps)
152
204
  scale_to_validator = EnumAttributeValidator.new('String', ["preview", "mobile", "sd", "hd", "1080"])
153
205
  return false unless scale_to_validator.valid?(@scale_to)
206
+ quality_validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
207
+ return false unless quality_validator.valid?(@quality)
154
208
  true
155
209
  end
156
210
 
157
211
  # Custom attribute writer method checking allowed values (enum).
158
212
  # @param [Object] format Object to be assigned
159
213
  def format=(format)
160
- validator = EnumAttributeValidator.new('String', ["mp4", "gif"])
214
+ validator = EnumAttributeValidator.new('String', ["mp4", "gif", "mp3", "jpg", "png", "bmp"])
161
215
  unless validator.valid?(format)
162
216
  fail ArgumentError, "invalid value for \"format\", must be one of #{validator.allowable_values}."
163
217
  end
@@ -177,13 +231,23 @@ module Shotstack
177
231
  # Custom attribute writer method checking allowed values (enum).
178
232
  # @param [Object] aspect_ratio Object to be assigned
179
233
  def aspect_ratio=(aspect_ratio)
180
- validator = EnumAttributeValidator.new('String', ["16:9", "9:16", "1:1"])
234
+ validator = EnumAttributeValidator.new('String', ["16:9", "9:16", "1:1", "4:5", "4:3"])
181
235
  unless validator.valid?(aspect_ratio)
182
236
  fail ArgumentError, "invalid value for \"aspect_ratio\", must be one of #{validator.allowable_values}."
183
237
  end
184
238
  @aspect_ratio = aspect_ratio
185
239
  end
186
240
 
241
+ # Custom attribute writer method checking allowed values (enum).
242
+ # @param [Object] fps Object to be assigned
243
+ def fps=(fps)
244
+ validator = EnumAttributeValidator.new('Integer', [12, 15, 24, 25, 30])
245
+ unless validator.valid?(fps)
246
+ fail ArgumentError, "invalid value for \"fps\", must be one of #{validator.allowable_values}."
247
+ end
248
+ @fps = fps
249
+ end
250
+
187
251
  # Custom attribute writer method checking allowed values (enum).
188
252
  # @param [Object] scale_to Object to be assigned
189
253
  def scale_to=(scale_to)
@@ -194,6 +258,16 @@ module Shotstack
194
258
  @scale_to = scale_to
195
259
  end
196
260
 
261
+ # Custom attribute writer method checking allowed values (enum).
262
+ # @param [Object] quality Object to be assigned
263
+ def quality=(quality)
264
+ validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
265
+ unless validator.valid?(quality)
266
+ fail ArgumentError, "invalid value for \"quality\", must be one of #{validator.allowable_values}."
267
+ end
268
+ @quality = quality
269
+ end
270
+
197
271
  # Checks equality by comparing each attribute.
198
272
  # @param [Object] Object to be compared
199
273
  def ==(o)
@@ -202,9 +276,14 @@ module Shotstack
202
276
  format == o.format &&
203
277
  resolution == o.resolution &&
204
278
  aspect_ratio == o.aspect_ratio &&
279
+ size == o.size &&
280
+ fps == o.fps &&
205
281
  scale_to == o.scale_to &&
282
+ quality == o.quality &&
283
+ range == o.range &&
206
284
  poster == o.poster &&
207
- thumbnail == o.thumbnail
285
+ thumbnail == o.thumbnail &&
286
+ destinations == o.destinations
208
287
  end
209
288
 
210
289
  # @see the `==` method
@@ -216,7 +295,7 @@ module Shotstack
216
295
  # Calculates hash code according to all attributes.
217
296
  # @return [Integer] Hash code
218
297
  def hash
219
- [format, resolution, aspect_ratio, scale_to, poster, thumbnail].hash
298
+ [format, resolution, aspect_ratio, size, fps, scale_to, quality, range, poster, thumbnail, destinations].hash
220
299
  end
221
300
 
222
301
  # Builds the object from hash
@@ -232,7 +311,9 @@ module Shotstack
232
311
  def build_from_hash(attributes)
233
312
  return nil unless attributes.is_a?(Hash)
234
313
  self.class.openapi_types.each_pair do |key, type|
235
- if type =~ /\AArray<(.*)>/i
314
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
315
+ self.send("#{key}=", nil)
316
+ elsif type =~ /\AArray<(.*)>/i
236
317
  # check to ensure the input is an array given that the attribute
237
318
  # is documented as an array but the input is not
238
319
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -240,7 +321,7 @@ module Shotstack
240
321
  end
241
322
  elsif !attributes[self.class.attribute_map[key]].nil?
242
323
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
243
- end # or else data not found in attributes(hash), not an issue as the data can be optional
324
+ end
244
325
  end
245
326
 
246
327
  self
@@ -252,8 +333,8 @@ module Shotstack
252
333
  # @return [Object] Deserialized data
253
334
  def _deserialize(type, value)
254
335
  case type.to_sym
255
- when :DateTime
256
- DateTime.parse(value)
336
+ when :Time
337
+ Time.parse(value)
257
338
  when :Date
258
339
  Date.parse(value)
259
340
  when :String
@@ -283,7 +364,9 @@ module Shotstack
283
364
  end
284
365
  end
285
366
  else # model
286
- Shotstack.const_get(type).build_from_hash(value)
367
+ # models (e.g. Pet) or oneOf
368
+ klass = Shotstack.const_get(type)
369
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
287
370
  end
288
371
  end
289
372
 
@@ -309,7 +392,7 @@ module Shotstack
309
392
  is_nullable = self.class.openapi_nullable.include?(attr)
310
393
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
311
394
  end
312
-
395
+
313
396
  hash[param] = _to_hash(value)
314
397
  end
315
398
  hash
@@ -332,5 +415,7 @@ module Shotstack
332
415
  value
333
416
  end
334
417
  end
418
+
335
419
  end
420
+
336
421
  end
@@ -1,16 +1,17 @@
1
1
  =begin
2
2
  #Shotstack
3
3
 
4
- #The Shotstack API is a video editing service that allows for the automated creation of videos using JSON. You can configure an edit and POST it to the Shotstack API which will render your video and provide a file location when complete. For more details check https://shotstack.io
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.gitbook.io/docs/guides/getting-started) 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>
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: 4.2.1
9
+ OpenAPI Generator version: 5.0.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module Shotstack
16
17
  # Generate a poster image for the video at a specific point from the timeline. The poster image size will match the size of the output video.
@@ -25,6 +26,11 @@ module Shotstack
25
26
  }
26
27
  end
27
28
 
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
28
34
  # Attribute type mapping.
29
35
  def self.openapi_types
30
36
  {
@@ -109,7 +115,9 @@ module Shotstack
109
115
  def build_from_hash(attributes)
110
116
  return nil unless attributes.is_a?(Hash)
111
117
  self.class.openapi_types.each_pair do |key, type|
112
- if type =~ /\AArray<(.*)>/i
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
113
121
  # check to ensure the input is an array given that the attribute
114
122
  # is documented as an array but the input is not
115
123
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -117,7 +125,7 @@ module Shotstack
117
125
  end
118
126
  elsif !attributes[self.class.attribute_map[key]].nil?
119
127
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
- end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
121
129
  end
122
130
 
123
131
  self
@@ -129,8 +137,8 @@ module Shotstack
129
137
  # @return [Object] Deserialized data
130
138
  def _deserialize(type, value)
131
139
  case type.to_sym
132
- when :DateTime
133
- DateTime.parse(value)
140
+ when :Time
141
+ Time.parse(value)
134
142
  when :Date
135
143
  Date.parse(value)
136
144
  when :String
@@ -160,7 +168,9 @@ module Shotstack
160
168
  end
161
169
  end
162
170
  else # model
163
- Shotstack.const_get(type).build_from_hash(value)
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Shotstack.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
164
174
  end
165
175
  end
166
176
 
@@ -186,7 +196,7 @@ module Shotstack
186
196
  is_nullable = self.class.openapi_nullable.include?(attr)
187
197
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
198
  end
189
-
199
+
190
200
  hash[param] = _to_hash(value)
191
201
  end
192
202
  hash
@@ -209,5 +219,7 @@ module Shotstack
209
219
  value
210
220
  end
211
221
  end
222
+
212
223
  end
224
+
213
225
  end