diff --git a/codegen/Cms/SourceCode/Api/ContentApi.php b/codegen/Cms/SourceCode/Api/ContentApi.php index f4e02c72..084a7eb8 100644 --- a/codegen/Cms/SourceCode/Api/ContentApi.php +++ b/codegen/Cms/SourceCode/Api/ContentApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -200,8 +202,10 @@ public function archiveWithHttpInfo($environment, $path, string $contentType = s $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -448,61 +452,21 @@ public function createWithHttpInfo($environment, $path, $file = null, string $co switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata' !== '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\SourceCode\Model\AssetFileMetadata', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -516,34 +480,11 @@ public function createWithHttpInfo($environment, $path, $file = null, string $co ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata'; - 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\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -553,7 +494,7 @@ public function createWithHttpInfo($environment, $path, $file = null, string $co $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -561,8 +502,10 @@ public function createWithHttpInfo($environment, $path, $file = null, string $co $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -707,17 +650,14 @@ public function createRequest($environment, $path, $file = null, string $content } // form params - if ($file !== null) { - $multipart = true; - $formParams['file'] = []; - $paramFiles = is_array($file) ? $file : [$file]; - foreach ($paramFiles as $paramFile) { - $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'file' => $file, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; $multipart = true; $headers = $this->headerSelector->selectHeaders( @@ -840,61 +780,21 @@ public function createOrUpdateWithHttpInfo($environment, $path, $file = null, st switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata' !== '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\SourceCode\Model\AssetFileMetadata', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -908,34 +808,11 @@ public function createOrUpdateWithHttpInfo($environment, $path, $file = null, st ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata'; - 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\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -945,7 +822,7 @@ public function createOrUpdateWithHttpInfo($environment, $path, $file = null, st $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -953,8 +830,10 @@ public function createOrUpdateWithHttpInfo($environment, $path, $file = null, st $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1096,17 +975,14 @@ public function createOrUpdateRequest($environment, $path, $file = null, string } // form params - if ($file !== null) { - $multipart = true; - $formParams['file'] = []; - $paramFiles = is_array($file) ? $file : [$file]; - foreach ($paramFiles as $paramFile) { - $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'file' => $file, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; $multipart = true; $headers = $this->headerSelector->selectHeaders( @@ -1177,7 +1053,7 @@ public function createOrUpdateRequest($environment, $path, $file = null, string * * @throws \HubSpot\Client\Cms\SourceCode\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\SourceCode\Model\Error + * @return \SplFileObject|\HubSpot\Client\Cms\SourceCode\Model\Error */ public function download($environment, $path, string $contentType = self::contentTypes['download'][0]) { @@ -1196,7 +1072,7 @@ public function download($environment, $path, string $contentType = self::conten * * @throws \HubSpot\Client\Cms\SourceCode\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\SourceCode\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of \SplFileObject|\HubSpot\Client\Cms\SourceCode\Model\Error, HTTP status code, HTTP response headers (array of strings) */ public function downloadWithHttpInfo($environment, $path, string $contentType = self::contentTypes['download'][0]) { @@ -1226,35 +1102,22 @@ public function downloadWithHttpInfo($environment, $path, string $contentType = switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\SplFileObject', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1268,36 +1131,21 @@ public function downloadWithHttpInfo($environment, $path, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\Error'; - 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( + '\SplFileObject', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1305,8 +1153,10 @@ public function downloadWithHttpInfo($environment, $path, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1347,7 +1197,7 @@ function ($response) { */ public function downloadAsyncWithHttpInfo($environment, $path, string $contentType = self::contentTypes['download'][0]) { - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\Error'; + $returnType = '\SplFileObject'; $request = $this->downloadRequest($environment, $path, $contentType); return $this->client @@ -1445,7 +1295,7 @@ public function downloadRequest($environment, $path, string $contentType = self: $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/octet-stream', '*/*', ], $contentType, $multipart ); @@ -1517,6 +1367,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/SourceCode/Api/ExtractApi.php b/codegen/Cms/SourceCode/Api/ExtractApi.php index 496a0a71..e3af2db9 100644 --- a/codegen/Cms/SourceCode/Api/ExtractApi.php +++ b/codegen/Cms/SourceCode/Api/ExtractApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\Model\TaskLocator' !== '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\SourceCode\Model\TaskLocator', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\TaskLocator', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -252,34 +215,11 @@ public function doAsyncWithHttpInfo($file_extract_request, string $contentType = ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\TaskLocator'; - 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\SourceCode\Model\TaskLocator', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 202: @@ -289,7 +229,7 @@ public function doAsyncWithHttpInfo($file_extract_request, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -297,8 +237,10 @@ public function doAsyncWithHttpInfo($file_extract_request, string $contentType = $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -530,61 +472,21 @@ public function getAsyncStatusWithHttpInfo($task_id, string $contentType = self: switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\SourceCode\Model\ActionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\Model\ActionResponse' !== '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\SourceCode\Model\ActionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\ActionResponse', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -598,34 +500,11 @@ public function getAsyncStatusWithHttpInfo($task_id, string $contentType = self: ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\ActionResponse'; - 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\SourceCode\Model\ActionResponse', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -635,7 +514,7 @@ public function getAsyncStatusWithHttpInfo($task_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -643,8 +522,10 @@ public function getAsyncStatusWithHttpInfo($task_id, string $contentType = self: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -834,6 +715,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/SourceCode/Api/MetadataApi.php b/codegen/Cms/SourceCode/Api/MetadataApi.php index 58e2a2b2..a3f30d26 100644 --- a/codegen/Cms/SourceCode/Api/MetadataApi.php +++ b/codegen/Cms/SourceCode/Api/MetadataApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata' !== '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\SourceCode\Model\AssetFileMetadata', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -253,34 +216,11 @@ public function getWithHttpInfo($environment, $path, $properties = null, string ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\AssetFileMetadata'; - 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\SourceCode\Model\AssetFileMetadata', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -290,7 +230,7 @@ public function getWithHttpInfo($environment, $path, $properties = null, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -298,8 +238,10 @@ public function getWithHttpInfo($environment, $path, $properties = null, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -523,6 +465,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/SourceCode/Api/ValidationApi.php b/codegen/Cms/SourceCode/Api/ValidationApi.php index 20a313e8..737196f6 100644 --- a/codegen/Cms/SourceCode/Api/ValidationApi.php +++ b/codegen/Cms/SourceCode/Api/ValidationApi.php @@ -1,7 +1,7 @@ doValidateWithHttpInfo($path, $file, $contentType); + list($response) = $this->doValidateWithHttpInfo($environment, $path, $file, $contentType); return $response; } @@ -146,6 +150,7 @@ public function doValidate($path, $file = null, string $contentType = self::cont * * Validate the contents of a file * + * @param string $environment (required) * @param string $path The file system location of the file. (required) * @param \SplFileObject|null $file (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['doValidate'] to see the possible values for this operation @@ -154,9 +159,9 @@ public function doValidate($path, $file = null, string $contentType = self::cont * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Cms\SourceCode\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function doValidateWithHttpInfo($path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) + public function doValidateWithHttpInfo($environment, $path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) { - $request = $this->doValidateRequest($path, $file, $contentType); + $request = $this->doValidateRequest($environment, $path, $file, $contentType); try { $options = $this->createHttpClientOption(); @@ -183,34 +188,15 @@ public function doValidateWithHttpInfo($path, $file = null, string $contentType switch($statusCode) { default: - if ('\HubSpot\Client\Cms\SourceCode\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\SourceCode\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\SourceCode\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Cms\SourceCode\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -224,34 +210,11 @@ public function doValidateWithHttpInfo($path, $file = null, string $contentType ); } - $returnType = '\HubSpot\Client\Cms\SourceCode\Model\Error'; - 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\SourceCode\Model\Error', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -261,8 +224,10 @@ public function doValidateWithHttpInfo($path, $file = null, string $contentType $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -272,6 +237,7 @@ public function doValidateWithHttpInfo($path, $file = null, string $contentType * * Validate the contents of a file * + * @param string $environment (required) * @param string $path The file system location of the file. (required) * @param \SplFileObject|null $file (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['doValidate'] to see the possible values for this operation @@ -279,9 +245,9 @@ public function doValidateWithHttpInfo($path, $file = null, string $contentType * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function doValidateAsync($path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) + public function doValidateAsync($environment, $path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) { - return $this->doValidateAsyncWithHttpInfo($path, $file, $contentType) + return $this->doValidateAsyncWithHttpInfo($environment, $path, $file, $contentType) ->then( function ($response) { return $response[0]; @@ -294,6 +260,7 @@ function ($response) { * * Validate the contents of a file * + * @param string $environment (required) * @param string $path The file system location of the file. (required) * @param \SplFileObject|null $file (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['doValidate'] to see the possible values for this operation @@ -301,10 +268,10 @@ function ($response) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function doValidateAsyncWithHttpInfo($path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) + public function doValidateAsyncWithHttpInfo($environment, $path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) { $returnType = '\HubSpot\Client\Cms\SourceCode\Model\Error'; - $request = $this->doValidateRequest($path, $file, $contentType); + $request = $this->doValidateRequest($environment, $path, $file, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -345,6 +312,7 @@ function ($exception) { /** * Create request for operation 'doValidate' * + * @param string $environment (required) * @param string $path The file system location of the file. (required) * @param \SplFileObject|null $file (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['doValidate'] to see the possible values for this operation @@ -352,9 +320,19 @@ function ($exception) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function doValidateRequest($path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) + public function doValidateRequest($environment, $path, $file = null, string $contentType = self::contentTypes['doValidate'][0]) { + // verify the required parameter 'environment' is set + if ($environment === null || (is_array($environment) && count($environment) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $environment when calling doValidate' + ); + } + if (!preg_match("/.+/", $environment)) { + throw new \InvalidArgumentException("invalid value for \"environment\" when calling ValidationApi.doValidate, must conform to the pattern /.+/."); + } + // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( @@ -376,6 +354,14 @@ public function doValidateRequest($path, $file = null, string $contentType = sel + // path params + if ($environment !== null) { + $resourcePath = str_replace( + '{' . 'environment' . '}', + ObjectSerializer::toPathValue($environment), + $resourcePath + ); + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -386,17 +372,14 @@ public function doValidateRequest($path, $file = null, string $contentType = sel } // form params - if ($file !== null) { - $multipart = true; - $formParams['file'] = []; - $paramFiles = is_array($file) ? $file : [$file]; - foreach ($paramFiles as $paramFile) { - $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'file' => $file, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; $multipart = true; $headers = $this->headerSelector->selectHeaders( @@ -472,6 +455,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/SourceCode/ApiException.php b/codegen/Cms/SourceCode/ApiException.php index 2ef6e4e6..668d7d3a 100644 --- a/codegen/Cms/SourceCode/ApiException.php +++ b/codegen/Cms/SourceCode/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/SourceCode/FormDataProcessor.php b/codegen/Cms/SourceCode/FormDataProcessor.php new file mode 100644 index 00000000..8802fca9 --- /dev/null +++ b/codegen/Cms/SourceCode/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/SourceCode/HeaderSelector.php b/codegen/Cms/SourceCode/HeaderSelector.php index 89cd7039..74dda36d 100644 --- a/codegen/Cms/SourceCode/HeaderSelector.php +++ b/codegen/Cms/SourceCode/HeaderSelector.php @@ -1,7 +1,7 @@ '\DateTime', + 'links' => 'array', 'requested_at' => '\DateTime', 'started_at' => '\DateTime', - 'links' => 'array', 'status' => 'string' ]; @@ -73,9 +73,9 @@ class ActionResponse implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'completed_at' => 'date-time', + 'links' => null, 'requested_at' => 'date-time', 'started_at' => 'date-time', - 'links' => null, 'status' => null ]; @@ -86,9 +86,9 @@ class ActionResponse implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static array $openAPINullables = [ 'completed_at' => false, + 'links' => false, 'requested_at' => false, 'started_at' => false, - 'links' => false, 'status' => false ]; @@ -179,9 +179,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'completed_at' => 'completedAt', + 'links' => 'links', 'requested_at' => 'requestedAt', 'started_at' => 'startedAt', - 'links' => 'links', 'status' => 'status' ]; @@ -192,9 +192,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'completed_at' => 'setCompletedAt', + 'links' => 'setLinks', 'requested_at' => 'setRequestedAt', 'started_at' => 'setStartedAt', - 'links' => 'setLinks', 'status' => 'setStatus' ]; @@ -205,9 +205,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'completed_at' => 'getCompletedAt', + 'links' => 'getLinks', 'requested_at' => 'getRequestedAt', 'started_at' => 'getStartedAt', - 'links' => 'getLinks', 'status' => 'getStatus' ]; @@ -252,10 +252,10 @@ public function getModelName() return self::$openAPIModelName; } - public const STATUS_PENDING = 'PENDING'; - public const STATUS_PROCESSING = 'PROCESSING'; public const STATUS_CANCELED = 'CANCELED'; public const STATUS_COMPLETE = 'COMPLETE'; + public const STATUS_PENDING = 'PENDING'; + public const STATUS_PROCESSING = 'PROCESSING'; /** * Gets allowable values of the enum @@ -265,10 +265,10 @@ public function getModelName() public function getStatusAllowableValues() { return [ - self::STATUS_PENDING, - self::STATUS_PROCESSING, self::STATUS_CANCELED, self::STATUS_COMPLETE, + self::STATUS_PENDING, + self::STATUS_PROCESSING, ]; } @@ -288,9 +288,9 @@ public function getStatusAllowableValues() public function __construct(?array $data = null) { $this->setIfExists('completed_at', $data ?? [], null); + $this->setIfExists('links', $data ?? [], null); $this->setIfExists('requested_at', $data ?? [], null); $this->setIfExists('started_at', $data ?? [], null); - $this->setIfExists('links', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); } @@ -381,6 +381,33 @@ public function setCompletedAt($completed_at) return $this; } + /** + * Gets links + * + * @return array|null + */ + public function getLinks() + { + return $this->container['links']; + } + + /** + * Sets links + * + * @param array|null $links links + * + * @return self + */ + public function setLinks($links) + { + if (is_null($links)) { + throw new \InvalidArgumentException('non-nullable links cannot be null'); + } + $this->container['links'] = $links; + + return $this; + } + /** * Gets requested_at * @@ -435,33 +462,6 @@ public function setStartedAt($started_at) return $this; } - /** - * Gets links - * - * @return array|null - */ - public function getLinks() - { - return $this->container['links']; - } - - /** - * Sets links - * - * @param array|null $links links - * - * @return self - */ - public function setLinks($links) - { - if (is_null($links)) { - throw new \InvalidArgumentException('non-nullable links cannot be null'); - } - $this->container['links'] = $links; - - return $this; - } - /** * Gets status * @@ -501,11 +501,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]); } @@ -513,12 +513,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; } @@ -543,11 +543,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/SourceCode/Model/AssetFileMetadata.php b/codegen/Cms/SourceCode/Model/AssetFileMetadata.php index 94a38e17..dc68baac 100644 --- a/codegen/Cms/SourceCode/Model/AssetFileMetadata.php +++ b/codegen/Cms/SourceCode/Model/AssetFileMetadata.php @@ -2,7 +2,7 @@ /** * AssetFileMetadata * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -57,13 +57,13 @@ class AssetFileMetadata implements ModelInterface, ArrayAccess, \JsonSerializabl * @var string[] */ protected static $openAPITypes = [ - 'created_at' => 'int', 'archived_at' => 'int', - 'folder' => 'bool', 'children' => 'string[]', - 'name' => 'string', - 'id' => 'string', + 'created_at' => 'int', + 'folder' => 'bool', 'hash' => 'string', + 'id' => 'string', + 'name' => 'string', 'updated_at' => 'int' ]; @@ -75,13 +75,13 @@ class AssetFileMetadata implements ModelInterface, ArrayAccess, \JsonSerializabl * @psalm-var array */ protected static $openAPIFormats = [ - 'created_at' => 'int64', 'archived_at' => 'int64', - 'folder' => null, 'children' => null, - 'name' => null, - 'id' => null, + 'created_at' => 'int64', + 'folder' => null, 'hash' => null, + 'id' => null, + 'name' => null, 'updated_at' => 'int64' ]; @@ -91,13 +91,13 @@ class AssetFileMetadata implements ModelInterface, ArrayAccess, \JsonSerializabl * @var boolean[] */ protected static array $openAPINullables = [ - 'created_at' => false, 'archived_at' => false, - 'folder' => false, 'children' => false, - 'name' => false, - 'id' => false, + 'created_at' => false, + 'folder' => false, 'hash' => false, + 'id' => false, + 'name' => false, 'updated_at' => false ]; @@ -187,13 +187,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'created_at' => 'createdAt', 'archived_at' => 'archivedAt', - 'folder' => 'folder', 'children' => 'children', - 'name' => 'name', - 'id' => 'id', + 'created_at' => 'createdAt', + 'folder' => 'folder', 'hash' => 'hash', + 'id' => 'id', + 'name' => 'name', 'updated_at' => 'updatedAt' ]; @@ -203,13 +203,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'created_at' => 'setCreatedAt', 'archived_at' => 'setArchivedAt', - 'folder' => 'setFolder', 'children' => 'setChildren', - 'name' => 'setName', - 'id' => 'setId', + 'created_at' => 'setCreatedAt', + 'folder' => 'setFolder', 'hash' => 'setHash', + 'id' => 'setId', + 'name' => 'setName', 'updated_at' => 'setUpdatedAt' ]; @@ -219,13 +219,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'created_at' => 'getCreatedAt', 'archived_at' => 'getArchivedAt', - 'folder' => 'getFolder', 'children' => 'getChildren', - 'name' => 'getName', - 'id' => 'getId', + 'created_at' => 'getCreatedAt', + 'folder' => 'getFolder', 'hash' => 'getHash', + 'id' => 'getId', + 'name' => 'getName', 'updated_at' => 'getUpdatedAt' ]; @@ -286,13 +286,13 @@ public function getModelName() */ public function __construct(?array $data = null) { - $this->setIfExists('created_at', $data ?? [], null); $this->setIfExists('archived_at', $data ?? [], null); - $this->setIfExists('folder', $data ?? [], null); $this->setIfExists('children', $data ?? [], null); - $this->setIfExists('name', $data ?? [], null); - $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('folder', $data ?? [], null); $this->setIfExists('hash', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); $this->setIfExists('updated_at', $data ?? [], null); } @@ -329,12 +329,12 @@ public function listInvalidProperties() if ($this->container['folder'] === null) { $invalidProperties[] = "'folder' can't be null"; } - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } if ($this->container['id'] === null) { $invalidProperties[] = "'id' can't be null"; } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } if ($this->container['updated_at'] === null) { $invalidProperties[] = "'updated_at' can't be null"; } @@ -354,136 +354,136 @@ public function valid() /** - * Gets created_at + * Gets archived_at * - * @return int + * @return int|null */ - public function getCreatedAt() + public function getArchivedAt() { - return $this->container['created_at']; + return $this->container['archived_at']; } /** - * Sets created_at + * Sets archived_at * - * @param int $created_at Timestamp of when the object was first created. + * @param int|null $archived_at Timestamp of when the object was archived (deleted). * * @return self */ - public function setCreatedAt($created_at) + public function setArchivedAt($archived_at) { - if (is_null($created_at)) { - throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + if (is_null($archived_at)) { + throw new \InvalidArgumentException('non-nullable archived_at cannot be null'); } - $this->container['created_at'] = $created_at; + $this->container['archived_at'] = $archived_at; return $this; } /** - * Gets archived_at + * Gets children * - * @return int|null + * @return string[]|null */ - public function getArchivedAt() + public function getChildren() { - return $this->container['archived_at']; + return $this->container['children']; } /** - * Sets archived_at + * Sets children * - * @param int|null $archived_at Timestamp of when the object was archived (deleted). + * @param string[]|null $children If the object is a folder, contains the filenames of the files within the folder. * * @return self */ - public function setArchivedAt($archived_at) + public function setChildren($children) { - if (is_null($archived_at)) { - throw new \InvalidArgumentException('non-nullable archived_at cannot be null'); + if (is_null($children)) { + throw new \InvalidArgumentException('non-nullable children cannot be null'); } - $this->container['archived_at'] = $archived_at; + $this->container['children'] = $children; return $this; } /** - * Gets folder + * Gets created_at * - * @return bool + * @return int */ - public function getFolder() + public function getCreatedAt() { - return $this->container['folder']; + return $this->container['created_at']; } /** - * Sets folder + * Sets created_at * - * @param bool $folder Determines whether or not this path points to a folder. + * @param int $created_at Timestamp of when the object was first created. * * @return self */ - public function setFolder($folder) + public function setCreatedAt($created_at) { - if (is_null($folder)) { - throw new \InvalidArgumentException('non-nullable folder cannot be null'); + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); } - $this->container['folder'] = $folder; + $this->container['created_at'] = $created_at; return $this; } /** - * Gets children + * Gets folder * - * @return string[]|null + * @return bool */ - public function getChildren() + public function getFolder() { - return $this->container['children']; + return $this->container['folder']; } /** - * Sets children + * Sets folder * - * @param string[]|null $children If the object is a folder, contains the filenames of the files within the folder. + * @param bool $folder Determines whether or not this path points to a folder. * * @return self */ - public function setChildren($children) + public function setFolder($folder) { - if (is_null($children)) { - throw new \InvalidArgumentException('non-nullable children cannot be null'); + if (is_null($folder)) { + throw new \InvalidArgumentException('non-nullable folder cannot be null'); } - $this->container['children'] = $children; + $this->container['folder'] = $folder; return $this; } /** - * Gets name + * Gets hash * - * @return string + * @return string|null */ - public function getName() + public function getHash() { - return $this->container['name']; + return $this->container['hash']; } /** - * Sets name + * Sets hash * - * @param string $name The name of the file. + * @param string|null $hash hash * * @return self */ - public function setName($name) + public function setHash($hash) { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); + if (is_null($hash)) { + throw new \InvalidArgumentException('non-nullable hash cannot be null'); } - $this->container['name'] = $name; + $this->container['hash'] = $hash; return $this; } @@ -516,28 +516,28 @@ public function setId($id) } /** - * Gets hash + * Gets name * - * @return string|null + * @return string */ - public function getHash() + public function getName() { - return $this->container['hash']; + return $this->container['name']; } /** - * Sets hash + * Sets name * - * @param string|null $hash hash + * @param string $name The name of the file. * * @return self */ - public function setHash($hash) + public function setName($name) { - if (is_null($hash)) { - throw new \InvalidArgumentException('non-nullable hash cannot be null'); + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); } - $this->container['hash'] = $hash; + $this->container['name'] = $name; return $this; } @@ -571,11 +571,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]); } @@ -583,12 +583,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; } @@ -613,11 +613,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/SourceCode/Model/Error.php b/codegen/Cms/SourceCode/Model/Error.php index c30dafd1..c6e60c5f 100644 --- a/codegen/Cms/SourceCode/Model/Error.php +++ b/codegen/Cms/SourceCode/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -57,13 +57,13 @@ class Error implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'sub_category' => 'string', + 'category' => 'string', 'context' => 'array', 'correlation_id' => 'string', + 'errors' => '\HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]', 'links' => 'array', 'message' => 'string', - 'category' => 'string', - 'errors' => '\HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]' + 'sub_category' => 'string' ]; /** @@ -74,13 +74,13 @@ class Error implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'sub_category' => null, + 'category' => null, 'context' => null, 'correlation_id' => 'uuid', + 'errors' => null, 'links' => null, 'message' => null, - 'category' => null, - 'errors' => null + 'sub_category' => null ]; /** @@ -89,13 +89,13 @@ class Error implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'sub_category' => false, + 'category' => false, 'context' => false, 'correlation_id' => false, + 'errors' => false, 'links' => false, 'message' => false, - 'category' => false, - 'errors' => false + 'sub_category' => false ]; /** @@ -184,13 +184,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'sub_category' => 'subCategory', + 'category' => 'category', 'context' => 'context', 'correlation_id' => 'correlationId', + 'errors' => 'errors', 'links' => 'links', 'message' => 'message', - 'category' => 'category', - 'errors' => 'errors' + 'sub_category' => 'subCategory' ]; /** @@ -199,13 +199,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'sub_category' => 'setSubCategory', + 'category' => 'setCategory', 'context' => 'setContext', 'correlation_id' => 'setCorrelationId', + 'errors' => 'setErrors', 'links' => 'setLinks', 'message' => 'setMessage', - 'category' => 'setCategory', - 'errors' => 'setErrors' + 'sub_category' => 'setSubCategory' ]; /** @@ -214,13 +214,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'sub_category' => 'getSubCategory', + 'category' => 'getCategory', 'context' => 'getContext', 'correlation_id' => 'getCorrelationId', + 'errors' => 'getErrors', 'links' => 'getLinks', 'message' => 'getMessage', - 'category' => 'getCategory', - 'errors' => 'getErrors' + 'sub_category' => 'getSubCategory' ]; /** @@ -280,13 +280,13 @@ public function getModelName() */ public function __construct(?array $data = null) { - $this->setIfExists('sub_category', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); $this->setIfExists('correlation_id', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); $this->setIfExists('links', $data ?? [], null); $this->setIfExists('message', $data ?? [], null); - $this->setIfExists('category', $data ?? [], null); - $this->setIfExists('errors', $data ?? [], null); + $this->setIfExists('sub_category', $data ?? [], null); } /** @@ -316,15 +316,15 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['category'] === null) { + $invalidProperties[] = "'category' can't be null"; + } if ($this->container['correlation_id'] === null) { $invalidProperties[] = "'correlation_id' can't be null"; } if ($this->container['message'] === null) { $invalidProperties[] = "'message' can't be null"; } - if ($this->container['category'] === null) { - $invalidProperties[] = "'category' can't be null"; - } return $invalidProperties; } @@ -341,28 +341,28 @@ public function valid() /** - * Gets sub_category + * Gets category * - * @return string|null + * @return string */ - public function getSubCategory() + public function getCategory() { - return $this->container['sub_category']; + return $this->container['category']; } /** - * Sets sub_category + * Sets category * - * @param string|null $sub_category A specific category that contains more specific detail about the error + * @param string $category The error category * * @return self */ - public function setSubCategory($sub_category) + public function setCategory($category) { - if (is_null($sub_category)) { - throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); } - $this->container['sub_category'] = $sub_category; + $this->container['category'] = $category; return $this; } @@ -421,6 +421,33 @@ public function setCorrelationId($correlation_id) return $this; } + /** + * Gets errors + * + * @return \HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]|null $errors further information about the error + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + throw new \InvalidArgumentException('non-nullable errors cannot be null'); + } + $this->container['errors'] = $errors; + + return $this; + } + /** * Gets links * @@ -476,66 +503,39 @@ public function setMessage($message) } /** - * Gets category - * - * @return string - */ - public function getCategory() - { - return $this->container['category']; - } - - /** - * Sets category - * - * @param string $category The error category - * - * @return self - */ - public function setCategory($category) - { - if (is_null($category)) { - throw new \InvalidArgumentException('non-nullable category cannot be null'); - } - $this->container['category'] = $category; - - return $this; - } - - /** - * Gets errors + * Gets sub_category * - * @return \HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]|null + * @return string|null */ - public function getErrors() + public function getSubCategory() { - return $this->container['errors']; + return $this->container['sub_category']; } /** - * Sets errors + * Sets sub_category * - * @param \HubSpot\Client\Cms\SourceCode\Model\ErrorDetail[]|null $errors further information about the error + * @param string|null $sub_category A specific category that contains more specific detail about the error * * @return self */ - public function setErrors($errors) + public function setSubCategory($sub_category) { - if (is_null($errors)) { - throw new \InvalidArgumentException('non-nullable errors cannot be null'); + if (is_null($sub_category)) { + throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); } - $this->container['errors'] = $errors; + $this->container['sub_category'] = $sub_category; return $this; } /** * 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/SourceCode/Model/ErrorDetail.php b/codegen/Cms/SourceCode/Model/ErrorDetail.php index 9d706d06..b0314f65 100644 --- a/codegen/Cms/SourceCode/Model/ErrorDetail.php +++ b/codegen/Cms/SourceCode/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -57,11 +57,11 @@ class ErrorDetail implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'sub_category' => 'string', 'code' => 'string', - 'in' => 'string', 'context' => 'array', - 'message' => 'string' + 'in' => 'string', + 'message' => 'string', + 'sub_category' => 'string' ]; /** @@ -72,11 +72,11 @@ class ErrorDetail implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'sub_category' => null, 'code' => null, - 'in' => null, 'context' => null, - 'message' => null + 'in' => null, + 'message' => null, + 'sub_category' => null ]; /** @@ -85,11 +85,11 @@ class ErrorDetail implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'sub_category' => false, 'code' => false, - 'in' => false, 'context' => false, - 'message' => false + 'in' => false, + 'message' => false, + 'sub_category' => false ]; /** @@ -178,11 +178,11 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'sub_category' => 'subCategory', 'code' => 'code', - 'in' => 'in', 'context' => 'context', - 'message' => 'message' + 'in' => 'in', + 'message' => 'message', + 'sub_category' => 'subCategory' ]; /** @@ -191,11 +191,11 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'sub_category' => 'setSubCategory', 'code' => 'setCode', - 'in' => 'setIn', 'context' => 'setContext', - 'message' => 'setMessage' + 'in' => 'setIn', + 'message' => 'setMessage', + 'sub_category' => 'setSubCategory' ]; /** @@ -204,11 +204,11 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'sub_category' => 'getSubCategory', 'code' => 'getCode', - 'in' => 'getIn', 'context' => 'getContext', - 'message' => 'getMessage' + 'in' => 'getIn', + 'message' => 'getMessage', + 'sub_category' => 'getSubCategory' ]; /** @@ -268,11 +268,11 @@ public function getModelName() */ public function __construct(?array $data = null) { - $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('code', $data ?? [], null); - $this->setIfExists('in', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); + $this->setIfExists('in', $data ?? [], null); $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('sub_category', $data ?? [], null); } /** @@ -321,55 +321,55 @@ public function valid() /** - * Gets sub_category + * Gets code * * @return string|null */ - public function getSubCategory() + public function getCode() { - return $this->container['sub_category']; + return $this->container['code']; } /** - * Sets sub_category + * Sets code * - * @param string|null $sub_category A specific category that contains more specific detail about the error + * @param string|null $code The status code associated with the error detail * * @return self */ - public function setSubCategory($sub_category) + public function setCode($code) { - if (is_null($sub_category)) { - throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); } - $this->container['sub_category'] = $sub_category; + $this->container['code'] = $code; return $this; } /** - * Gets code + * Gets context * - * @return string|null + * @return array|null */ - public function getCode() + public function getContext() { - return $this->container['code']; + return $this->container['context']; } /** - * Sets code + * Sets context * - * @param string|null $code The status code associated with the error detail + * @param array|null $context Context about the error condition * * @return self */ - public function setCode($code) + public function setContext($context) { - if (is_null($code)) { - throw new \InvalidArgumentException('non-nullable code cannot be null'); + if (is_null($context)) { + throw new \InvalidArgumentException('non-nullable context cannot be null'); } - $this->container['code'] = $code; + $this->container['context'] = $context; return $this; } @@ -402,66 +402,66 @@ public function setIn($in) } /** - * Gets context + * Gets message * - * @return array|null + * @return string */ - public function getContext() + public function getMessage() { - return $this->container['context']; + return $this->container['message']; } /** - * Sets context + * Sets message * - * @param array|null $context Context about the error condition + * @param string $message A human readable message describing the error along with remediation steps where appropriate * * @return self */ - public function setContext($context) + public function setMessage($message) { - if (is_null($context)) { - throw new \InvalidArgumentException('non-nullable context cannot be null'); + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); } - $this->container['context'] = $context; + $this->container['message'] = $message; return $this; } /** - * Gets message + * Gets sub_category * - * @return string + * @return string|null */ - public function getMessage() + public function getSubCategory() { - return $this->container['message']; + return $this->container['sub_category']; } /** - * Sets message + * Sets sub_category * - * @param string $message A human readable message describing the error along with remediation steps where appropriate + * @param string|null $sub_category A specific category that contains more specific detail about the error * * @return self */ - public function setMessage($message) + public function setSubCategory($sub_category) { - if (is_null($message)) { - throw new \InvalidArgumentException('non-nullable message cannot be null'); + if (is_null($sub_category)) { + throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); } - $this->container['message'] = $message; + $this->container['sub_category'] = $sub_category; return $this; } /** * 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/SourceCode/Model/FileExtractRequest.php b/codegen/Cms/SourceCode/Model/FileExtractRequest.php index eca7b673..cdbba30c 100644 --- a/codegen/Cms/SourceCode/Model/FileExtractRequest.php +++ b/codegen/Cms/SourceCode/Model/FileExtractRequest.php @@ -2,7 +2,7 @@ /** * FileExtractRequest * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * 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 setPath($path) /** * 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/SourceCode/Model/ModelInterface.php b/codegen/Cms/SourceCode/Model/ModelInterface.php index 66e15c5d..3d00273c 100644 --- a/codegen/Cms/SourceCode/Model/ModelInterface.php +++ b/codegen/Cms/SourceCode/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode\Model @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * 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/SourceCode/Model/TaskLocator.php b/codegen/Cms/SourceCode/Model/TaskLocator.php index c903746e..0613eed2 100644 --- a/codegen/Cms/SourceCode/Model/TaskLocator.php +++ b/codegen/Cms/SourceCode/Model/TaskLocator.php @@ -2,7 +2,7 @@ /** * TaskLocator * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -57,8 +57,8 @@ class TaskLocator implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'links' => 'array', - 'id' => 'string' + 'id' => 'string', + 'links' => 'array' ]; /** @@ -69,8 +69,8 @@ class TaskLocator implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'links' => null, - 'id' => null + 'id' => null, + 'links' => null ]; /** @@ -79,8 +79,8 @@ class TaskLocator implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'links' => false, - 'id' => false + 'id' => false, + 'links' => false ]; /** @@ -169,8 +169,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'links' => 'links', - 'id' => 'id' + 'id' => 'id', + 'links' => 'links' ]; /** @@ -179,8 +179,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'links' => 'setLinks', - 'id' => 'setId' + 'id' => 'setId', + 'links' => 'setLinks' ]; /** @@ -189,8 +189,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'links' => 'getLinks', - 'id' => 'getId' + 'id' => 'getId', + 'links' => 'getLinks' ]; /** @@ -250,8 +250,8 @@ public function getModelName() */ public function __construct(?array $data = null) { - $this->setIfExists('links', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('links', $data ?? [], null); } /** @@ -300,66 +300,66 @@ public function valid() /** - * Gets links + * Gets id * - * @return array|null + * @return string */ - public function getLinks() + public function getId() { - return $this->container['links']; + return $this->container['id']; } /** - * Sets links + * Sets id * - * @param array|null $links links + * @param string $id id * * @return self */ - public function setLinks($links) + public function setId($id) { - if (is_null($links)) { - throw new \InvalidArgumentException('non-nullable links cannot be null'); + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); } - $this->container['links'] = $links; + $this->container['id'] = $id; return $this; } /** - * Gets id + * Gets links * - * @return string + * @return array|null */ - public function getId() + public function getLinks() { - return $this->container['id']; + return $this->container['links']; } /** - * Sets id + * Sets links * - * @param string $id id + * @param array|null $links links * * @return self */ - public function setId($id) + public function setLinks($links) { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); + if (is_null($links)) { + throw new \InvalidArgumentException('non-nullable links cannot be null'); } - $this->container['id'] = $id; + $this->container['links'] = $links; return $this; } /** * 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 +367,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 +397,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/SourceCode/ObjectSerializer.php b/codegen/Cms/SourceCode/ObjectSerializer.php index 66ab500f..fc66ab33 100644 --- a/codegen/Cms/SourceCode/ObjectSerializer.php +++ b/codegen/Cms/SourceCode/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Cms\SourceCode @@ -11,13 +11,13 @@ */ /** - * Source Code + * CMS Source Code * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * API for managing and retrieving source code files and metadata * * 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) : ''; } }