diff --git a/codegen/Cms/AuditLogs/Api/AuditLogsApi.php b/codegen/Cms/AuditLogs/Api/AuditLogsApi.php index 69f1e768..512e0a6c 100644 --- a/codegen/Cms/AuditLogs/Api/AuditLogsApi.php +++ b/codegen/Cms/AuditLogs/Api/AuditLogsApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\AuditLogs\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\AuditLogs\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\AuditLogs\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\AuditLogs\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -263,34 +226,11 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object ); } - $returnType = '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -300,7 +240,7 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -308,8 +248,10 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -585,6 +527,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/AuditLogs/ApiException.php b/codegen/Cms/AuditLogs/ApiException.php index 771d4638..5fdd681f 100644 --- a/codegen/Cms/AuditLogs/ApiException.php +++ b/codegen/Cms/AuditLogs/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Cms/AuditLogs/FormDataProcessor.php b/codegen/Cms/AuditLogs/FormDataProcessor.php new file mode 100644 index 00000000..6326ef09 --- /dev/null +++ b/codegen/Cms/AuditLogs/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Cms/AuditLogs/HeaderSelector.php b/codegen/Cms/AuditLogs/HeaderSelector.php index 9ca18272..4f58d23e 100644 --- a/codegen/Cms/AuditLogs/HeaderSelector.php +++ b/codegen/Cms/AuditLogs/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -368,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -398,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/Error.php b/codegen/Cms/AuditLogs/Model/Error.php index 692d525f..3552ad47 100644 --- a/codegen/Cms/AuditLogs/Model/Error.php +++ b/codegen/Cms/AuditLogs/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/ErrorDetail.php b/codegen/Cms/AuditLogs/Model/ErrorDetail.php index bf29abe9..c83b8af9 100644 --- a/codegen/Cms/AuditLogs/Model/ErrorDetail.php +++ b/codegen/Cms/AuditLogs/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/ModelInterface.php b/codegen/Cms/AuditLogs/Model/ModelInterface.php index b8763cda..262d9e32 100644 --- a/codegen/Cms/AuditLogs/Model/ModelInterface.php +++ b/codegen/Cms/AuditLogs/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Cms/AuditLogs/Model/NextPage.php b/codegen/Cms/AuditLogs/Model/NextPage.php index a3cd3d2b..734b43eb 100644 --- a/codegen/Cms/AuditLogs/Model/NextPage.php +++ b/codegen/Cms/AuditLogs/Model/NextPage.php @@ -2,7 +2,7 @@ /** * NextPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -35,6 +35,7 @@ * NextPage Class Doc Comment * * @category Class + * @description Specifies the paging information needed to retrieve the next set of results in a paginated API response * @package HubSpot\Client\Cms\AuditLogs * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -312,7 +313,7 @@ public function getLink() /** * Sets link * - * @param string|null $link link + * @param string|null $link A URL that can be used to retrieve the next page results. * * @return self */ @@ -339,7 +340,7 @@ public function getAfter() /** * Sets after * - * @param string $after after + * @param string $after A paging cursor token for retrieving subsequent pages. * * @return self */ @@ -355,11 +356,11 @@ public function setAfter($after) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -367,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -397,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/Paging.php b/codegen/Cms/AuditLogs/Model/Paging.php index 94d80d88..cdd4b77a 100644 --- a/codegen/Cms/AuditLogs/Model/Paging.php +++ b/codegen/Cms/AuditLogs/Model/Paging.php @@ -2,7 +2,7 @@ /** * Paging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -352,11 +352,11 @@ public function setPrev($prev) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -364,12 +364,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -394,11 +394,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/PreviousPage.php b/codegen/Cms/AuditLogs/Model/PreviousPage.php index b48b021d..32bdb333 100644 --- a/codegen/Cms/AuditLogs/Model/PreviousPage.php +++ b/codegen/Cms/AuditLogs/Model/PreviousPage.php @@ -2,7 +2,7 @@ /** * PreviousPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -35,6 +35,7 @@ * PreviousPage Class Doc Comment * * @category Class + * @description specifies the paging information needed to retrieve the previous set of results in a paginated API response * @package HubSpot\Client\Cms\AuditLogs * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -312,7 +313,7 @@ public function getBefore() /** * Sets before * - * @param string $before before + * @param string $before A paging cursor token for retrieving previous pages. * * @return self */ @@ -339,7 +340,7 @@ public function getLink() /** * Sets link * - * @param string|null $link link + * @param string|null $link A URL that can be used to retrieve the previous pages' results. * * @return self */ @@ -355,11 +356,11 @@ public function setLink($link) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -367,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -397,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/Model/PublicAuditLog.php b/codegen/Cms/AuditLogs/Model/PublicAuditLog.php index 168b0450..84541f65 100644 --- a/codegen/Cms/AuditLogs/Model/PublicAuditLog.php +++ b/codegen/Cms/AuditLogs/Model/PublicAuditLog.php @@ -2,7 +2,7 @@ /** * PublicAuditLog * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -689,11 +689,11 @@ public function setTimestamp($timestamp) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -701,12 +701,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -731,11 +731,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/AuditLogs/ObjectSerializer.php b/codegen/Cms/AuditLogs/ObjectSerializer.php index ee4e0bbd..cc7b4853 100644 --- a/codegen/Cms/AuditLogs/ObjectSerializer.php +++ b/codegen/Cms/AuditLogs/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\AuditLogs @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Cms/Domains/Api/DomainsApi.php b/codegen/Cms/Domains/Api/DomainsApi.php index bd69e1e1..77cb76c4 100644 --- a/codegen/Cms/Domains/Api/DomainsApi.php +++ b/codegen/Cms/Domains/Api/DomainsApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Domains\Model\Domain' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Domains\Model\Domain', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\Domain', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Domains\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Domains\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Domains\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -252,34 +215,11 @@ public function getByIdWithHttpInfo($domain_id, string $contentType = self::cont ); } - $returnType = '\HubSpot\Client\Cms\Domains\Model\Domain'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\Domain', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -289,7 +229,7 @@ public function getByIdWithHttpInfo($domain_id, string $contentType = self::cont $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -297,8 +237,10 @@ public function getByIdWithHttpInfo($domain_id, string $contentType = self::cont $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -549,61 +491,21 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Domains\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Domains\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Domains\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -617,34 +519,11 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ ); } - $returnType = '\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -654,7 +533,7 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -662,8 +541,10 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -965,6 +846,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/Domains/ApiException.php b/codegen/Cms/Domains/ApiException.php index 90460895..ce533783 100644 --- a/codegen/Cms/Domains/ApiException.php +++ b/codegen/Cms/Domains/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Cms/Domains/FormDataProcessor.php b/codegen/Cms/Domains/FormDataProcessor.php new file mode 100644 index 00000000..d7ee407a --- /dev/null +++ b/codegen/Cms/Domains/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Cms/Domains/HeaderSelector.php b/codegen/Cms/Domains/HeaderSelector.php index e97e12cc..1f59357b 100644 --- a/codegen/Cms/Domains/HeaderSelector.php +++ b/codegen/Cms/Domains/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -404,12 +404,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -434,11 +434,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/Model/Domain.php b/codegen/Cms/Domains/Model/Domain.php index 186ca361..0205b354 100644 --- a/codegen/Cms/Domains/Model/Domain.php +++ b/codegen/Cms/Domains/Model/Domain.php @@ -2,7 +2,7 @@ /** * Domain * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -988,11 +988,11 @@ public function setPrimaryEmail($primary_email) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -1000,12 +1000,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -1030,11 +1030,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/Model/Error.php b/codegen/Cms/Domains/Model/Error.php index ed022144..f86304e7 100644 --- a/codegen/Cms/Domains/Model/Error.php +++ b/codegen/Cms/Domains/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/Model/ErrorDetail.php b/codegen/Cms/Domains/Model/ErrorDetail.php index 8d8fd85e..13a6579a 100644 --- a/codegen/Cms/Domains/Model/ErrorDetail.php +++ b/codegen/Cms/Domains/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/Model/ForwardPaging.php b/codegen/Cms/Domains/Model/ForwardPaging.php index 28ff6cd4..abf38d77 100644 --- a/codegen/Cms/Domains/Model/ForwardPaging.php +++ b/codegen/Cms/Domains/Model/ForwardPaging.php @@ -2,7 +2,7 @@ /** * ForwardPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -318,11 +318,11 @@ public function setNext($next) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -330,12 +330,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -360,11 +360,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/Model/ModelInterface.php b/codegen/Cms/Domains/Model/ModelInterface.php index 5401d7f3..cb736407 100644 --- a/codegen/Cms/Domains/Model/ModelInterface.php +++ b/codegen/Cms/Domains/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Cms/Domains/Model/NextPage.php b/codegen/Cms/Domains/Model/NextPage.php index dfd9bd60..25902a4f 100644 --- a/codegen/Cms/Domains/Model/NextPage.php +++ b/codegen/Cms/Domains/Model/NextPage.php @@ -2,7 +2,7 @@ /** * NextPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -35,6 +35,7 @@ * NextPage Class Doc Comment * * @category Class + * @description Specifies the paging information needed to retrieve the next set of results in a paginated API response * @package HubSpot\Client\Cms\Domains * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -312,7 +313,7 @@ public function getLink() /** * Sets link * - * @param string|null $link link + * @param string|null $link A URL that can be used to retrieve the next page results. * * @return self */ @@ -339,7 +340,7 @@ public function getAfter() /** * Sets after * - * @param string $after after + * @param string $after A paging cursor token for retrieving subsequent pages. * * @return self */ @@ -355,11 +356,11 @@ public function setAfter($after) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -367,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -397,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Domains/ObjectSerializer.php b/codegen/Cms/Domains/ObjectSerializer.php index e7b05dfe..a00eaf64 100644 --- a/codegen/Cms/Domains/ObjectSerializer.php +++ b/codegen/Cms/Domains/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Domains @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Cms/Pages/Api/LandingPagesApi.php b/codegen/Cms/Pages/Api/LandingPagesApi.php index 3a714371..2306e0d1 100644 --- a/codegen/Cms/Pages/Api/LandingPagesApi.php +++ b/codegen/Cms/Pages/Api/LandingPagesApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -305,8 +307,10 @@ public function archiveWithHttpInfo($object_id, $archived = null, string $conten $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -537,7 +541,6 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -547,8 +550,10 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -767,7 +772,6 @@ public function archiveFolderWithHttpInfo($object_id, $archived = null, string $ return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -777,8 +781,10 @@ public function archiveFolderWithHttpInfo($object_id, $archived = null, string $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1009,7 +1015,6 @@ public function archiveFoldersWithHttpInfo($batch_input_string, string $contentT return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -1019,8 +1024,10 @@ public function archiveFoldersWithHttpInfo($batch_input_string, string $contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1237,7 +1244,6 @@ public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_ return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -1247,8 +1253,10 @@ public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1467,61 +1475,21 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1535,34 +1503,11 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1572,7 +1517,7 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1580,8 +1525,10 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1811,7 +1758,6 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -1821,7 +1767,7 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1829,8 +1775,10 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2049,61 +1997,21 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2117,34 +2025,11 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -2154,7 +2039,7 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2162,8 +2047,10 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2395,88 +2282,27 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2490,34 +2316,11 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -2527,7 +2330,7 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2535,7 +2338,7 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2543,8 +2346,10 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2776,61 +2581,21 @@ public function createFolderWithHttpInfo($content_folder, string $contentType = switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\ContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2844,34 +2609,11 @@ public function createFolderWithHttpInfo($content_folder, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\ContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -2881,7 +2623,7 @@ public function createFolderWithHttpInfo($content_folder, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2889,8 +2631,10 @@ public function createFolderWithHttpInfo($content_folder, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3122,88 +2866,27 @@ public function createFoldersWithHttpInfo($batch_input_content_folder, string $c switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -3217,34 +2900,11 @@ public function createFoldersWithHttpInfo($batch_input_content_folder, string $c ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -3254,7 +2914,7 @@ public function createFoldersWithHttpInfo($batch_input_content_folder, string $c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3262,7 +2922,7 @@ public function createFoldersWithHttpInfo($batch_input_content_folder, string $c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3270,8 +2930,10 @@ public function createFoldersWithHttpInfo($batch_input_content_folder, string $c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3503,61 +3165,21 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -3571,34 +3193,11 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -3608,7 +3207,7 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3616,8 +3215,10 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3847,7 +3448,6 @@ public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_ return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -3857,8 +3457,10 @@ public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -4075,7 +3677,6 @@ public function endActiveABTestWithHttpInfo($ab_test_end_request_v_next, string return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -4085,8 +3686,10 @@ public function endActiveABTestWithHttpInfo($ab_test_end_request_v_next, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -4309,61 +3912,21 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -4377,34 +3940,11 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -4414,7 +3954,7 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -4422,8 +3962,10 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -4682,61 +4224,21 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -4750,34 +4252,11 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -4787,7 +4266,7 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -4795,8 +4274,10 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5033,61 +4514,21 @@ public function getFolderByIdWithHttpInfo($object_id, $archived = null, $propert switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\ContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -5101,34 +4542,11 @@ public function getFolderByIdWithHttpInfo($object_id, $archived = null, $propert ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\ContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -5138,7 +4556,7 @@ public function getFolderByIdWithHttpInfo($object_id, $archived = null, $propert $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5146,8 +4564,10 @@ public function getFolderByIdWithHttpInfo($object_id, $archived = null, $propert $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5408,61 +4828,21 @@ public function getFolderPreviousVersionWithHttpInfo($object_id, $revision_id, s switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\VersionContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\VersionContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\VersionContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -5476,34 +4856,11 @@ public function getFolderPreviousVersionWithHttpInfo($object_id, $revision_id, s ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\VersionContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -5513,7 +4870,7 @@ public function getFolderPreviousVersionWithHttpInfo($object_id, $revision_id, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5521,8 +4878,10 @@ public function getFolderPreviousVersionWithHttpInfo($object_id, $revision_id, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5779,61 +5138,21 @@ public function getFolderPreviousVersionsWithHttpInfo($object_id, $after = null, switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -5847,34 +5166,11 @@ public function getFolderPreviousVersionsWithHttpInfo($object_id, $after = null, ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -5884,7 +5180,7 @@ public function getFolderPreviousVersionsWithHttpInfo($object_id, $after = null, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5892,8 +5188,10 @@ public function getFolderPreviousVersionsWithHttpInfo($object_id, $after = null, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -6185,61 +5483,21 @@ public function getFoldersPageWithHttpInfo($created_at = null, $created_after = switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -6253,34 +5511,11 @@ public function getFoldersPageWithHttpInfo($created_at = null, $created_after = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalContentFolderForwardPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -6290,7 +5525,7 @@ public function getFoldersPageWithHttpInfo($created_at = null, $created_after = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -6298,8 +5533,10 @@ public function getFoldersPageWithHttpInfo($created_at = null, $created_after = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -6677,61 +5914,21 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -6745,34 +5942,11 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -6782,7 +5956,7 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -6790,8 +5964,10 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7151,61 +6327,21 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\VersionPage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\VersionPage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\VersionPage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionPage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -7219,34 +6355,11 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\VersionPage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionPage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -7256,7 +6369,7 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7264,8 +6377,10 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7522,61 +6637,21 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -7590,34 +6665,11 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -7627,7 +6679,7 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7635,8 +6687,10 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7906,7 +6960,6 @@ public function pushLiveWithHttpInfo($object_id, string $contentType = self::con return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -7916,8 +6969,10 @@ public function pushLiveWithHttpInfo($object_id, string $contentType = self::con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8139,88 +7194,27 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -8234,34 +7228,11 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -8271,7 +7242,7 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -8279,7 +7250,7 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -8287,8 +7258,10 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8535,88 +7508,27 @@ public function readFoldersWithHttpInfo($batch_input_string, $archived = null, s switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -8630,34 +7542,11 @@ public function readFoldersWithHttpInfo($batch_input_string, $archived = null, s ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -8667,7 +7556,7 @@ public function readFoldersWithHttpInfo($batch_input_string, $archived = null, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -8675,7 +7564,7 @@ public function readFoldersWithHttpInfo($batch_input_string, $archived = null, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -8683,8 +7572,10 @@ public function readFoldersWithHttpInfo($batch_input_string, $archived = null, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8927,7 +7818,6 @@ public function rerunPreviousABTestWithHttpInfo($ab_test_rerun_request_v_next, s return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -8937,8 +7827,10 @@ public function rerunPreviousABTestWithHttpInfo($ab_test_rerun_request_v_next, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -9155,7 +8047,6 @@ public function resetDraftWithHttpInfo($object_id, string $contentType = self::c return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -9165,8 +8056,10 @@ public function resetDraftWithHttpInfo($object_id, string $contentType = self::c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -9388,61 +8281,21 @@ public function restoreFolderPreviousVersionWithHttpInfo($object_id, $revision_i switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\ContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -9456,34 +8309,11 @@ public function restoreFolderPreviousVersionWithHttpInfo($object_id, $revision_i ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\ContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -9493,7 +8323,7 @@ public function restoreFolderPreviousVersionWithHttpInfo($object_id, $revision_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -9501,8 +8331,10 @@ public function restoreFolderPreviousVersionWithHttpInfo($object_id, $revision_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -9755,61 +8587,21 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -9823,34 +8615,11 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -9860,7 +8629,7 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -9868,8 +8637,10 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -10122,61 +8893,21 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -10190,34 +8921,11 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -10227,7 +8935,7 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -10235,8 +8943,10 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -10485,7 +9195,6 @@ public function scheduleWithHttpInfo($content_schedule_request_v_next, string $c return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -10495,8 +9204,10 @@ public function scheduleWithHttpInfo($content_schedule_request_v_next, string $c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -10713,7 +9424,6 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -10723,8 +9433,10 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -10947,61 +9659,21 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -11015,34 +9687,11 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -11052,7 +9701,7 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -11060,8 +9709,10 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -11326,88 +9977,27 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -11421,34 +10011,11 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -11458,7 +10025,7 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -11466,7 +10033,7 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -11474,8 +10041,10 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -11722,61 +10291,21 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -11790,34 +10319,11 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -11827,7 +10333,7 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -11835,8 +10341,10 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -12090,61 +10598,21 @@ public function updateFolderWithHttpInfo($object_id, $content_folder, $archived switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\ContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\ContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -12158,34 +10626,11 @@ public function updateFolderWithHttpInfo($object_id, $content_folder, $archived ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\ContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\ContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -12195,7 +10640,7 @@ public function updateFolderWithHttpInfo($object_id, $content_folder, $archived $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -12203,8 +10648,10 @@ public function updateFolderWithHttpInfo($object_id, $content_folder, $archived $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -12469,88 +10916,27 @@ public function updateFoldersWithHttpInfo($batch_input_json_node, $archived = nu switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolderWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -12564,34 +10950,11 @@ public function updateFoldersWithHttpInfo($batch_input_json_node, $archived = nu ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponseContentFolder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -12601,7 +10964,7 @@ public function updateFoldersWithHttpInfo($batch_input_json_node, $archived = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -12609,7 +10972,7 @@ public function updateFoldersWithHttpInfo($batch_input_json_node, $archived = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -12617,8 +10980,10 @@ public function updateFoldersWithHttpInfo($batch_input_json_node, $archived = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -12861,7 +11226,6 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -12871,8 +11235,10 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -13048,6 +11414,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/Pages/Api/SitePagesApi.php b/codegen/Cms/Pages/Api/SitePagesApi.php index 28e5dd55..0e4d7cbd 100644 --- a/codegen/Cms/Pages/Api/SitePagesApi.php +++ b/codegen/Cms/Pages/Api/SitePagesApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -269,8 +271,10 @@ public function archiveWithHttpInfo($object_id, $archived = null, string $conten $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -501,7 +505,6 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -511,8 +514,10 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -729,7 +734,6 @@ public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_ return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -739,8 +743,10 @@ public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -959,61 +965,21 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1027,34 +993,11 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1064,7 +1007,7 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1072,8 +1015,10 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1303,7 +1248,6 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -1313,7 +1257,7 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1321,8 +1265,10 @@ public function createWithHttpInfo($page, string $contentType = self::contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1541,61 +1487,21 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1609,34 +1515,11 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -1646,7 +1529,7 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1654,8 +1537,10 @@ public function createABTestVariationWithHttpInfo($ab_test_create_request_v_next $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1887,88 +1772,27 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1982,34 +1806,11 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -2019,7 +1820,7 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2027,7 +1828,7 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2035,8 +1836,10 @@ public function createBatchWithHttpInfo($batch_input_page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2268,61 +2071,21 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2336,34 +2099,11 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -2373,7 +2113,7 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2381,8 +2121,10 @@ public function createLangVariationWithHttpInfo($content_language_clone_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2612,7 +2354,6 @@ public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_ return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -2622,8 +2363,10 @@ public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2840,7 +2583,6 @@ public function endActiveABTestWithHttpInfo($ab_test_end_request_v_next, string return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -2850,8 +2592,10 @@ public function endActiveABTestWithHttpInfo($ab_test_end_request_v_next, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3074,61 +2818,21 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -3142,34 +2846,11 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -3179,7 +2860,7 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3187,8 +2868,10 @@ public function getByIdWithHttpInfo($object_id, $archived = null, $property = nu $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3447,61 +3130,21 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -3515,34 +3158,11 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -3552,7 +3172,7 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3560,8 +3180,10 @@ public function getDraftByIdWithHttpInfo($object_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -3814,61 +3436,21 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -3882,34 +3464,11 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalPageForwardPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -3919,7 +3478,7 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -3927,8 +3486,10 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -4288,61 +3849,21 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\VersionPage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\VersionPage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\VersionPage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionPage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -4356,34 +3877,11 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\VersionPage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\VersionPage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -4393,7 +3891,7 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -4401,8 +3899,10 @@ public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -4659,61 +4159,21 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -4727,34 +4187,11 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\CollectionResponseWithTotalVersionPage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -4764,7 +4201,7 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -4772,8 +4209,10 @@ public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $befo $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5043,7 +4482,6 @@ public function pushLiveWithHttpInfo($object_id, string $contentType = self::con return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -5053,8 +4491,10 @@ public function pushLiveWithHttpInfo($object_id, string $contentType = self::con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5276,88 +4716,27 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -5371,34 +4750,11 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -5408,7 +4764,7 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5416,7 +4772,7 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5424,8 +4780,10 @@ public function readBatchWithHttpInfo($batch_input_string, $archived = null, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5668,7 +5026,6 @@ public function rerunPreviousABTestWithHttpInfo($ab_test_rerun_request_v_next, s return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -5678,8 +5035,10 @@ public function rerunPreviousABTestWithHttpInfo($ab_test_rerun_request_v_next, s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -5896,7 +5255,6 @@ public function resetDraftWithHttpInfo($object_id, string $contentType = self::c return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -5906,8 +5264,10 @@ public function resetDraftWithHttpInfo($object_id, string $contentType = self::c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -6129,61 +5489,21 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -6197,34 +5517,11 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -6234,7 +5531,7 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -6242,8 +5539,10 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -6496,61 +5795,21 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -6564,34 +5823,11 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -6601,7 +5837,7 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -6609,8 +5845,10 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -6859,7 +6097,6 @@ public function scheduleWithHttpInfo($content_schedule_request_v_next, string $c return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -6869,8 +6106,10 @@ public function scheduleWithHttpInfo($content_schedule_request_v_next, string $c $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7087,7 +6326,6 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -7097,8 +6335,10 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7321,61 +6561,21 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -7389,34 +6589,11 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -7426,7 +6603,7 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7434,8 +6611,10 @@ public function updateWithHttpInfo($object_id, $page, $archived = null, string $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -7700,88 +6879,27 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); case 207: - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePageWithErrors', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -7795,34 +6913,11 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\BatchResponsePage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -7832,7 +6927,7 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7840,7 +6935,7 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7848,8 +6943,10 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8096,61 +7193,21 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Pages\Model\Page' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Page' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Page', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\Pages\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Pages\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Pages\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -8164,34 +7221,11 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\Pages\Model\Page'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\Pages\Model\Page', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -8201,7 +7235,7 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -8209,8 +7243,10 @@ public function updateDraftWithHttpInfo($object_id, $page, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8458,7 +7494,6 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -8468,8 +7503,10 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -8645,6 +7682,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/Pages/ApiException.php b/codegen/Cms/Pages/ApiException.php index 957db140..de82905d 100644 --- a/codegen/Cms/Pages/ApiException.php +++ b/codegen/Cms/Pages/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Cms/Pages/FormDataProcessor.php b/codegen/Cms/Pages/FormDataProcessor.php new file mode 100644 index 00000000..052f87a3 --- /dev/null +++ b/codegen/Cms/Pages/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Cms/Pages/HeaderSelector.php b/codegen/Cms/Pages/HeaderSelector.php index 15d57373..ffdcbc25 100644 --- a/codegen/Cms/Pages/HeaderSelector.php +++ b/codegen/Cms/Pages/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -371,12 +371,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -401,11 +401,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/AbTestEndRequestVNext.php b/codegen/Cms/Pages/Model/AbTestEndRequestVNext.php index 798a340b..9b7e7fd5 100644 --- a/codegen/Cms/Pages/Model/AbTestEndRequestVNext.php +++ b/codegen/Cms/Pages/Model/AbTestEndRequestVNext.php @@ -2,7 +2,7 @@ /** * AbTestEndRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -359,11 +359,11 @@ public function setAbTestId($ab_test_id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -371,12 +371,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -401,11 +401,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/AbTestRerunRequestVNext.php b/codegen/Cms/Pages/Model/AbTestRerunRequestVNext.php index efcea51b..a4f67aa8 100644 --- a/codegen/Cms/Pages/Model/AbTestRerunRequestVNext.php +++ b/codegen/Cms/Pages/Model/AbTestRerunRequestVNext.php @@ -2,7 +2,7 @@ /** * AbTestRerunRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -359,11 +359,11 @@ public function setAbTestId($ab_test_id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -371,12 +371,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -401,11 +401,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Angle.php b/codegen/Cms/Pages/Model/Angle.php index 7cb54a43..fd206942 100644 --- a/codegen/Cms/Pages/Model/Angle.php +++ b/codegen/Cms/Pages/Model/Angle.php @@ -2,7 +2,7 @@ /** * Angle * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -315,7 +315,7 @@ public function getUnits() /** * Sets units * - * @param string $units + * @param string $units units * * @return self */ @@ -342,7 +342,7 @@ public function getValue() /** * Sets value * - * @param float $value + * @param float $value value * * @return self */ @@ -358,11 +358,11 @@ public function setValue($value) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -370,12 +370,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -400,11 +400,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/AttachToLangPrimaryRequestVNext.php b/codegen/Cms/Pages/Model/AttachToLangPrimaryRequestVNext.php index 87a189fa..728e6f7a 100644 --- a/codegen/Cms/Pages/Model/AttachToLangPrimaryRequestVNext.php +++ b/codegen/Cms/Pages/Model/AttachToLangPrimaryRequestVNext.php @@ -2,7 +2,7 @@ /** * AttachToLangPrimaryRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -430,11 +430,11 @@ public function setPrimaryLanguage($primary_language) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -442,12 +442,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -472,11 +472,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BackgroundImage.php b/codegen/Cms/Pages/Model/BackgroundImage.php index 65ed9ecb..db74e443 100644 --- a/codegen/Cms/Pages/Model/BackgroundImage.php +++ b/codegen/Cms/Pages/Model/BackgroundImage.php @@ -2,7 +2,7 @@ /** * BackgroundImage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -325,7 +325,7 @@ public function getImageUrl() /** * Sets image_url * - * @param string $image_url + * @param string $image_url image_url * * @return self */ @@ -352,7 +352,7 @@ public function getBackgroundSize() /** * Sets background_size * - * @param string $background_size + * @param string $background_size background_size * * @return self */ @@ -379,7 +379,7 @@ public function getBackgroundPosition() /** * Sets background_position * - * @param string $background_position + * @param string $background_position background_position * * @return self */ @@ -395,11 +395,11 @@ public function setBackgroundPosition($background_position) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -407,12 +407,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -437,11 +437,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchInputContentFolder.php b/codegen/Cms/Pages/Model/BatchInputContentFolder.php index bfdc2f83..4eaa98ad 100644 --- a/codegen/Cms/Pages/Model/BatchInputContentFolder.php +++ b/codegen/Cms/Pages/Model/BatchInputContentFolder.php @@ -2,7 +2,7 @@ /** * BatchInputContentFolder * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setInputs($inputs) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchInputJsonNode.php b/codegen/Cms/Pages/Model/BatchInputJsonNode.php index a38d938e..f3090041 100644 --- a/codegen/Cms/Pages/Model/BatchInputJsonNode.php +++ b/codegen/Cms/Pages/Model/BatchInputJsonNode.php @@ -2,7 +2,7 @@ /** * BatchInputJsonNode * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setInputs($inputs) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchInputPage.php b/codegen/Cms/Pages/Model/BatchInputPage.php index 9652b9e9..9a478e7a 100644 --- a/codegen/Cms/Pages/Model/BatchInputPage.php +++ b/codegen/Cms/Pages/Model/BatchInputPage.php @@ -2,7 +2,7 @@ /** * BatchInputPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setInputs($inputs) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchInputString.php b/codegen/Cms/Pages/Model/BatchInputString.php index f9c8d062..8feceb9c 100644 --- a/codegen/Cms/Pages/Model/BatchInputString.php +++ b/codegen/Cms/Pages/Model/BatchInputString.php @@ -2,7 +2,7 @@ /** * BatchInputString * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setInputs($inputs) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchResponseContentFolder.php b/codegen/Cms/Pages/Model/BatchResponseContentFolder.php index 93b563c9..cac3f2de 100644 --- a/codegen/Cms/Pages/Model/BatchResponseContentFolder.php +++ b/codegen/Cms/Pages/Model/BatchResponseContentFolder.php @@ -2,7 +2,7 @@ /** * BatchResponseContentFolder * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -539,11 +539,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -551,12 +551,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -581,11 +581,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchResponseContentFolderWithErrors.php b/codegen/Cms/Pages/Model/BatchResponseContentFolderWithErrors.php index c0c5a0fc..f8561825 100644 --- a/codegen/Cms/Pages/Model/BatchResponseContentFolderWithErrors.php +++ b/codegen/Cms/Pages/Model/BatchResponseContentFolderWithErrors.php @@ -2,7 +2,7 @@ /** * BatchResponseContentFolderWithErrors * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -607,11 +607,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -619,12 +619,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -649,11 +649,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchResponsePage.php b/codegen/Cms/Pages/Model/BatchResponsePage.php index b7a81cf0..e4d0e7a3 100644 --- a/codegen/Cms/Pages/Model/BatchResponsePage.php +++ b/codegen/Cms/Pages/Model/BatchResponsePage.php @@ -2,7 +2,7 @@ /** * BatchResponsePage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -539,11 +539,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -551,12 +551,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -581,11 +581,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/BatchResponsePageWithErrors.php b/codegen/Cms/Pages/Model/BatchResponsePageWithErrors.php index f88a91b8..a7f77d4a 100644 --- a/codegen/Cms/Pages/Model/BatchResponsePageWithErrors.php +++ b/codegen/Cms/Pages/Model/BatchResponsePageWithErrors.php @@ -2,7 +2,7 @@ /** * BatchResponsePageWithErrors * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -607,11 +607,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -619,12 +619,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -649,11 +649,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/CollectionResponseWithTotalContentFolderForwardPaging.php b/codegen/Cms/Pages/Model/CollectionResponseWithTotalContentFolderForwardPaging.php index b89a0815..6ab98263 100644 --- a/codegen/Cms/Pages/Model/CollectionResponseWithTotalContentFolderForwardPaging.php +++ b/codegen/Cms/Pages/Model/CollectionResponseWithTotalContentFolderForwardPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponseWithTotalContentFolderForwardPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -393,11 +393,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +405,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +435,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/CollectionResponseWithTotalPageForwardPaging.php b/codegen/Cms/Pages/Model/CollectionResponseWithTotalPageForwardPaging.php index d2d6c268..71658376 100644 --- a/codegen/Cms/Pages/Model/CollectionResponseWithTotalPageForwardPaging.php +++ b/codegen/Cms/Pages/Model/CollectionResponseWithTotalPageForwardPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponseWithTotalPageForwardPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -393,11 +393,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +405,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +435,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionContentFolder.php b/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionContentFolder.php index 24026c0a..2d7ea902 100644 --- a/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionContentFolder.php +++ b/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionContentFolder.php @@ -2,7 +2,7 @@ /** * CollectionResponseWithTotalVersionContentFolder * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -393,11 +393,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +405,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +435,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionPage.php b/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionPage.php index 601371eb..21438196 100644 --- a/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionPage.php +++ b/codegen/Cms/Pages/Model/CollectionResponseWithTotalVersionPage.php @@ -2,7 +2,7 @@ /** * CollectionResponseWithTotalVersionPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -393,11 +393,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +405,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +435,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ColorStop.php b/codegen/Cms/Pages/Model/ColorStop.php index 3a9edd70..bf589abf 100644 --- a/codegen/Cms/Pages/Model/ColorStop.php +++ b/codegen/Cms/Pages/Model/ColorStop.php @@ -2,7 +2,7 @@ /** * ColorStop * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -321,11 +321,11 @@ public function setColor($color) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ContentCloneRequestVNext.php b/codegen/Cms/Pages/Model/ContentCloneRequestVNext.php index bf391673..3a00af34 100644 --- a/codegen/Cms/Pages/Model/ContentCloneRequestVNext.php +++ b/codegen/Cms/Pages/Model/ContentCloneRequestVNext.php @@ -2,7 +2,7 @@ /** * ContentCloneRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -356,11 +356,11 @@ public function setId($id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -368,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -398,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ContentFolder.php b/codegen/Cms/Pages/Model/ContentFolder.php index 683727c1..fdd8fa22 100644 --- a/codegen/Cms/Pages/Model/ContentFolder.php +++ b/codegen/Cms/Pages/Model/ContentFolder.php @@ -2,7 +2,7 @@ /** * ContentFolder * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -544,11 +544,11 @@ public function setUpdated($updated) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -556,12 +556,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -586,11 +586,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ContentLanguageCloneRequestVNext.php b/codegen/Cms/Pages/Model/ContentLanguageCloneRequestVNext.php index 513ef000..556aad62 100644 --- a/codegen/Cms/Pages/Model/ContentLanguageCloneRequestVNext.php +++ b/codegen/Cms/Pages/Model/ContentLanguageCloneRequestVNext.php @@ -2,7 +2,7 @@ /** * ContentLanguageCloneRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -390,11 +390,11 @@ public function setPrimaryLanguage($primary_language) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -402,12 +402,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -432,11 +432,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ContentLanguageVariation.php b/codegen/Cms/Pages/Model/ContentLanguageVariation.php index 77fd5b29..013e55e7 100644 --- a/codegen/Cms/Pages/Model/ContentLanguageVariation.php +++ b/codegen/Cms/Pages/Model/ContentLanguageVariation.php @@ -2,7 +2,7 @@ /** * ContentLanguageVariation * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -799,11 +799,11 @@ public function setSlug($slug) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -811,12 +811,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -841,11 +841,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ContentScheduleRequestVNext.php b/codegen/Cms/Pages/Model/ContentScheduleRequestVNext.php index 93ca56cf..0a5ba781 100644 --- a/codegen/Cms/Pages/Model/ContentScheduleRequestVNext.php +++ b/codegen/Cms/Pages/Model/ContentScheduleRequestVNext.php @@ -2,7 +2,7 @@ /** * ContentScheduleRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -359,11 +359,11 @@ public function setId($id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -371,12 +371,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -401,11 +401,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/DetachFromLangGroupRequestVNext.php b/codegen/Cms/Pages/Model/DetachFromLangGroupRequestVNext.php index d3f84033..65fc21ba 100644 --- a/codegen/Cms/Pages/Model/DetachFromLangGroupRequestVNext.php +++ b/codegen/Cms/Pages/Model/DetachFromLangGroupRequestVNext.php @@ -2,7 +2,7 @@ /** * DetachFromLangGroupRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setId($id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Error.php b/codegen/Cms/Pages/Model/Error.php index 64112543..37cb3fb5 100644 --- a/codegen/Cms/Pages/Model/Error.php +++ b/codegen/Cms/Pages/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ErrorDetail.php b/codegen/Cms/Pages/Model/ErrorDetail.php index 7c401aa2..a55abae1 100644 --- a/codegen/Cms/Pages/Model/ErrorDetail.php +++ b/codegen/Cms/Pages/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ForwardPaging.php b/codegen/Cms/Pages/Model/ForwardPaging.php index b587e720..a675b693 100644 --- a/codegen/Cms/Pages/Model/ForwardPaging.php +++ b/codegen/Cms/Pages/Model/ForwardPaging.php @@ -2,7 +2,7 @@ /** * ForwardPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -319,11 +319,11 @@ public function setNext($next) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -331,12 +331,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -361,11 +361,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Gradient.php b/codegen/Cms/Pages/Model/Gradient.php index ed3c59a0..f9d4cd43 100644 --- a/codegen/Cms/Pages/Model/Gradient.php +++ b/codegen/Cms/Pages/Model/Gradient.php @@ -2,7 +2,7 @@ /** * Gradient * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -379,7 +379,7 @@ public function getColors() /** * Sets colors * - * @param \HubSpot\Client\Cms\Pages\Model\ColorStop[] $colors + * @param \HubSpot\Client\Cms\Pages\Model\ColorStop[] $colors colors * * @return self */ @@ -395,11 +395,11 @@ public function setColors($colors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -407,12 +407,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -437,11 +437,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/LayoutSection.php b/codegen/Cms/Pages/Model/LayoutSection.php index 7812c81e..390aa45a 100644 --- a/codegen/Cms/Pages/Model/LayoutSection.php +++ b/codegen/Cms/Pages/Model/LayoutSection.php @@ -2,7 +2,7 @@ /** * LayoutSection * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -425,7 +425,7 @@ public function getCssStyle() /** * Sets css_style * - * @param string $css_style + * @param string $css_style css_style * * @return self */ @@ -452,7 +452,7 @@ public function getLabel() /** * Sets label * - * @param string $label + * @param string $label label * * @return self */ @@ -479,7 +479,7 @@ public function getType() /** * Sets type * - * @param string $type + * @param string $type type * * @return self */ @@ -506,7 +506,7 @@ public function getParams() /** * Sets params * - * @param array $params + * @param array $params params * * @return self */ @@ -533,7 +533,7 @@ public function getRows() /** * Sets rows * - * @param array[] $rows + * @param array[] $rows rows * * @return self */ @@ -560,7 +560,7 @@ public function getRowMetaData() /** * Sets row_meta_data * - * @param \HubSpot\Client\Cms\Pages\Model\RowMetaData[] $row_meta_data + * @param \HubSpot\Client\Cms\Pages\Model\RowMetaData[] $row_meta_data row_meta_data * * @return self */ @@ -587,7 +587,7 @@ public function getCells() /** * Sets cells * - * @param \HubSpot\Client\Cms\Pages\Model\LayoutSection[] $cells + * @param \HubSpot\Client\Cms\Pages\Model\LayoutSection[] $cells cells * * @return self */ @@ -614,7 +614,7 @@ public function getCssClass() /** * Sets css_class * - * @param string $css_class + * @param string $css_class css_class * * @return self */ @@ -641,7 +641,7 @@ public function getW() /** * Sets w * - * @param int $w + * @param int $w w * * @return self */ @@ -668,7 +668,7 @@ public function getCssId() /** * Sets css_id * - * @param string $css_id + * @param string $css_id css_id * * @return self */ @@ -695,7 +695,7 @@ public function getX() /** * Sets x * - * @param int $x + * @param int $x x * * @return self */ @@ -722,7 +722,7 @@ public function getName() /** * Sets name * - * @param string $name + * @param string $name name * * @return self */ @@ -765,11 +765,11 @@ public function setStyles($styles) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -777,12 +777,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -807,11 +807,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/ModelInterface.php b/codegen/Cms/Pages/Model/ModelInterface.php index eee7c6b2..955c43a2 100644 --- a/codegen/Cms/Pages/Model/ModelInterface.php +++ b/codegen/Cms/Pages/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Cms/Pages/Model/NextPage.php b/codegen/Cms/Pages/Model/NextPage.php index b5c94b25..87436b03 100644 --- a/codegen/Cms/Pages/Model/NextPage.php +++ b/codegen/Cms/Pages/Model/NextPage.php @@ -2,7 +2,7 @@ /** * NextPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -313,7 +313,7 @@ public function getLink() /** * Sets link * - * @param string|null $link + * @param string|null $link A URL that can be used to retrieve the next page results. * * @return self */ @@ -340,7 +340,7 @@ public function getAfter() /** * Sets after * - * @param string $after + * @param string $after A paging cursor token for retrieving subsequent pages. * * @return self */ @@ -356,11 +356,11 @@ public function setAfter($after) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -368,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -398,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Page.php b/codegen/Cms/Pages/Model/Page.php index 639812d2..1aeb100b 100644 --- a/codegen/Cms/Pages/Model/Page.php +++ b/codegen/Cms/Pages/Model/Page.php @@ -2,7 +2,7 @@ /** * Page * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -3504,7 +3504,7 @@ public function getLayoutSections() /** * Sets layout_sections * - * @param array $layout_sections + * @param array $layout_sections layout_sections * * @return self */ @@ -3946,7 +3946,7 @@ public function getThemeSettingsValues() /** * Sets theme_settings_values * - * @param array $theme_settings_values + * @param array $theme_settings_values theme_settings_values * * @return self */ @@ -4134,11 +4134,11 @@ public function setLinkRelCanonicalUrl($link_rel_canonical_url) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -4146,12 +4146,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -4176,11 +4176,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Paging.php b/codegen/Cms/Pages/Model/Paging.php index 14fab9b7..9a1ee098 100644 --- a/codegen/Cms/Pages/Model/Paging.php +++ b/codegen/Cms/Pages/Model/Paging.php @@ -2,7 +2,7 @@ /** * Paging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -353,11 +353,11 @@ public function setPrev($prev) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -365,12 +365,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -395,11 +395,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/PreviousPage.php b/codegen/Cms/Pages/Model/PreviousPage.php index e36be4bd..147f4d0e 100644 --- a/codegen/Cms/Pages/Model/PreviousPage.php +++ b/codegen/Cms/Pages/Model/PreviousPage.php @@ -2,7 +2,7 @@ /** * PreviousPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -313,7 +313,7 @@ public function getBefore() /** * Sets before * - * @param string $before + * @param string $before A paging cursor token for retrieving previous pages. * * @return self */ @@ -340,7 +340,7 @@ public function getLink() /** * Sets link * - * @param string|null $link + * @param string|null $link A URL that can be used to retrieve the previous pages' results. * * @return self */ @@ -356,11 +356,11 @@ public function setLink($link) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -368,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -398,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/RGBAColor.php b/codegen/Cms/Pages/Model/RGBAColor.php index a621763b..0c43bd90 100644 --- a/codegen/Cms/Pages/Model/RGBAColor.php +++ b/codegen/Cms/Pages/Model/RGBAColor.php @@ -2,7 +2,7 @@ /** * RGBAColor * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -433,11 +433,11 @@ public function setG($g) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -445,12 +445,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -475,11 +475,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/RowMetaData.php b/codegen/Cms/Pages/Model/RowMetaData.php index 5fc87f41..e6179cf8 100644 --- a/codegen/Cms/Pages/Model/RowMetaData.php +++ b/codegen/Cms/Pages/Model/RowMetaData.php @@ -2,7 +2,7 @@ /** * RowMetaData * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -315,7 +315,7 @@ public function getCssClass() /** * Sets css_class * - * @param string $css_class + * @param string $css_class css_class * * @return self */ @@ -358,11 +358,11 @@ public function setStyles($styles) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -370,12 +370,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -400,11 +400,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/SetNewLanguagePrimaryRequestVNext.php b/codegen/Cms/Pages/Model/SetNewLanguagePrimaryRequestVNext.php index 4b3beaf6..a8b6c920 100644 --- a/codegen/Cms/Pages/Model/SetNewLanguagePrimaryRequestVNext.php +++ b/codegen/Cms/Pages/Model/SetNewLanguagePrimaryRequestVNext.php @@ -2,7 +2,7 @@ /** * SetNewLanguagePrimaryRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setId($id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/SideOrCorner.php b/codegen/Cms/Pages/Model/SideOrCorner.php index 92735e54..13d75753 100644 --- a/codegen/Cms/Pages/Model/SideOrCorner.php +++ b/codegen/Cms/Pages/Model/SideOrCorner.php @@ -2,7 +2,7 @@ /** * SideOrCorner * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -315,7 +315,7 @@ public function getHorizontalSide() /** * Sets horizontal_side * - * @param string $horizontal_side + * @param string $horizontal_side horizontal_side * * @return self */ @@ -342,7 +342,7 @@ public function getVerticalSide() /** * Sets vertical_side * - * @param string $vertical_side + * @param string $vertical_side vertical_side * * @return self */ @@ -358,11 +358,11 @@ public function setVerticalSide($vertical_side) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -370,12 +370,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -400,11 +400,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/StandardError.php b/codegen/Cms/Pages/Model/StandardError.php index 124ba1e2..cfdbcf19 100644 --- a/codegen/Cms/Pages/Model/StandardError.php +++ b/codegen/Cms/Pages/Model/StandardError.php @@ -2,7 +2,7 @@ /** * StandardError * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -575,11 +575,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -587,12 +587,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -617,11 +617,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/Styles.php b/codegen/Cms/Pages/Model/Styles.php index c7ff0074..d137f0b4 100644 --- a/codegen/Cms/Pages/Model/Styles.php +++ b/codegen/Cms/Pages/Model/Styles.php @@ -2,7 +2,7 @@ /** * Styles * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -392,7 +392,7 @@ public function getFlexboxPositioning() /** * Sets flexbox_positioning * - * @param string $flexbox_positioning + * @param string $flexbox_positioning flexbox_positioning * * @return self */ @@ -446,7 +446,7 @@ public function getForceFullWidthSection() /** * Sets force_full_width_section * - * @param bool $force_full_width_section + * @param bool $force_full_width_section force_full_width_section * * @return self */ @@ -473,7 +473,7 @@ public function getVerticalAlignment() /** * Sets vertical_alignment * - * @param string $vertical_alignment + * @param string $vertical_alignment vertical_alignment * * @return self */ @@ -500,7 +500,7 @@ public function getMaxWidthSectionCentering() /** * Sets max_width_section_centering * - * @param int $max_width_section_centering + * @param int $max_width_section_centering max_width_section_centering * * @return self */ @@ -543,11 +543,11 @@ public function setBackgroundGradient($background_gradient) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -555,12 +555,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -585,11 +585,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/UpdateLanguagesRequestVNext.php b/codegen/Cms/Pages/Model/UpdateLanguagesRequestVNext.php index 3aa8d459..a1836bbe 100644 --- a/codegen/Cms/Pages/Model/UpdateLanguagesRequestVNext.php +++ b/codegen/Cms/Pages/Model/UpdateLanguagesRequestVNext.php @@ -2,7 +2,7 @@ /** * UpdateLanguagesRequestVNext * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -359,11 +359,11 @@ public function setPrimaryId($primary_id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -371,12 +371,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -401,11 +401,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/VersionContentFolder.php b/codegen/Cms/Pages/Model/VersionContentFolder.php index 65582b59..959d402a 100644 --- a/codegen/Cms/Pages/Model/VersionContentFolder.php +++ b/codegen/Cms/Pages/Model/VersionContentFolder.php @@ -2,7 +2,7 @@ /** * VersionContentFolder * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -433,11 +433,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -445,12 +445,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -475,11 +475,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/VersionPage.php b/codegen/Cms/Pages/Model/VersionPage.php index bae25f8d..8f7dcf53 100644 --- a/codegen/Cms/Pages/Model/VersionPage.php +++ b/codegen/Cms/Pages/Model/VersionPage.php @@ -2,7 +2,7 @@ /** * VersionPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -433,11 +433,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -445,12 +445,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -475,11 +475,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/Model/VersionUser.php b/codegen/Cms/Pages/Model/VersionUser.php index 519646d6..68a01c69 100644 --- a/codegen/Cms/Pages/Model/VersionUser.php +++ b/codegen/Cms/Pages/Model/VersionUser.php @@ -2,7 +2,7 @@ /** * VersionUser * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -396,11 +396,11 @@ public function setEmail($email) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -408,12 +408,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -438,11 +438,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/Pages/ObjectSerializer.php b/codegen/Cms/Pages/ObjectSerializer.php index a162189a..02d6dc63 100644 --- a/codegen/Cms/Pages/ObjectSerializer.php +++ b/codegen/Cms/Pages/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\Pages @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Cms/SiteSearch/Api/PublicApi.php b/codegen/Cms/SiteSearch/Api/PublicApi.php index 207f7b79..932a8f84 100644 --- a/codegen/Cms/SiteSearch/Api/PublicApi.php +++ b/codegen/Cms/SiteSearch/Api/PublicApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SiteSearch\Model\IndexedData' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\SiteSearch\Model\IndexedData', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\IndexedData', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SiteSearch\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SiteSearch\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\SiteSearch\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -254,34 +217,11 @@ public function getByIdWithHttpInfo($content_id, $type = null, string $contentTy ); } - $returnType = '\HubSpot\Client\Cms\SiteSearch\Model\IndexedData'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\IndexedData', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -291,7 +231,7 @@ public function getByIdWithHttpInfo($content_id, $type = null, string $contentTy $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -299,8 +239,10 @@ public function getByIdWithHttpInfo($content_id, $type = null, string $contentTy $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -581,61 +523,21 @@ public function searchWithHttpInfo($q = null, $limit = null, $offset = null, $la switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SiteSearch\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SiteSearch\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\SiteSearch\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -649,34 +551,11 @@ public function searchWithHttpInfo($q = null, $limit = null, $offset = null, $la ); } - $returnType = '\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SiteSearch\Model\PublicSearchResults', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -686,7 +565,7 @@ public function searchWithHttpInfo($q = null, $limit = null, $offset = null, $la $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -694,8 +573,10 @@ public function searchWithHttpInfo($q = null, $limit = null, $offset = null, $la $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1088,6 +969,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/SiteSearch/ApiException.php b/codegen/Cms/SiteSearch/ApiException.php index 5110a8fe..bb4f8032 100644 --- a/codegen/Cms/SiteSearch/ApiException.php +++ b/codegen/Cms/SiteSearch/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Cms/SiteSearch/FormDataProcessor.php b/codegen/Cms/SiteSearch/FormDataProcessor.php new file mode 100644 index 00000000..4ae25f1e --- /dev/null +++ b/codegen/Cms/SiteSearch/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Cms/SiteSearch/HeaderSelector.php b/codegen/Cms/SiteSearch/HeaderSelector.php index 1218bd9a..b2d5d492 100644 --- a/codegen/Cms/SiteSearch/HeaderSelector.php +++ b/codegen/Cms/SiteSearch/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -2468,12 +2468,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -2498,11 +2498,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/Model/Error.php b/codegen/Cms/SiteSearch/Model/Error.php index 07b94af2..c97b63d6 100644 --- a/codegen/Cms/SiteSearch/Model/Error.php +++ b/codegen/Cms/SiteSearch/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/Model/ErrorDetail.php b/codegen/Cms/SiteSearch/Model/ErrorDetail.php index f6e5109b..459f7993 100644 --- a/codegen/Cms/SiteSearch/Model/ErrorDetail.php +++ b/codegen/Cms/SiteSearch/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/Model/IndexedData.php b/codegen/Cms/SiteSearch/Model/IndexedData.php index 221f957a..2c217c5d 100644 --- a/codegen/Cms/SiteSearch/Model/IndexedData.php +++ b/codegen/Cms/SiteSearch/Model/IndexedData.php @@ -2,7 +2,7 @@ /** * IndexedData * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -436,11 +436,11 @@ public function setFields($fields) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -448,12 +448,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -478,11 +478,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/Model/IndexedField.php b/codegen/Cms/SiteSearch/Model/IndexedField.php index 322feda9..6448ea06 100644 --- a/codegen/Cms/SiteSearch/Model/IndexedField.php +++ b/codegen/Cms/SiteSearch/Model/IndexedField.php @@ -2,7 +2,7 @@ /** * IndexedField * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -432,11 +432,11 @@ public function setMetadataField($metadata_field) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -444,12 +444,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -474,11 +474,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/Model/ModelInterface.php b/codegen/Cms/SiteSearch/Model/ModelInterface.php index c0ddc1fc..6c09ca1b 100644 --- a/codegen/Cms/SiteSearch/Model/ModelInterface.php +++ b/codegen/Cms/SiteSearch/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Cms/SiteSearch/Model/PublicSearchResults.php b/codegen/Cms/SiteSearch/Model/PublicSearchResults.php index 2d856ebb..6a0f0fbf 100644 --- a/codegen/Cms/SiteSearch/Model/PublicSearchResults.php +++ b/codegen/Cms/SiteSearch/Model/PublicSearchResults.php @@ -2,7 +2,7 @@ /** * PublicSearchResults * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -503,11 +503,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -515,12 +515,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -545,11 +545,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/SiteSearch/ObjectSerializer.php b/codegen/Cms/SiteSearch/ObjectSerializer.php index 5b9742b1..a63ade05 100644 --- a/codegen/Cms/SiteSearch/ObjectSerializer.php +++ b/codegen/Cms/SiteSearch/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SiteSearch @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Cms/UrlRedirects/Api/RedirectsApi.php b/codegen/Cms/UrlRedirects/Api/RedirectsApi.php index 7d3f1f93..8903801c 100644 --- a/codegen/Cms/UrlRedirects/Api/RedirectsApi.php +++ b/codegen/Cms/UrlRedirects/Api/RedirectsApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -201,8 +203,10 @@ public function archiveWithHttpInfo($url_redirect_id, string $contentType = self $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -422,61 +426,21 @@ public function createWithHttpInfo($url_mapping_create_request_body, string $con switch($statusCode) { case 201: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -490,34 +454,11 @@ public function createWithHttpInfo($url_mapping_create_request_body, string $con ); } - $returnType = '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -527,7 +468,7 @@ public function createWithHttpInfo($url_mapping_create_request_body, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -535,8 +476,10 @@ public function createWithHttpInfo($url_mapping_create_request_body, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -768,61 +711,21 @@ public function getByIdWithHttpInfo($url_redirect_id, string $contentType = self switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -836,34 +739,11 @@ public function getByIdWithHttpInfo($url_redirect_id, string $contentType = self ); } - $returnType = '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -873,7 +753,7 @@ public function getByIdWithHttpInfo($url_redirect_id, string $contentType = self $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -881,8 +761,10 @@ public function getByIdWithHttpInfo($url_redirect_id, string $contentType = self $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1133,61 +1015,21 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1201,34 +1043,11 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ ); } - $returnType = '\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\CollectionResponseWithTotalUrlMappingForwardPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1238,7 +1057,7 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1246,8 +1065,10 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1594,61 +1415,21 @@ public function updateWithHttpInfo($url_redirect_id, $url_mapping, string $conte switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\UrlRedirects\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\UrlRedirects\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1662,34 +1443,11 @@ public function updateWithHttpInfo($url_redirect_id, $url_mapping, string $conte ); } - $returnType = '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\UrlRedirects\Model\UrlMapping', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1699,7 +1457,7 @@ public function updateWithHttpInfo($url_redirect_id, $url_mapping, string $conte $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1707,8 +1465,10 @@ public function updateWithHttpInfo($url_redirect_id, $url_mapping, string $conte $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1915,6 +1675,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Cms/UrlRedirects/ApiException.php b/codegen/Cms/UrlRedirects/ApiException.php index 0597ecf3..016a67ab 100644 --- a/codegen/Cms/UrlRedirects/ApiException.php +++ b/codegen/Cms/UrlRedirects/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Cms/UrlRedirects/FormDataProcessor.php b/codegen/Cms/UrlRedirects/FormDataProcessor.php new file mode 100644 index 00000000..23f32f37 --- /dev/null +++ b/codegen/Cms/UrlRedirects/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Cms/UrlRedirects/HeaderSelector.php b/codegen/Cms/UrlRedirects/HeaderSelector.php index 875088de..b40f4ef6 100644 --- a/codegen/Cms/UrlRedirects/HeaderSelector.php +++ b/codegen/Cms/UrlRedirects/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -404,12 +404,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -434,11 +434,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/Error.php b/codegen/Cms/UrlRedirects/Model/Error.php index 59cce5a1..937b1d7b 100644 --- a/codegen/Cms/UrlRedirects/Model/Error.php +++ b/codegen/Cms/UrlRedirects/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/ErrorDetail.php b/codegen/Cms/UrlRedirects/Model/ErrorDetail.php index b4f18fbb..e5fc20f8 100644 --- a/codegen/Cms/UrlRedirects/Model/ErrorDetail.php +++ b/codegen/Cms/UrlRedirects/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/ForwardPaging.php b/codegen/Cms/UrlRedirects/Model/ForwardPaging.php index 53d173f4..c1427985 100644 --- a/codegen/Cms/UrlRedirects/Model/ForwardPaging.php +++ b/codegen/Cms/UrlRedirects/Model/ForwardPaging.php @@ -2,7 +2,7 @@ /** * ForwardPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -318,11 +318,11 @@ public function setNext($next) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -330,12 +330,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -360,11 +360,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/ModelInterface.php b/codegen/Cms/UrlRedirects/Model/ModelInterface.php index 4bdc0f45..aee43cb8 100644 --- a/codegen/Cms/UrlRedirects/Model/ModelInterface.php +++ b/codegen/Cms/UrlRedirects/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Cms/UrlRedirects/Model/NextPage.php b/codegen/Cms/UrlRedirects/Model/NextPage.php index 09366c85..df122b6d 100644 --- a/codegen/Cms/UrlRedirects/Model/NextPage.php +++ b/codegen/Cms/UrlRedirects/Model/NextPage.php @@ -2,7 +2,7 @@ /** * NextPage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -35,6 +35,7 @@ * NextPage Class Doc Comment * * @category Class + * @description Specifies the paging information needed to retrieve the next set of results in a paginated API response * @package HubSpot\Client\Cms\UrlRedirects * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -312,7 +313,7 @@ public function getLink() /** * Sets link * - * @param string|null $link link + * @param string|null $link A URL that can be used to retrieve the next page results. * * @return self */ @@ -339,7 +340,7 @@ public function getAfter() /** * Sets after * - * @param string $after after + * @param string $after A paging cursor token for retrieving subsequent pages. * * @return self */ @@ -355,11 +356,11 @@ public function setAfter($after) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -367,12 +368,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -397,11 +398,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/UrlMapping.php b/codegen/Cms/UrlRedirects/Model/UrlMapping.php index 88ca7095..8436e8d6 100644 --- a/codegen/Cms/UrlRedirects/Model/UrlMapping.php +++ b/codegen/Cms/UrlRedirects/Model/UrlMapping.php @@ -2,7 +2,7 @@ /** * UrlMapping * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -759,11 +759,11 @@ public function setUpdated($updated) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -771,12 +771,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -801,11 +801,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/Model/UrlMappingCreateRequestBody.php b/codegen/Cms/UrlRedirects/Model/UrlMappingCreateRequestBody.php index d8e4a8da..2dd531cc 100644 --- a/codegen/Cms/UrlRedirects/Model/UrlMappingCreateRequestBody.php +++ b/codegen/Cms/UrlRedirects/Model/UrlMappingCreateRequestBody.php @@ -2,7 +2,7 @@ /** * UrlMappingCreateRequestBody * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -633,11 +633,11 @@ public function setPrecedence($precedence) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -645,12 +645,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -675,11 +675,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Cms/UrlRedirects/ObjectSerializer.php b/codegen/Cms/UrlRedirects/ObjectSerializer.php index f419acab..14bd582e 100644 --- a/codegen/Cms/UrlRedirects/ObjectSerializer.php +++ b/codegen/Cms/UrlRedirects/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\UrlRedirects @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } }