From 66a60dfcb2603a896a74256da8c8f001af47df24 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 19 Feb 2026 11:50:52 +0300 Subject: [PATCH] Codegen: OAuth --- codegen/Oauth/Api/AccessTokensApi.php | 176 ++-- codegen/Oauth/Api/RefreshTokensApi.php | 196 ++-- codegen/Oauth/Api/TokensApi.php | 197 ++-- codegen/Oauth/ApiException.php | 4 +- codegen/Oauth/Configuration.php | 63 +- codegen/Oauth/FormDataProcessor.php | 246 +++++ codegen/Oauth/HeaderSelector.php | 4 +- .../Oauth/Model/AccessTokenInfoResponse.php | 350 ++++--- codegen/Oauth/Model/Error.php | 158 +-- codegen/Oauth/Model/ErrorDetail.php | 134 +-- codegen/Oauth/Model/ModelInterface.php | 4 +- .../Oauth/Model/RefreshTokenInfoResponse.php | 248 ++--- codegen/Oauth/Model/SignedAccessToken.php | 930 ++++++++++++++++++ codegen/Oauth/Model/TokenResponseIF.php | 180 ++-- codegen/Oauth/ObjectSerializer.php | 24 +- 15 files changed, 2119 insertions(+), 795 deletions(-) create mode 100644 codegen/Oauth/FormDataProcessor.php create mode 100644 codegen/Oauth/Model/SignedAccessToken.php diff --git a/codegen/Oauth/Api/AccessTokensApi.php b/codegen/Oauth/Api/AccessTokensApi.php index ba9c0e4e..5e6df624 100644 --- a/codegen/Oauth/Api/AccessTokensApi.php +++ b/codegen/Oauth/Api/AccessTokensApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\Model\AccessTokenInfoResponse' !== '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\Oauth\Model\AccessTokenInfoResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\AccessTokenInfoResponse', + $request, + $response, + ); default: - if ('\HubSpot\Client\Oauth\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\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\Oauth\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -249,34 +214,11 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes ); } - $returnType = '\HubSpot\Client\Oauth\Model\AccessTokenInfoResponse'; - 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\Oauth\Model\AccessTokenInfoResponse', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -286,7 +228,7 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -294,8 +236,10 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -305,11 +249,12 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes * * Retrieve OAuth token metadata * - * @param string $token The access token that you want to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getAsync($token, string $contentType = self::contentTypes['get'][0]) { @@ -326,11 +271,12 @@ function ($response) { * * Retrieve OAuth token metadata * - * @param string $token The access token that you want to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getAsyncWithHttpInfo($token, string $contentType = self::contentTypes['get'][0]) { @@ -376,11 +322,12 @@ function ($exception) { /** * Create request for operation 'get' * - * @param string $token The access token that you want to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request + * @deprecated */ public function getRequest($token, string $contentType = self::contentTypes['get'][0]) { @@ -481,6 +428,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/Oauth/Api/RefreshTokensApi.php b/codegen/Oauth/Api/RefreshTokensApi.php index d1af3d1a..4f49cbe6 100644 --- a/codegen/Oauth/Api/RefreshTokensApi.php +++ b/codegen/Oauth/Api/RefreshTokensApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -192,8 +196,10 @@ public function archiveWithHttpInfo($token, string $contentType = self::contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -203,11 +209,12 @@ public function archiveWithHttpInfo($token, string $contentType = self::contentT * * Delete a refresh token * - * @param string $token The refresh token to delete. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function archiveAsync($token, string $contentType = self::contentTypes['archive'][0]) { @@ -224,11 +231,12 @@ function ($response) { * * Delete a refresh token * - * @param string $token The refresh token to delete. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function archiveAsyncWithHttpInfo($token, string $contentType = self::contentTypes['archive'][0]) { @@ -261,11 +269,12 @@ function ($exception) { /** * Create request for operation 'archive' * - * @param string $token The refresh token to delete. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request + * @deprecated */ public function archiveRequest($token, string $contentType = self::contentTypes['archive'][0]) { @@ -355,12 +364,13 @@ public function archiveRequest($token, string $contentType = self::contentTypes[ * * Retrieve refresh token metadata * - * @param string $token The refresh token to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse|\HubSpot\Client\Oauth\Model\Error + * @deprecated */ public function get($token, string $contentType = self::contentTypes['get'][0]) { @@ -373,12 +383,13 @@ public function get($token, string $contentType = self::contentTypes['get'][0]) * * Retrieve refresh token metadata * - * @param string $token The refresh token to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse|\HubSpot\Client\Oauth\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @deprecated */ public function getWithHttpInfo($token, string $contentType = self::contentTypes['get'][0]) { @@ -409,61 +420,21 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes switch($statusCode) { case 200: - if ('\HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse' !== '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\Oauth\Model\RefreshTokenInfoResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse', + $request, + $response, + ); default: - if ('\HubSpot\Client\Oauth\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\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\Oauth\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -477,34 +448,11 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes ); } - $returnType = '\HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse'; - 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\Oauth\Model\RefreshTokenInfoResponse', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -514,7 +462,7 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -522,8 +470,10 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -533,11 +483,12 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes * * Retrieve refresh token metadata * - * @param string $token The refresh token to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getAsync($token, string $contentType = self::contentTypes['get'][0]) { @@ -554,11 +505,12 @@ function ($response) { * * Retrieve refresh token metadata * - * @param string $token The refresh token to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getAsyncWithHttpInfo($token, string $contentType = self::contentTypes['get'][0]) { @@ -604,11 +556,12 @@ function ($exception) { /** * Create request for operation 'get' * - * @param string $token The refresh token to retrieve information about. (required) + * @param string $token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request + * @deprecated */ public function getRequest($token, string $contentType = self::contentTypes['get'][0]) { @@ -709,6 +662,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/Oauth/Api/TokensApi.php b/codegen/Oauth/Api/TokensApi.php index 25907b3c..becb8bcc 100644 --- a/codegen/Oauth/Api/TokensApi.php +++ b/codegen/Oauth/Api/TokensApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\Model\TokenResponseIF' !== '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\Oauth\Model\TokenResponseIF', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\TokenResponseIF', + $request, + $response, + ); default: - if ('\HubSpot\Client\Oauth\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Oauth\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\Oauth\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Oauth\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -259,34 +222,11 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u ); } - $returnType = '\HubSpot\Client\Oauth\Model\TokenResponseIF'; - 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\Oauth\Model\TokenResponseIF', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -296,7 +236,7 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -304,8 +244,10 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -428,29 +370,19 @@ public function createRequest($grant_type = null, $code = null, $redirect_uri = // form params - if ($grant_type !== null) { - $formParams['grant_type'] = ObjectSerializer::toFormValue($grant_type); - } - // form params - if ($code !== null) { - $formParams['code'] = ObjectSerializer::toFormValue($code); - } - // form params - if ($redirect_uri !== null) { - $formParams['redirect_uri'] = ObjectSerializer::toFormValue($redirect_uri); - } - // form params - if ($client_id !== null) { - $formParams['client_id'] = ObjectSerializer::toFormValue($client_id); - } - // form params - if ($client_secret !== null) { - $formParams['client_secret'] = ObjectSerializer::toFormValue($client_secret); - } - // form params - if ($refresh_token !== null) { - $formParams['refresh_token'] = ObjectSerializer::toFormValue($refresh_token); - } + $formDataProcessor = new FormDataProcessor(); + + $formData = $formDataProcessor->prepare([ + 'grant_type' => $grant_type, + 'code' => $code, + 'redirect_uri' => $redirect_uri, + 'client_id' => $client_id, + 'client_secret' => $client_secret, + 'refresh_token' => $refresh_token, + ]); + + $formParams = $formDataProcessor->flatten($formData); + $multipart = $formDataProcessor->has_file; $headers = $this->headerSelector->selectHeaders( ['application/json', '*/*', ], @@ -521,6 +453,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/Oauth/ApiException.php b/codegen/Oauth/ApiException.php index 64105239..ae7a80b3 100644 --- a/codegen/Oauth/ApiException.php +++ b/codegen/Oauth/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/Oauth/FormDataProcessor.php b/codegen/Oauth/FormDataProcessor.php new file mode 100644 index 00000000..161d035f --- /dev/null +++ b/codegen/Oauth/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/Oauth/HeaderSelector.php b/codegen/Oauth/HeaderSelector.php index 0e425871..9e79a5c3 100644 --- a/codegen/Oauth/HeaderSelector.php +++ b/codegen/Oauth/HeaderSelector.php @@ -1,7 +1,7 @@ 'int', + 'expires_in' => 'int', + 'hub_domain' => 'string', 'hub_id' => 'int', - 'user_id' => 'int', + 'is_private_distribution' => 'bool', 'scopes' => 'string[]', + 'signed_access_token' => '\HubSpot\Client\Oauth\Model\SignedAccessToken', + 'token' => 'string', 'token_type' => 'string', 'user' => 'string', - 'hub_domain' => 'string', - 'app_id' => 'int', - 'expires_in' => 'int', - 'token' => 'string' + 'user_id' => 'int' ]; /** @@ -76,15 +78,17 @@ class AccessTokenInfoResponse implements ModelInterface, ArrayAccess, \JsonSeria * @psalm-var array */ protected static $openAPIFormats = [ + 'app_id' => 'int32', + 'expires_in' => 'int32', + 'hub_domain' => null, 'hub_id' => 'int32', - 'user_id' => 'int32', + 'is_private_distribution' => null, 'scopes' => null, + 'signed_access_token' => null, + 'token' => null, 'token_type' => null, 'user' => null, - 'hub_domain' => null, - 'app_id' => 'int32', - 'expires_in' => 'int32', - 'token' => null + 'user_id' => 'int32' ]; /** @@ -93,15 +97,17 @@ class AccessTokenInfoResponse implements ModelInterface, ArrayAccess, \JsonSeria * @var boolean[] */ protected static array $openAPINullables = [ + 'app_id' => false, + 'expires_in' => false, + 'hub_domain' => false, 'hub_id' => false, - 'user_id' => false, + 'is_private_distribution' => false, 'scopes' => false, + 'signed_access_token' => false, + 'token' => false, 'token_type' => false, 'user' => false, - 'hub_domain' => false, - 'app_id' => false, - 'expires_in' => false, - 'token' => false + 'user_id' => false ]; /** @@ -190,15 +196,17 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'app_id' => 'app_id', + 'expires_in' => 'expires_in', + 'hub_domain' => 'hub_domain', 'hub_id' => 'hub_id', - 'user_id' => 'user_id', + 'is_private_distribution' => 'is_private_distribution', 'scopes' => 'scopes', + 'signed_access_token' => 'signed_access_token', + 'token' => 'token', 'token_type' => 'token_type', 'user' => 'user', - 'hub_domain' => 'hub_domain', - 'app_id' => 'app_id', - 'expires_in' => 'expires_in', - 'token' => 'token' + 'user_id' => 'user_id' ]; /** @@ -207,15 +215,17 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'app_id' => 'setAppId', + 'expires_in' => 'setExpiresIn', + 'hub_domain' => 'setHubDomain', 'hub_id' => 'setHubId', - 'user_id' => 'setUserId', + 'is_private_distribution' => 'setIsPrivateDistribution', 'scopes' => 'setScopes', + 'signed_access_token' => 'setSignedAccessToken', + 'token' => 'setToken', 'token_type' => 'setTokenType', 'user' => 'setUser', - 'hub_domain' => 'setHubDomain', - 'app_id' => 'setAppId', - 'expires_in' => 'setExpiresIn', - 'token' => 'setToken' + 'user_id' => 'setUserId' ]; /** @@ -224,15 +234,17 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'app_id' => 'getAppId', + 'expires_in' => 'getExpiresIn', + 'hub_domain' => 'getHubDomain', 'hub_id' => 'getHubId', - 'user_id' => 'getUserId', + 'is_private_distribution' => 'getIsPrivateDistribution', 'scopes' => 'getScopes', + 'signed_access_token' => 'getSignedAccessToken', + 'token' => 'getToken', 'token_type' => 'getTokenType', 'user' => 'getUser', - 'hub_domain' => 'getHubDomain', - 'app_id' => 'getAppId', - 'expires_in' => 'getExpiresIn', - 'token' => 'getToken' + 'user_id' => 'getUserId' ]; /** @@ -292,15 +304,17 @@ public function getModelName() */ public function __construct(?array $data = null) { + $this->setIfExists('app_id', $data ?? [], null); + $this->setIfExists('expires_in', $data ?? [], null); + $this->setIfExists('hub_domain', $data ?? [], null); $this->setIfExists('hub_id', $data ?? [], null); - $this->setIfExists('user_id', $data ?? [], null); + $this->setIfExists('is_private_distribution', $data ?? [], null); $this->setIfExists('scopes', $data ?? [], null); + $this->setIfExists('signed_access_token', $data ?? [], null); + $this->setIfExists('token', $data ?? [], null); $this->setIfExists('token_type', $data ?? [], null); $this->setIfExists('user', $data ?? [], null); - $this->setIfExists('hub_domain', $data ?? [], null); - $this->setIfExists('app_id', $data ?? [], null); - $this->setIfExists('expires_in', $data ?? [], null); - $this->setIfExists('token', $data ?? [], null); + $this->setIfExists('user_id', $data ?? [], null); } /** @@ -330,26 +344,26 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['app_id'] === null) { + $invalidProperties[] = "'app_id' can't be null"; + } + if ($this->container['expires_in'] === null) { + $invalidProperties[] = "'expires_in' can't be null"; + } if ($this->container['hub_id'] === null) { $invalidProperties[] = "'hub_id' can't be null"; } - if ($this->container['user_id'] === null) { - $invalidProperties[] = "'user_id' can't be null"; - } if ($this->container['scopes'] === null) { $invalidProperties[] = "'scopes' can't be null"; } + if ($this->container['token'] === null) { + $invalidProperties[] = "'token' can't be null"; + } if ($this->container['token_type'] === null) { $invalidProperties[] = "'token_type' can't be null"; } - if ($this->container['app_id'] === null) { - $invalidProperties[] = "'app_id' can't be null"; - } - if ($this->container['expires_in'] === null) { - $invalidProperties[] = "'expires_in' can't be null"; - } - if ($this->container['token'] === null) { - $invalidProperties[] = "'token' can't be null"; + if ($this->container['user_id'] === null) { + $invalidProperties[] = "'user_id' can't be null"; } return $invalidProperties; } @@ -367,255 +381,309 @@ public function valid() /** - * Gets hub_id + * Gets app_id * * @return int */ - public function getHubId() + public function getAppId() { - return $this->container['hub_id']; + return $this->container['app_id']; } /** - * Sets hub_id + * Sets app_id * - * @param int $hub_id + * @param int $app_id The ID of the application associated with the access token. * * @return self */ - public function setHubId($hub_id) + public function setAppId($app_id) { - if (is_null($hub_id)) { - throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); + if (is_null($app_id)) { + throw new \InvalidArgumentException('non-nullable app_id cannot be null'); } - $this->container['hub_id'] = $hub_id; + $this->container['app_id'] = $app_id; return $this; } /** - * Gets user_id + * Gets expires_in * * @return int */ - public function getUserId() + public function getExpiresIn() { - return $this->container['user_id']; + return $this->container['expires_in']; } /** - * Sets user_id + * Sets expires_in * - * @param int $user_id + * @param int $expires_in The time in seconds until the access token expires. * * @return self */ - public function setUserId($user_id) + public function setExpiresIn($expires_in) { - if (is_null($user_id)) { - throw new \InvalidArgumentException('non-nullable user_id cannot be null'); + if (is_null($expires_in)) { + throw new \InvalidArgumentException('non-nullable expires_in cannot be null'); } - $this->container['user_id'] = $user_id; + $this->container['expires_in'] = $expires_in; return $this; } /** - * Gets scopes + * Gets hub_domain * - * @return string[] + * @return string|null */ - public function getScopes() + public function getHubDomain() { - return $this->container['scopes']; + return $this->container['hub_domain']; } /** - * Sets scopes + * Sets hub_domain * - * @param string[] $scopes + * @param string|null $hub_domain The domain of the HubSpot account associated with the access token. * * @return self */ - public function setScopes($scopes) + public function setHubDomain($hub_domain) { - if (is_null($scopes)) { - throw new \InvalidArgumentException('non-nullable scopes cannot be null'); + if (is_null($hub_domain)) { + throw new \InvalidArgumentException('non-nullable hub_domain cannot be null'); } - $this->container['scopes'] = $scopes; + $this->container['hub_domain'] = $hub_domain; return $this; } /** - * Gets token_type + * Gets hub_id * - * @return string + * @return int */ - public function getTokenType() + public function getHubId() { - return $this->container['token_type']; + return $this->container['hub_id']; } /** - * Sets token_type + * Sets hub_id * - * @param string $token_type + * @param int $hub_id The ID of the HubSpot account associated with the access token. * * @return self */ - public function setTokenType($token_type) + public function setHubId($hub_id) { - if (is_null($token_type)) { - throw new \InvalidArgumentException('non-nullable token_type cannot be null'); + if (is_null($hub_id)) { + throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); } - $this->container['token_type'] = $token_type; + $this->container['hub_id'] = $hub_id; return $this; } /** - * Gets user + * Gets is_private_distribution * - * @return string|null + * @return bool|null */ - public function getUser() + public function getIsPrivateDistribution() { - return $this->container['user']; + return $this->container['is_private_distribution']; } /** - * Sets user + * Sets is_private_distribution * - * @param string|null $user + * @param bool|null $is_private_distribution Indicates whether the token is for a privately distributed application. If false, it is marketplace distributed. * * @return self */ - public function setUser($user) + public function setIsPrivateDistribution($is_private_distribution) { - if (is_null($user)) { - throw new \InvalidArgumentException('non-nullable user cannot be null'); + if (is_null($is_private_distribution)) { + throw new \InvalidArgumentException('non-nullable is_private_distribution cannot be null'); } - $this->container['user'] = $user; + $this->container['is_private_distribution'] = $is_private_distribution; return $this; } /** - * Gets hub_domain + * Gets scopes * - * @return string|null + * @return string[] */ - public function getHubDomain() + public function getScopes() { - return $this->container['hub_domain']; + return $this->container['scopes']; } /** - * Sets hub_domain + * Sets scopes * - * @param string|null $hub_domain + * @param string[] $scopes scopes * * @return self */ - public function setHubDomain($hub_domain) + public function setScopes($scopes) { - if (is_null($hub_domain)) { - throw new \InvalidArgumentException('non-nullable hub_domain cannot be null'); + if (is_null($scopes)) { + throw new \InvalidArgumentException('non-nullable scopes cannot be null'); } - $this->container['hub_domain'] = $hub_domain; + $this->container['scopes'] = $scopes; return $this; } /** - * Gets app_id + * Gets signed_access_token * - * @return int + * @return \HubSpot\Client\Oauth\Model\SignedAccessToken|null */ - public function getAppId() + public function getSignedAccessToken() { - return $this->container['app_id']; + return $this->container['signed_access_token']; } /** - * Sets app_id + * Sets signed_access_token * - * @param int $app_id + * @param \HubSpot\Client\Oauth\Model\SignedAccessToken|null $signed_access_token signed_access_token * * @return self */ - public function setAppId($app_id) + public function setSignedAccessToken($signed_access_token) { - if (is_null($app_id)) { - throw new \InvalidArgumentException('non-nullable app_id cannot be null'); + if (is_null($signed_access_token)) { + throw new \InvalidArgumentException('non-nullable signed_access_token cannot be null'); } - $this->container['app_id'] = $app_id; + $this->container['signed_access_token'] = $signed_access_token; return $this; } /** - * Gets expires_in + * Gets token * - * @return int + * @return string */ - public function getExpiresIn() + public function getToken() { - return $this->container['expires_in']; + return $this->container['token']; } /** - * Sets expires_in + * Sets token * - * @param int $expires_in + * @param string $token The access token string used to make API calls. * * @return self */ - public function setExpiresIn($expires_in) + public function setToken($token) { - if (is_null($expires_in)) { - throw new \InvalidArgumentException('non-nullable expires_in cannot be null'); + if (is_null($token)) { + throw new \InvalidArgumentException('non-nullable token cannot be null'); } - $this->container['expires_in'] = $expires_in; + $this->container['token'] = $token; return $this; } /** - * Gets token + * Gets token_type * * @return string */ - public function getToken() + public function getTokenType() { - return $this->container['token']; + return $this->container['token_type']; } /** - * Sets token + * Sets token_type * - * @param string $token + * @param string $token_type The type of token, typically indicating the authentication scheme. Typically `bearer`. * * @return self */ - public function setToken($token) + public function setTokenType($token_type) { - if (is_null($token)) { - throw new \InvalidArgumentException('non-nullable token cannot be null'); + if (is_null($token_type)) { + throw new \InvalidArgumentException('non-nullable token_type cannot be null'); } - $this->container['token'] = $token; + $this->container['token_type'] = $token_type; + + return $this; + } + + /** + * Gets user + * + * @return string|null + */ + public function getUser() + { + return $this->container['user']; + } + + /** + * Sets user + * + * @param string|null $user The email address of the hubspot user for whom the access token was created. + * + * @return self + */ + public function setUser($user) + { + if (is_null($user)) { + throw new \InvalidArgumentException('non-nullable user cannot be null'); + } + $this->container['user'] = $user; + + return $this; + } + + /** + * Gets user_id + * + * @return int + */ + public function getUserId() + { + return $this->container['user_id']; + } + + /** + * Sets user_id + * + * @param int $user_id The ID of the hubspot user for whom the access token was created. + * + * @return self + */ + public function setUserId($user_id) + { + if (is_null($user_id)) { + throw new \InvalidArgumentException('non-nullable user_id cannot be null'); + } + $this->container['user_id'] = $user_id; 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]); } @@ -623,12 +691,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; } @@ -653,11 +721,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/Oauth/Model/Error.php b/codegen/Oauth/Model/Error.php index 49fa2bab..fc031e1c 100644 --- a/codegen/Oauth/Model/Error.php +++ b/codegen/Oauth/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.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\Oauth\Model\ErrorDetail[]', 'links' => 'array', 'message' => 'string', - 'category' => 'string', - 'errors' => '\HubSpot\Client\Oauth\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\Oauth\Model\ErrorDetail[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \HubSpot\Client\Oauth\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\Oauth\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\Oauth\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/Oauth/Model/ErrorDetail.php b/codegen/Oauth/Model/ErrorDetail.php index 831caff2..a93a4857 100644 --- a/codegen/Oauth/Model/ErrorDetail.php +++ b/codegen/Oauth/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.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/Oauth/Model/ModelInterface.php b/codegen/Oauth/Model/ModelInterface.php index 2d082ed4..75dd7bcc 100644 --- a/codegen/Oauth/Model/ModelInterface.php +++ b/codegen/Oauth/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.0 */ /** diff --git a/codegen/Oauth/Model/RefreshTokenInfoResponse.php b/codegen/Oauth/Model/RefreshTokenInfoResponse.php index 3a13f07f..6600fbb5 100644 --- a/codegen/Oauth/Model/RefreshTokenInfoResponse.php +++ b/codegen/Oauth/Model/RefreshTokenInfoResponse.php @@ -2,7 +2,7 @@ /** * RefreshTokenInfoResponse * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.0 */ /** @@ -57,14 +57,14 @@ class RefreshTokenInfoResponse implements ModelInterface, ArrayAccess, \JsonSeri * @var string[] */ protected static $openAPITypes = [ + 'client_id' => 'string', + 'hub_domain' => 'string', 'hub_id' => 'int', - 'user_id' => 'int', 'scopes' => 'string[]', + 'token' => 'string', 'token_type' => 'string', 'user' => 'string', - 'hub_domain' => 'string', - 'client_id' => 'string', - 'token' => 'string' + 'user_id' => 'int' ]; /** @@ -75,14 +75,14 @@ class RefreshTokenInfoResponse implements ModelInterface, ArrayAccess, \JsonSeri * @psalm-var array */ protected static $openAPIFormats = [ + 'client_id' => null, + 'hub_domain' => null, 'hub_id' => 'int32', - 'user_id' => 'int32', 'scopes' => null, + 'token' => null, 'token_type' => null, 'user' => null, - 'hub_domain' => null, - 'client_id' => null, - 'token' => null + 'user_id' => 'int32' ]; /** @@ -91,14 +91,14 @@ class RefreshTokenInfoResponse implements ModelInterface, ArrayAccess, \JsonSeri * @var boolean[] */ protected static array $openAPINullables = [ + 'client_id' => false, + 'hub_domain' => false, 'hub_id' => false, - 'user_id' => false, 'scopes' => false, + 'token' => false, 'token_type' => false, 'user' => false, - 'hub_domain' => false, - 'client_id' => false, - 'token' => false + 'user_id' => false ]; /** @@ -187,14 +187,14 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'client_id' => 'client_id', + 'hub_domain' => 'hub_domain', 'hub_id' => 'hub_id', - 'user_id' => 'user_id', 'scopes' => 'scopes', + 'token' => 'token', 'token_type' => 'token_type', 'user' => 'user', - 'hub_domain' => 'hub_domain', - 'client_id' => 'client_id', - 'token' => 'token' + 'user_id' => 'user_id' ]; /** @@ -203,14 +203,14 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'client_id' => 'setClientId', + 'hub_domain' => 'setHubDomain', 'hub_id' => 'setHubId', - 'user_id' => 'setUserId', 'scopes' => 'setScopes', + 'token' => 'setToken', 'token_type' => 'setTokenType', 'user' => 'setUser', - 'hub_domain' => 'setHubDomain', - 'client_id' => 'setClientId', - 'token' => 'setToken' + 'user_id' => 'setUserId' ]; /** @@ -219,14 +219,14 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'client_id' => 'getClientId', + 'hub_domain' => 'getHubDomain', 'hub_id' => 'getHubId', - 'user_id' => 'getUserId', 'scopes' => 'getScopes', + 'token' => 'getToken', 'token_type' => 'getTokenType', 'user' => 'getUser', - 'hub_domain' => 'getHubDomain', - 'client_id' => 'getClientId', - 'token' => 'getToken' + 'user_id' => 'getUserId' ]; /** @@ -286,14 +286,14 @@ public function getModelName() */ public function __construct(?array $data = null) { + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('hub_domain', $data ?? [], null); $this->setIfExists('hub_id', $data ?? [], null); - $this->setIfExists('user_id', $data ?? [], null); $this->setIfExists('scopes', $data ?? [], null); + $this->setIfExists('token', $data ?? [], null); $this->setIfExists('token_type', $data ?? [], null); $this->setIfExists('user', $data ?? [], null); - $this->setIfExists('hub_domain', $data ?? [], null); - $this->setIfExists('client_id', $data ?? [], null); - $this->setIfExists('token', $data ?? [], null); + $this->setIfExists('user_id', $data ?? [], null); } /** @@ -323,23 +323,23 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['client_id'] === null) { + $invalidProperties[] = "'client_id' can't be null"; + } if ($this->container['hub_id'] === null) { $invalidProperties[] = "'hub_id' can't be null"; } - if ($this->container['user_id'] === null) { - $invalidProperties[] = "'user_id' can't be null"; - } if ($this->container['scopes'] === null) { $invalidProperties[] = "'scopes' can't be null"; } + if ($this->container['token'] === null) { + $invalidProperties[] = "'token' can't be null"; + } if ($this->container['token_type'] === null) { $invalidProperties[] = "'token_type' can't be null"; } - if ($this->container['client_id'] === null) { - $invalidProperties[] = "'client_id' can't be null"; - } - if ($this->container['token'] === null) { - $invalidProperties[] = "'token' can't be null"; + if ($this->container['user_id'] === null) { + $invalidProperties[] = "'user_id' can't be null"; } return $invalidProperties; } @@ -357,228 +357,228 @@ public function valid() /** - * Gets hub_id + * Gets client_id * - * @return int + * @return string */ - public function getHubId() + public function getClientId() { - return $this->container['hub_id']; + return $this->container['client_id']; } /** - * Sets hub_id + * Sets client_id * - * @param int $hub_id + * @param string $client_id The client ID of the application that the refresh token was issued for. * * @return self */ - public function setHubId($hub_id) + public function setClientId($client_id) { - if (is_null($hub_id)) { - throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); + if (is_null($client_id)) { + throw new \InvalidArgumentException('non-nullable client_id cannot be null'); } - $this->container['hub_id'] = $hub_id; + $this->container['client_id'] = $client_id; return $this; } /** - * Gets user_id + * Gets hub_domain * - * @return int + * @return string|null */ - public function getUserId() + public function getHubDomain() { - return $this->container['user_id']; + return $this->container['hub_domain']; } /** - * Sets user_id + * Sets hub_domain * - * @param int $user_id + * @param string|null $hub_domain The domain of the HubSpot account associated with the refresh token. * * @return self */ - public function setUserId($user_id) + public function setHubDomain($hub_domain) { - if (is_null($user_id)) { - throw new \InvalidArgumentException('non-nullable user_id cannot be null'); + if (is_null($hub_domain)) { + throw new \InvalidArgumentException('non-nullable hub_domain cannot be null'); } - $this->container['user_id'] = $user_id; + $this->container['hub_domain'] = $hub_domain; return $this; } /** - * Gets scopes + * Gets hub_id * - * @return string[] + * @return int */ - public function getScopes() + public function getHubId() { - return $this->container['scopes']; + return $this->container['hub_id']; } /** - * Sets scopes + * Sets hub_id * - * @param string[] $scopes + * @param int $hub_id The ID of the HubSpot account associated with the refresh token. * * @return self */ - public function setScopes($scopes) + public function setHubId($hub_id) { - if (is_null($scopes)) { - throw new \InvalidArgumentException('non-nullable scopes cannot be null'); + if (is_null($hub_id)) { + throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); } - $this->container['scopes'] = $scopes; + $this->container['hub_id'] = $hub_id; return $this; } /** - * Gets token_type + * Gets scopes * - * @return string + * @return string[] */ - public function getTokenType() + public function getScopes() { - return $this->container['token_type']; + return $this->container['scopes']; } /** - * Sets token_type + * Sets scopes * - * @param string $token_type + * @param string[] $scopes scopes * * @return self */ - public function setTokenType($token_type) + public function setScopes($scopes) { - if (is_null($token_type)) { - throw new \InvalidArgumentException('non-nullable token_type cannot be null'); + if (is_null($scopes)) { + throw new \InvalidArgumentException('non-nullable scopes cannot be null'); } - $this->container['token_type'] = $token_type; + $this->container['scopes'] = $scopes; return $this; } /** - * Gets user + * Gets token * - * @return string|null + * @return string */ - public function getUser() + public function getToken() { - return $this->container['user']; + return $this->container['token']; } /** - * Sets user + * Sets token * - * @param string|null $user + * @param string $token The access token string used to make API calls. * * @return self */ - public function setUser($user) + public function setToken($token) { - if (is_null($user)) { - throw new \InvalidArgumentException('non-nullable user cannot be null'); + if (is_null($token)) { + throw new \InvalidArgumentException('non-nullable token cannot be null'); } - $this->container['user'] = $user; + $this->container['token'] = $token; return $this; } /** - * Gets hub_domain + * Gets token_type * - * @return string|null + * @return string */ - public function getHubDomain() + public function getTokenType() { - return $this->container['hub_domain']; + return $this->container['token_type']; } /** - * Sets hub_domain + * Sets token_type * - * @param string|null $hub_domain + * @param string $token_type The type of token, typically indicating the OAuth token type. Typically `bearer`. * * @return self */ - public function setHubDomain($hub_domain) + public function setTokenType($token_type) { - if (is_null($hub_domain)) { - throw new \InvalidArgumentException('non-nullable hub_domain cannot be null'); + if (is_null($token_type)) { + throw new \InvalidArgumentException('non-nullable token_type cannot be null'); } - $this->container['hub_domain'] = $hub_domain; + $this->container['token_type'] = $token_type; return $this; } /** - * Gets client_id + * Gets user * - * @return string + * @return string|null */ - public function getClientId() + public function getUser() { - return $this->container['client_id']; + return $this->container['user']; } /** - * Sets client_id + * Sets user * - * @param string $client_id + * @param string|null $user The email address of the hubspot user associated with the refresh token. * * @return self */ - public function setClientId($client_id) + public function setUser($user) { - if (is_null($client_id)) { - throw new \InvalidArgumentException('non-nullable client_id cannot be null'); + if (is_null($user)) { + throw new \InvalidArgumentException('non-nullable user cannot be null'); } - $this->container['client_id'] = $client_id; + $this->container['user'] = $user; return $this; } /** - * Gets token + * Gets user_id * - * @return string + * @return int */ - public function getToken() + public function getUserId() { - return $this->container['token']; + return $this->container['user_id']; } /** - * Sets token + * Sets user_id * - * @param string $token + * @param int $user_id The ID of the hubspot user associated with the refresh token. * * @return self */ - public function setToken($token) + public function setUserId($user_id) { - if (is_null($token)) { - throw new \InvalidArgumentException('non-nullable token cannot be null'); + if (is_null($user_id)) { + throw new \InvalidArgumentException('non-nullable user_id cannot be null'); } - $this->container['token'] = $token; + $this->container['user_id'] = $user_id; 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]); } @@ -586,12 +586,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; } @@ -616,11 +616,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/Oauth/Model/SignedAccessToken.php b/codegen/Oauth/Model/SignedAccessToken.php new file mode 100644 index 00000000..7b46e7d7 --- /dev/null +++ b/codegen/Oauth/Model/SignedAccessToken.php @@ -0,0 +1,930 @@ + + */ +class SignedAccessToken implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SignedAccessToken'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'app_id' => 'int', + 'expires_at' => 'int', + 'hub_id' => 'int', + 'hublet' => 'string', + 'installing_user_id' => 'int', + 'is_private_distribution' => 'bool', + 'is_service_account' => 'bool', + 'is_user_level' => 'bool', + 'new_signature' => 'string', + 'scope_to_scope_group_pks' => 'string', + 'scopes' => 'string', + 'signature' => 'string', + 'trial_scope_to_scope_group_pks' => 'string', + 'trial_scopes' => 'string', + 'user_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'app_id' => 'int32', + 'expires_at' => 'int64', + 'hub_id' => 'int32', + 'hublet' => null, + 'installing_user_id' => 'int32', + 'is_private_distribution' => null, + 'is_service_account' => null, + 'is_user_level' => null, + 'new_signature' => null, + 'scope_to_scope_group_pks' => null, + 'scopes' => null, + 'signature' => null, + 'trial_scope_to_scope_group_pks' => null, + 'trial_scopes' => null, + 'user_id' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'app_id' => false, + 'expires_at' => false, + 'hub_id' => false, + 'hublet' => false, + 'installing_user_id' => false, + 'is_private_distribution' => false, + 'is_service_account' => false, + 'is_user_level' => false, + 'new_signature' => false, + 'scope_to_scope_group_pks' => false, + 'scopes' => false, + 'signature' => false, + 'trial_scope_to_scope_group_pks' => false, + 'trial_scopes' => false, + 'user_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'app_id' => 'appId', + 'expires_at' => 'expiresAt', + 'hub_id' => 'hubId', + 'hublet' => 'hublet', + 'installing_user_id' => 'installingUserId', + 'is_private_distribution' => 'isPrivateDistribution', + 'is_service_account' => 'isServiceAccount', + 'is_user_level' => 'isUserLevel', + 'new_signature' => 'newSignature', + 'scope_to_scope_group_pks' => 'scopeToScopeGroupPks', + 'scopes' => 'scopes', + 'signature' => 'signature', + 'trial_scope_to_scope_group_pks' => 'trialScopeToScopeGroupPks', + 'trial_scopes' => 'trialScopes', + 'user_id' => 'userId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'app_id' => 'setAppId', + 'expires_at' => 'setExpiresAt', + 'hub_id' => 'setHubId', + 'hublet' => 'setHublet', + 'installing_user_id' => 'setInstallingUserId', + 'is_private_distribution' => 'setIsPrivateDistribution', + 'is_service_account' => 'setIsServiceAccount', + 'is_user_level' => 'setIsUserLevel', + 'new_signature' => 'setNewSignature', + 'scope_to_scope_group_pks' => 'setScopeToScopeGroupPks', + 'scopes' => 'setScopes', + 'signature' => 'setSignature', + 'trial_scope_to_scope_group_pks' => 'setTrialScopeToScopeGroupPks', + 'trial_scopes' => 'setTrialScopes', + 'user_id' => 'setUserId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'app_id' => 'getAppId', + 'expires_at' => 'getExpiresAt', + 'hub_id' => 'getHubId', + 'hublet' => 'getHublet', + 'installing_user_id' => 'getInstallingUserId', + 'is_private_distribution' => 'getIsPrivateDistribution', + 'is_service_account' => 'getIsServiceAccount', + 'is_user_level' => 'getIsUserLevel', + 'new_signature' => 'getNewSignature', + 'scope_to_scope_group_pks' => 'getScopeToScopeGroupPks', + 'scopes' => 'getScopes', + 'signature' => 'getSignature', + 'trial_scope_to_scope_group_pks' => 'getTrialScopeToScopeGroupPks', + 'trial_scopes' => 'getTrialScopes', + 'user_id' => 'getUserId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('app_id', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('hub_id', $data ?? [], null); + $this->setIfExists('hublet', $data ?? [], null); + $this->setIfExists('installing_user_id', $data ?? [], null); + $this->setIfExists('is_private_distribution', $data ?? [], null); + $this->setIfExists('is_service_account', $data ?? [], null); + $this->setIfExists('is_user_level', $data ?? [], null); + $this->setIfExists('new_signature', $data ?? [], null); + $this->setIfExists('scope_to_scope_group_pks', $data ?? [], null); + $this->setIfExists('scopes', $data ?? [], null); + $this->setIfExists('signature', $data ?? [], null); + $this->setIfExists('trial_scope_to_scope_group_pks', $data ?? [], null); + $this->setIfExists('trial_scopes', $data ?? [], null); + $this->setIfExists('user_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['app_id'] === null) { + $invalidProperties[] = "'app_id' can't be null"; + } + if ($this->container['expires_at'] === null) { + $invalidProperties[] = "'expires_at' can't be null"; + } + if ($this->container['hub_id'] === null) { + $invalidProperties[] = "'hub_id' can't be null"; + } + if ($this->container['hublet'] === null) { + $invalidProperties[] = "'hublet' can't be null"; + } + if ($this->container['installing_user_id'] === null) { + $invalidProperties[] = "'installing_user_id' can't be null"; + } + if ($this->container['is_private_distribution'] === null) { + $invalidProperties[] = "'is_private_distribution' can't be null"; + } + if ($this->container['is_service_account'] === null) { + $invalidProperties[] = "'is_service_account' can't be null"; + } + if ($this->container['is_user_level'] === null) { + $invalidProperties[] = "'is_user_level' can't be null"; + } + if ($this->container['new_signature'] === null) { + $invalidProperties[] = "'new_signature' can't be null"; + } + if ($this->container['scope_to_scope_group_pks'] === null) { + $invalidProperties[] = "'scope_to_scope_group_pks' can't be null"; + } + if ($this->container['scopes'] === null) { + $invalidProperties[] = "'scopes' can't be null"; + } + if ($this->container['signature'] === null) { + $invalidProperties[] = "'signature' can't be null"; + } + if ($this->container['trial_scope_to_scope_group_pks'] === null) { + $invalidProperties[] = "'trial_scope_to_scope_group_pks' can't be null"; + } + if ($this->container['trial_scopes'] === null) { + $invalidProperties[] = "'trial_scopes' can't be null"; + } + if ($this->container['user_id'] === null) { + $invalidProperties[] = "'user_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets app_id + * + * @return int + */ + public function getAppId() + { + return $this->container['app_id']; + } + + /** + * Sets app_id + * + * @param int $app_id The ID of the application associated with the access token. + * + * @return self + */ + public function setAppId($app_id) + { + if (is_null($app_id)) { + throw new \InvalidArgumentException('non-nullable app_id cannot be null'); + } + $this->container['app_id'] = $app_id; + + return $this; + } + + /** + * Gets expires_at + * + * @return int + */ + public function getExpiresAt() + { + return $this->container['expires_at']; + } + + /** + * Sets expires_at + * + * @param int $expires_at The timestamp indicating when the access token will expire. + * + * @return self + */ + public function setExpiresAt($expires_at) + { + if (is_null($expires_at)) { + throw new \InvalidArgumentException('non-nullable expires_at cannot be null'); + } + $this->container['expires_at'] = $expires_at; + + return $this; + } + + /** + * Gets hub_id + * + * @return int + */ + public function getHubId() + { + return $this->container['hub_id']; + } + + /** + * Sets hub_id + * + * @param int $hub_id The ID of the HubSpot account associated with the access token. + * + * @return self + */ + public function setHubId($hub_id) + { + if (is_null($hub_id)) { + throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); + } + $this->container['hub_id'] = $hub_id; + + return $this; + } + + /** + * Gets hublet + * + * @return string + */ + public function getHublet() + { + return $this->container['hublet']; + } + + /** + * Sets hublet + * + * @param string $hublet The specific regional data center where the account is hosted. + * + * @return self + */ + public function setHublet($hublet) + { + if (is_null($hublet)) { + throw new \InvalidArgumentException('non-nullable hublet cannot be null'); + } + $this->container['hublet'] = $hublet; + + return $this; + } + + /** + * Gets installing_user_id + * + * @return int + */ + public function getInstallingUserId() + { + return $this->container['installing_user_id']; + } + + /** + * Sets installing_user_id + * + * @param int $installing_user_id The ID of the user who installed the application. + * + * @return self + */ + public function setInstallingUserId($installing_user_id) + { + if (is_null($installing_user_id)) { + throw new \InvalidArgumentException('non-nullable installing_user_id cannot be null'); + } + $this->container['installing_user_id'] = $installing_user_id; + + return $this; + } + + /** + * Gets is_private_distribution + * + * @return bool + */ + public function getIsPrivateDistribution() + { + return $this->container['is_private_distribution']; + } + + /** + * Sets is_private_distribution + * + * @param bool $is_private_distribution Indicates whether the token is for a privately distributed application. If false, it is marketplace distributed. + * + * @return self + */ + public function setIsPrivateDistribution($is_private_distribution) + { + if (is_null($is_private_distribution)) { + throw new \InvalidArgumentException('non-nullable is_private_distribution cannot be null'); + } + $this->container['is_private_distribution'] = $is_private_distribution; + + return $this; + } + + /** + * Gets is_service_account + * + * @return bool + */ + public function getIsServiceAccount() + { + return $this->container['is_service_account']; + } + + /** + * Sets is_service_account + * + * @param bool $is_service_account Indicates whether the access token is associated with a service account. Meaning it is decoupled from the user who installed it. + * + * @return self + */ + public function setIsServiceAccount($is_service_account) + { + if (is_null($is_service_account)) { + throw new \InvalidArgumentException('non-nullable is_service_account cannot be null'); + } + $this->container['is_service_account'] = $is_service_account; + + return $this; + } + + /** + * Gets is_user_level + * + * @return bool + */ + public function getIsUserLevel() + { + return $this->container['is_user_level']; + } + + /** + * Sets is_user_level + * + * @param bool $is_user_level Indicates whether the access token is issued at the user level. Meaning the app is configured to allow multiple installs of the same app on a hub. + * + * @return self + */ + public function setIsUserLevel($is_user_level) + { + if (is_null($is_user_level)) { + throw new \InvalidArgumentException('non-nullable is_user_level cannot be null'); + } + $this->container['is_user_level'] = $is_user_level; + + return $this; + } + + /** + * Gets new_signature + * + * @return string + */ + public function getNewSignature() + { + return $this->container['new_signature']; + } + + /** + * Sets new_signature + * + * @param string $new_signature The updated cryptographic signature for the access token. + * + * @return self + */ + public function setNewSignature($new_signature) + { + if (is_null($new_signature)) { + throw new \InvalidArgumentException('non-nullable new_signature cannot be null'); + } + $this->container['new_signature'] = $new_signature; + + return $this; + } + + /** + * Gets scope_to_scope_group_pks + * + * @return string + */ + public function getScopeToScopeGroupPks() + { + return $this->container['scope_to_scope_group_pks']; + } + + /** + * Sets scope_to_scope_group_pks + * + * @param string $scope_to_scope_group_pks A mapping of scopes to their corresponding scope group primary keys. + * + * @return self + */ + public function setScopeToScopeGroupPks($scope_to_scope_group_pks) + { + if (is_null($scope_to_scope_group_pks)) { + throw new \InvalidArgumentException('non-nullable scope_to_scope_group_pks cannot be null'); + } + $this->container['scope_to_scope_group_pks'] = $scope_to_scope_group_pks; + + return $this; + } + + /** + * Gets scopes + * + * @return string + */ + public function getScopes() + { + return $this->container['scopes']; + } + + /** + * Sets scopes + * + * @param string $scopes The permissions granted to the access token. + * + * @return self + */ + public function setScopes($scopes) + { + if (is_null($scopes)) { + throw new \InvalidArgumentException('non-nullable scopes cannot be null'); + } + $this->container['scopes'] = $scopes; + + return $this; + } + + /** + * Gets signature + * + * @return string + */ + public function getSignature() + { + return $this->container['signature']; + } + + /** + * Sets signature + * + * @param string $signature The cryptographic signature used to verify the integrity of the access token. + * + * @return self + */ + public function setSignature($signature) + { + if (is_null($signature)) { + throw new \InvalidArgumentException('non-nullable signature cannot be null'); + } + $this->container['signature'] = $signature; + + return $this; + } + + /** + * Gets trial_scope_to_scope_group_pks + * + * @return string + */ + public function getTrialScopeToScopeGroupPks() + { + return $this->container['trial_scope_to_scope_group_pks']; + } + + /** + * Sets trial_scope_to_scope_group_pks + * + * @param string $trial_scope_to_scope_group_pks A mapping of trial scopes to their corresponding scope group primary keys. + * + * @return self + */ + public function setTrialScopeToScopeGroupPks($trial_scope_to_scope_group_pks) + { + if (is_null($trial_scope_to_scope_group_pks)) { + throw new \InvalidArgumentException('non-nullable trial_scope_to_scope_group_pks cannot be null'); + } + $this->container['trial_scope_to_scope_group_pks'] = $trial_scope_to_scope_group_pks; + + return $this; + } + + /** + * Gets trial_scopes + * + * @return string + */ + public function getTrialScopes() + { + return $this->container['trial_scopes']; + } + + /** + * Sets trial_scopes + * + * @param string $trial_scopes The trial scopes included in the access token. + * + * @return self + */ + public function setTrialScopes($trial_scopes) + { + if (is_null($trial_scopes)) { + throw new \InvalidArgumentException('non-nullable trial_scopes cannot be null'); + } + $this->container['trial_scopes'] = $trial_scopes; + + return $this; + } + + /** + * Gets user_id + * + * @return int + */ + public function getUserId() + { + return $this->container['user_id']; + } + + /** + * Sets user_id + * + * @param int $user_id The ID of the hubspot user associated with the access token. + * + * @return self + */ + public function setUserId($user_id) + { + if (is_null($user_id)) { + throw new \InvalidArgumentException('non-nullable user_id cannot be null'); + } + $this->container['user_id'] = $user_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Oauth/Model/TokenResponseIF.php b/codegen/Oauth/Model/TokenResponseIF.php index 9b701f0c..8056bad8 100644 --- a/codegen/Oauth/Model/TokenResponseIF.php +++ b/codegen/Oauth/Model/TokenResponseIF.php @@ -2,7 +2,7 @@ /** * TokenResponseIF * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.0 */ /** @@ -58,10 +58,12 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPITypes = [ 'access_token' => 'string', - 'refresh_token' => 'string', + 'expires_in' => 'int', + 'hub_id' => 'int', 'id_token' => 'string', + 'scopes' => 'string[]', 'token_type' => 'string', - 'expires_in' => 'int' + 'user_id' => 'int' ]; /** @@ -73,10 +75,12 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'access_token' => null, - 'refresh_token' => null, + 'expires_in' => 'int64', + 'hub_id' => 'int32', 'id_token' => null, + 'scopes' => null, 'token_type' => null, - 'expires_in' => 'int32' + 'user_id' => 'int32' ]; /** @@ -86,10 +90,12 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static array $openAPINullables = [ 'access_token' => false, - 'refresh_token' => false, + 'expires_in' => false, + 'hub_id' => false, 'id_token' => false, + 'scopes' => false, 'token_type' => false, - 'expires_in' => false + 'user_id' => false ]; /** @@ -178,11 +184,13 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'access_token' => 'access_token', - 'refresh_token' => 'refresh_token', - 'id_token' => 'id_token', - 'token_type' => 'token_type', - 'expires_in' => 'expires_in' + 'access_token' => 'accessToken', + 'expires_in' => 'expiresIn', + 'hub_id' => 'hubId', + 'id_token' => 'idToken', + 'scopes' => 'scopes', + 'token_type' => 'tokenType', + 'user_id' => 'userId' ]; /** @@ -192,10 +200,12 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'access_token' => 'setAccessToken', - 'refresh_token' => 'setRefreshToken', + 'expires_in' => 'setExpiresIn', + 'hub_id' => 'setHubId', 'id_token' => 'setIdToken', + 'scopes' => 'setScopes', 'token_type' => 'setTokenType', - 'expires_in' => 'setExpiresIn' + 'user_id' => 'setUserId' ]; /** @@ -205,10 +215,12 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'access_token' => 'getAccessToken', - 'refresh_token' => 'getRefreshToken', + 'expires_in' => 'getExpiresIn', + 'hub_id' => 'getHubId', 'id_token' => 'getIdToken', + 'scopes' => 'getScopes', 'token_type' => 'getTokenType', - 'expires_in' => 'getExpiresIn' + 'user_id' => 'getUserId' ]; /** @@ -269,10 +281,12 @@ public function getModelName() public function __construct(?array $data = null) { $this->setIfExists('access_token', $data ?? [], null); - $this->setIfExists('refresh_token', $data ?? [], null); + $this->setIfExists('expires_in', $data ?? [], null); + $this->setIfExists('hub_id', $data ?? [], null); $this->setIfExists('id_token', $data ?? [], null); + $this->setIfExists('scopes', $data ?? [], null); $this->setIfExists('token_type', $data ?? [], null); - $this->setIfExists('expires_in', $data ?? [], null); + $this->setIfExists('user_id', $data ?? [], null); } /** @@ -302,18 +316,6 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['access_token'] === null) { - $invalidProperties[] = "'access_token' can't be null"; - } - if ($this->container['refresh_token'] === null) { - $invalidProperties[] = "'refresh_token' can't be null"; - } - if ($this->container['token_type'] === null) { - $invalidProperties[] = "'token_type' can't be null"; - } - if ($this->container['expires_in'] === null) { - $invalidProperties[] = "'expires_in' can't be null"; - } return $invalidProperties; } @@ -332,7 +334,7 @@ public function valid() /** * Gets access_token * - * @return string + * @return string|null */ public function getAccessToken() { @@ -342,7 +344,7 @@ public function getAccessToken() /** * Sets access_token * - * @param string $access_token + * @param string|null $access_token The access token used for authentication in API requests. * * @return self */ @@ -357,28 +359,55 @@ public function setAccessToken($access_token) } /** - * Gets refresh_token + * Gets expires_in * - * @return string + * @return int|null */ - public function getRefreshToken() + public function getExpiresIn() { - return $this->container['refresh_token']; + return $this->container['expires_in']; } /** - * Sets refresh_token + * Sets expires_in * - * @param string $refresh_token + * @param int|null $expires_in The duration in seconds for which the access token is valid. * * @return self */ - public function setRefreshToken($refresh_token) + public function setExpiresIn($expires_in) { - if (is_null($refresh_token)) { - throw new \InvalidArgumentException('non-nullable refresh_token cannot be null'); + if (is_null($expires_in)) { + throw new \InvalidArgumentException('non-nullable expires_in cannot be null'); } - $this->container['refresh_token'] = $refresh_token; + $this->container['expires_in'] = $expires_in; + + return $this; + } + + /** + * Gets hub_id + * + * @return int|null + */ + public function getHubId() + { + return $this->container['hub_id']; + } + + /** + * Sets hub_id + * + * @param int|null $hub_id The ID of the HubSpot account associated with the token. + * + * @return self + */ + public function setHubId($hub_id) + { + if (is_null($hub_id)) { + throw new \InvalidArgumentException('non-nullable hub_id cannot be null'); + } + $this->container['hub_id'] = $hub_id; return $this; } @@ -396,7 +425,7 @@ public function getIdToken() /** * Sets id_token * - * @param string|null $id_token + * @param string|null $id_token The ID token that contains identity claims about the user. * * @return self */ @@ -410,10 +439,37 @@ public function setIdToken($id_token) return $this; } + /** + * Gets scopes + * + * @return string[]|null + */ + public function getScopes() + { + return $this->container['scopes']; + } + + /** + * Sets scopes + * + * @param string[]|null $scopes scopes + * + * @return self + */ + public function setScopes($scopes) + { + if (is_null($scopes)) { + throw new \InvalidArgumentException('non-nullable scopes cannot be null'); + } + $this->container['scopes'] = $scopes; + + return $this; + } + /** * Gets token_type * - * @return string + * @return string|null */ public function getTokenType() { @@ -423,7 +479,7 @@ public function getTokenType() /** * Sets token_type * - * @param string $token_type + * @param string|null $token_type The type of token, typically indicating the authentication scheme. Typically `bearer`. * * @return self */ @@ -438,39 +494,39 @@ public function setTokenType($token_type) } /** - * Gets expires_in + * Gets user_id * - * @return int + * @return int|null */ - public function getExpiresIn() + public function getUserId() { - return $this->container['expires_in']; + return $this->container['user_id']; } /** - * Sets expires_in + * Sets user_id * - * @param int $expires_in + * @param int|null $user_id The ID of the hubspot user for whom the token was created. * * @return self */ - public function setExpiresIn($expires_in) + public function setUserId($user_id) { - if (is_null($expires_in)) { - throw new \InvalidArgumentException('non-nullable expires_in cannot be null'); + if (is_null($user_id)) { + throw new \InvalidArgumentException('non-nullable user_id cannot be null'); } - $this->container['expires_in'] = $expires_in; + $this->container['user_id'] = $user_id; 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]); } @@ -478,12 +534,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; } @@ -508,11 +564,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/Oauth/ObjectSerializer.php b/codegen/Oauth/ObjectSerializer.php index 76ad33eb..f2e36738 100644 --- a/codegen/Oauth/ObjectSerializer.php +++ b/codegen/Oauth/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Oauth @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.19.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) : ''; } }