Skip to content

Commit 47c00c3

Browse files
author
Dean Fogarty
authored
Update generation, add new FPS settings (#21)
* Update api generator version, whitespace fixes. * First pass generator check. * Second pass generator check. * Update FPS notes. * Remove default FPS. * Turn off language deprecation warnings. * Note PHP and Guzzle versions.
1 parent aa6cfb4 commit 47c00c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+317
-392
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For examples of how to use the SDK to create videos using code checkout the PHP
1212

1313
## Contents <!-- omit in toc -->
1414
- [Using the PHP SDK](#using-the-php-sdk)
15+
- [Requirements](#requirements)
1516
- [Installation](#installation)
1617
- [Video Editing](#video-editing)
1718
- [Video Editing Example](#video-editing-example)
@@ -64,6 +65,10 @@ For examples of how to use the SDK to create videos using code checkout the PHP
6465
- [API Documentation and Guides](#api-documentation-and-guides)
6566

6667
# Using the PHP SDK
68+
### Requirements
69+
70+
Requires PHP7.3+ and uses Guzzle7.3+.
71+
6772
### Installation
6873

6974
The recommended way to use the SDK is as a composer package. Install using the command:
@@ -734,7 +739,7 @@ setFormat(string $format) | The output format and type of media file to generate
734739
setResolution(string $resolution) | 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> | -
735740
setAspectRatio(string $aspectRatio) | 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> | -
736741
setSize([\Shotstack\Client\Model\Size](#size) $size) | Set a custom size for a video or image. When using a custom size omit the `resolution` and `aspectRatio`. Custom sizes must be divisible by 2 based on the encoder specifications. | -
737-
setFps(int $fps) | 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> | -
742+
setFps(float $fps) | 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>`23.976` - 23.976fps</li><li>`24` - 24fps</li><li>`25` - 25fps</li><li>`29.97` - 29.97fps</li><li>`30` - 30fps</li></ul> | -
738743
setScaleTo(string $scaleTo) | 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> | -
739744
setQuality(string $quality) | 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> | -
740745
setRepeat(bool $repeat) | Loop settings for gif files. Set to `true` to loop, `false` to play only once. [default to `true`] | -
@@ -1104,4 +1109,4 @@ getUpdated(): string | The time the asset status was last updated. | -
11041109
- [Getting Started Guide](https://shotstack.io/docs/guide/getting-started/core-concepts/)
11051110
- [API Reference](https://shotstack.io/docs/api/)
11061111
- [Examples](https://github.com/shotstack/php-demos)
1107-
- [Shotstack Website](https://shotstack.io)
1112+
- [Shotstack Website](https://shotstack.io)

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
"minimum-stability": "dev",
77
"keywords": ["shotstack", "video", "video editing", "api"],
88
"require": {
9-
"php": ">=7.2",
9+
"php": "^7.3 || ^8.0",
1010
"ext-curl": "*",
1111
"ext-json": "*",
1212
"ext-mbstring": "*",
13-
"guzzlehttp/guzzle": "7.2.0"
13+
"guzzlehttp/guzzle": "^7.3",
14+
"guzzlehttp/psr7": "^1.7 || ^2.0"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "^8.0 || ^9.0",
18+
"friendsofphp/php-cs-fixer": "^2.12"
1419
},
1520
"autoload": {
1621
"psr-4": { "Shotstack\\Client\\" : "src/" }

src/Api/EditApi.php

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* EditApi
4-
* PHP version 7.2
4+
* PHP version 7.3
55
*
66
* @category Class
77
* @package Shotstack\Client
@@ -15,9 +15,8 @@
1515
* 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>
1616
*
1717
* The version of the OpenAPI document: v1
18-
*
1918
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 5.0.0
19+
* OpenAPI Generator version: 5.4.0
2120
*/
2221

2322
/**
@@ -28,9 +27,12 @@
2827

2928
namespace Shotstack\Client\Api;
3029

30+
error_reporting(E_ALL & ~E_DEPRECATED);
31+
3132
use GuzzleHttp\Client;
3233
use GuzzleHttp\ClientInterface;
3334
use GuzzleHttp\Exception\RequestException;
35+
use GuzzleHttp\Exception\ConnectException;
3436
use GuzzleHttp\Psr7\MultipartStream;
3537
use GuzzleHttp\Psr7\Request;
3638
use GuzzleHttp\RequestOptions;
@@ -92,7 +94,7 @@ public function __construct(
9294
*
9395
* @param int $hostIndex Host index (required)
9496
*/
95-
public function setHostIndex($hostIndex)
97+
public function setHostIndex($hostIndex): void
9698
{
9799
$this->hostIndex = $hostIndex;
98100
}
@@ -158,10 +160,17 @@ public function getRenderWithHttpInfo($id, $data = null, $merged = null)
158160
} catch (RequestException $e) {
159161
throw new ApiException(
160162
"[{$e->getCode()}] {$e->getMessage()}",
161-
$e->getCode(),
163+
(int) $e->getCode(),
162164
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
163165
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
164166
);
167+
} catch (ConnectException $e) {
168+
throw new ApiException(
169+
"[{$e->getCode()}] {$e->getMessage()}",
170+
(int) $e->getCode(),
171+
null,
172+
null
173+
);
165174
}
166175

167176
$statusCode = $response->getStatusCode();
@@ -171,21 +180,20 @@ public function getRenderWithHttpInfo($id, $data = null, $merged = null)
171180
sprintf(
172181
'[%d] Error connecting to the API (%s)',
173182
$statusCode,
174-
$request->getUri()
183+
(string) $request->getUri()
175184
),
176185
$statusCode,
177186
$response->getHeaders(),
178-
$response->getBody()
187+
(string) $response->getBody()
179188
);
180189
}
181190

182-
$responseBody = $response->getBody();
183191
switch($statusCode) {
184192
case 200:
185193
if ('\Shotstack\Client\Model\RenderResponse' === '\SplFileObject') {
186-
$content = $responseBody; //stream goes to serializer
194+
$content = $response->getBody(); //stream goes to serializer
187195
} else {
188-
$content = (string) $responseBody;
196+
$content = (string) $response->getBody();
189197
}
190198

191199
return [
@@ -196,11 +204,10 @@ public function getRenderWithHttpInfo($id, $data = null, $merged = null)
196204
}
197205

198206
$returnType = '\Shotstack\Client\Model\RenderResponse';
199-
$responseBody = $response->getBody();
200207
if ($returnType === '\SplFileObject') {
201-
$content = $responseBody; //stream goes to serializer
208+
$content = $response->getBody(); //stream goes to serializer
202209
} else {
203-
$content = (string) $responseBody;
210+
$content = (string) $response->getBody();
204211
}
205212

206213
return [
@@ -267,11 +274,10 @@ public function getRenderAsyncWithHttpInfo($id, $data = null, $merged = null)
267274
->sendAsync($request, $this->createHttpClientOption())
268275
->then(
269276
function ($response) use ($returnType) {
270-
$responseBody = $response->getBody();
271277
if ($returnType === '\SplFileObject') {
272-
$content = $responseBody; //stream goes to serializer
278+
$content = $response->getBody(); //stream goes to serializer
273279
} else {
274-
$content = (string) $responseBody;
280+
$content = (string) $response->getBody();
275281
}
276282

277283
return [
@@ -291,7 +297,7 @@ function ($exception) {
291297
),
292298
$statusCode,
293299
$response->getHeaders(),
294-
$response->getBody()
300+
(string) $response->getBody()
295301
);
296302
}
297303
);
@@ -393,7 +399,7 @@ public function getRenderRequest($id, $data = null, $merged = null)
393399

394400
} else {
395401
// for HTTP post (form)
396-
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
402+
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
397403
}
398404
}
399405

@@ -414,7 +420,7 @@ public function getRenderRequest($id, $data = null, $merged = null)
414420
$headers
415421
);
416422

417-
$query = \GuzzleHttp\Psr7\build_query($queryParams);
423+
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
418424
return new Request(
419425
'GET',
420426
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
@@ -462,10 +468,17 @@ public function postRenderWithHttpInfo($edit)
462468
} catch (RequestException $e) {
463469
throw new ApiException(
464470
"[{$e->getCode()}] {$e->getMessage()}",
465-
$e->getCode(),
471+
(int) $e->getCode(),
466472
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
467473
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
468474
);
475+
} catch (ConnectException $e) {
476+
throw new ApiException(
477+
"[{$e->getCode()}] {$e->getMessage()}",
478+
(int) $e->getCode(),
479+
null,
480+
null
481+
);
469482
}
470483

471484
$statusCode = $response->getStatusCode();
@@ -475,21 +488,20 @@ public function postRenderWithHttpInfo($edit)
475488
sprintf(
476489
'[%d] Error connecting to the API (%s)',
477490
$statusCode,
478-
$request->getUri()
491+
(string) $request->getUri()
479492
),
480493
$statusCode,
481494
$response->getHeaders(),
482-
$response->getBody()
495+
(string) $response->getBody()
483496
);
484497
}
485498

486-
$responseBody = $response->getBody();
487499
switch($statusCode) {
488500
case 201:
489501
if ('\Shotstack\Client\Model\QueuedResponse' === '\SplFileObject') {
490-
$content = $responseBody; //stream goes to serializer
502+
$content = $response->getBody(); //stream goes to serializer
491503
} else {
492-
$content = (string) $responseBody;
504+
$content = (string) $response->getBody();
493505
}
494506

495507
return [
@@ -500,11 +512,10 @@ public function postRenderWithHttpInfo($edit)
500512
}
501513

502514
$returnType = '\Shotstack\Client\Model\QueuedResponse';
503-
$responseBody = $response->getBody();
504515
if ($returnType === '\SplFileObject') {
505-
$content = $responseBody; //stream goes to serializer
516+
$content = $response->getBody(); //stream goes to serializer
506517
} else {
507-
$content = (string) $responseBody;
518+
$content = (string) $response->getBody();
508519
}
509520

510521
return [
@@ -567,11 +578,10 @@ public function postRenderAsyncWithHttpInfo($edit)
567578
->sendAsync($request, $this->createHttpClientOption())
568579
->then(
569580
function ($response) use ($returnType) {
570-
$responseBody = $response->getBody();
571581
if ($returnType === '\SplFileObject') {
572-
$content = $responseBody; //stream goes to serializer
582+
$content = $response->getBody(); //stream goes to serializer
573583
} else {
574-
$content = (string) $responseBody;
584+
$content = (string) $response->getBody();
575585
}
576586

577587
return [
@@ -591,7 +601,7 @@ function ($exception) {
591601
),
592602
$statusCode,
593603
$response->getHeaders(),
594-
$response->getBody()
604+
(string) $response->getBody()
595605
);
596606
}
597607
);
@@ -663,7 +673,7 @@ public function postRenderRequest($edit)
663673

664674
} else {
665675
// for HTTP post (form)
666-
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
676+
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
667677
}
668678
}
669679

@@ -684,7 +694,7 @@ public function postRenderRequest($edit)
684694
$headers
685695
);
686696

687-
$query = \GuzzleHttp\Psr7\build_query($queryParams);
697+
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
688698
return new Request(
689699
'POST',
690700
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
@@ -732,10 +742,17 @@ public function probeWithHttpInfo($url)
732742
} catch (RequestException $e) {
733743
throw new ApiException(
734744
"[{$e->getCode()}] {$e->getMessage()}",
735-
$e->getCode(),
745+
(int) $e->getCode(),
736746
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
737747
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
738748
);
749+
} catch (ConnectException $e) {
750+
throw new ApiException(
751+
"[{$e->getCode()}] {$e->getMessage()}",
752+
(int) $e->getCode(),
753+
null,
754+
null
755+
);
739756
}
740757

741758
$statusCode = $response->getStatusCode();
@@ -745,21 +762,20 @@ public function probeWithHttpInfo($url)
745762
sprintf(
746763
'[%d] Error connecting to the API (%s)',
747764
$statusCode,
748-
$request->getUri()
765+
(string) $request->getUri()
749766
),
750767
$statusCode,
751768
$response->getHeaders(),
752-
$response->getBody()
769+
(string) $response->getBody()
753770
);
754771
}
755772

756-
$responseBody = $response->getBody();
757773
switch($statusCode) {
758774
case 200:
759775
if ('\Shotstack\Client\Model\ProbeResponse' === '\SplFileObject') {
760-
$content = $responseBody; //stream goes to serializer
776+
$content = $response->getBody(); //stream goes to serializer
761777
} else {
762-
$content = (string) $responseBody;
778+
$content = (string) $response->getBody();
763779
}
764780

765781
return [
@@ -770,11 +786,10 @@ public function probeWithHttpInfo($url)
770786
}
771787

772788
$returnType = '\Shotstack\Client\Model\ProbeResponse';
773-
$responseBody = $response->getBody();
774789
if ($returnType === '\SplFileObject') {
775-
$content = $responseBody; //stream goes to serializer
790+
$content = $response->getBody(); //stream goes to serializer
776791
} else {
777-
$content = (string) $responseBody;
792+
$content = (string) $response->getBody();
778793
}
779794

780795
return [
@@ -837,11 +852,10 @@ public function probeAsyncWithHttpInfo($url)
837852
->sendAsync($request, $this->createHttpClientOption())
838853
->then(
839854
function ($response) use ($returnType) {
840-
$responseBody = $response->getBody();
841855
if ($returnType === '\SplFileObject') {
842-
$content = $responseBody; //stream goes to serializer
856+
$content = $response->getBody(); //stream goes to serializer
843857
} else {
844-
$content = (string) $responseBody;
858+
$content = (string) $response->getBody();
845859
}
846860

847861
return [
@@ -861,7 +875,7 @@ function ($exception) {
861875
),
862876
$statusCode,
863877
$response->getHeaders(),
864-
$response->getBody()
878+
(string) $response->getBody()
865879
);
866880
}
867881
);
@@ -935,7 +949,7 @@ public function probeRequest($url)
935949

936950
} else {
937951
// for HTTP post (form)
938-
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
952+
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
939953
}
940954
}
941955

@@ -956,7 +970,7 @@ public function probeRequest($url)
956970
$headers
957971
);
958972

959-
$query = \GuzzleHttp\Psr7\build_query($queryParams);
973+
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
960974
return new Request(
961975
'GET',
962976
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),

0 commit comments

Comments
 (0)