Skip to content

Commit

Permalink
PHP 7.2 and OpenAPI 5 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffski committed Dec 29, 2020
1 parent 3831234 commit 412946b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
src/autoload.php
src/composer.json
composer.lock
vendor
85 changes: 39 additions & 46 deletions src/Api/EndpointsApi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* EndpointsApi
* PHP version 5
* PHP version 7.2
*
* @category Class
* @package Shotstack\Client
Expand All @@ -17,7 +17,7 @@
* The version of the OpenAPI document: v1
*
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 4.2.1
* OpenAPI Generator version: 5.0.0
*/

/**
Expand Down Expand Up @@ -73,34 +73,34 @@ class EndpointsApi
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$host_index = 0
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $host_index;
$this->hostIndex = $hostIndex;
}

/**
* Set the host index
*
* @param int Host index (required)
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($host_index)
public function setHostIndex($hostIndex)
{
$this->hostIndex = $host_index;
$this->hostIndex = $hostIndex;
}

/**
* Get the host index
*
* @return Host index
* @return int Host index
*/
public function getHostIndex()
{
Expand Down Expand Up @@ -156,7 +156,7 @@ public function getRenderWithHttpInfo($id)
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
}

Expand All @@ -181,7 +181,7 @@ public function getRenderWithHttpInfo($id)
if ('\Shotstack\Client\Model\RenderResponse' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand All @@ -196,7 +196,7 @@ public function getRenderWithHttpInfo($id)
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand Down Expand Up @@ -263,7 +263,7 @@ function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand Down Expand Up @@ -297,7 +297,7 @@ function ($exception) {
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function getRenderRequest($id)
public function getRenderRequest($id)
{
// verify the required parameter 'id' is set
if ($id === null || (is_array($id) && count($id) === 0)) {
Expand All @@ -318,6 +318,7 @@ protected function getRenderRequest($id)
$multipart = false;



// path params
if ($id !== null) {
$resourcePath = str_replace(
Expand All @@ -327,8 +328,6 @@ protected function getRenderRequest($id)
);
}

// body params
$_tempBody = null;

if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
Expand All @@ -342,21 +341,17 @@ protected function getRenderRequest($id)
}

// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
Expand Down Expand Up @@ -439,7 +434,7 @@ public function postRenderWithHttpInfo($edit, $x_api_queue_id = null)
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
}

Expand All @@ -464,7 +459,7 @@ public function postRenderWithHttpInfo($edit, $x_api_queue_id = null)
if ('\Shotstack\Client\Model\QueuedResponse' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand All @@ -479,7 +474,7 @@ public function postRenderWithHttpInfo($edit, $x_api_queue_id = null)
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand Down Expand Up @@ -548,7 +543,7 @@ function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
$content = (string) $responseBody;
}

return [
Expand Down Expand Up @@ -583,7 +578,7 @@ function ($exception) {
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function postRenderRequest($edit, $x_api_queue_id = null)
public function postRenderRequest($edit, $x_api_queue_id = null)
{
// verify the required parameter 'edit' is set
if ($edit === null || (is_array($edit) && count($edit) === 0)) {
Expand All @@ -599,17 +594,13 @@ protected function postRenderRequest($edit, $x_api_queue_id = null)
$httpBody = '';
$multipart = false;


// header params
if ($x_api_queue_id !== null) {
$headerParams['x-api-queue-id'] = ObjectSerializer::toHeaderValue($x_api_queue_id);
}


// body params
$_tempBody = null;
if (isset($edit)) {
$_tempBody = $edit;
}

if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
Expand All @@ -623,21 +614,23 @@ protected function postRenderRequest($edit, $x_api_queue_id = null)
}

// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
if (isset($edit)) {
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody));
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($edit));
} else {
$httpBody = $_tempBody;
$httpBody = $edit;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
Expand Down

0 comments on commit 412946b

Please sign in to comment.