From c451bdccc1c368dc2aa870421a3e400a53be59ac Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Fri, 25 Apr 2025 12:19:33 +0300 Subject: [PATCH] Remove CMS Perfomance API client --- .../Performance/Api/PublicPerformanceApi.php | 1040 --------------- codegen/Cms/Performance/ApiException.php | 119 -- codegen/Cms/Performance/Configuration.php | 531 -------- codegen/Cms/Performance/HeaderSelector.php | 273 ---- codegen/Cms/Performance/Model/Error.php | 622 --------- codegen/Cms/Performance/Model/ErrorDetail.php | 548 -------- .../Cms/Performance/Model/ModelInterface.php | 111 -- .../Cms/Performance/Model/PerformanceView.php | 1181 ----------------- .../Model/PublicPerformanceResponse.php | 725 ---------- codegen/Cms/Performance/ObjectSerializer.php | 617 --------- lib/Discovery/Cms/Discovery.php | 1 - lib/Discovery/Cms/Performance/Discovery.php | 11 - tests/spec/Discovery/Cms/DiscoverySpec.php | 1 - .../Cms/Performance/DiscoverySpec.php | 27 - 14 files changed, 5807 deletions(-) delete mode 100644 codegen/Cms/Performance/Api/PublicPerformanceApi.php delete mode 100644 codegen/Cms/Performance/ApiException.php delete mode 100644 codegen/Cms/Performance/Configuration.php delete mode 100644 codegen/Cms/Performance/HeaderSelector.php delete mode 100644 codegen/Cms/Performance/Model/Error.php delete mode 100644 codegen/Cms/Performance/Model/ErrorDetail.php delete mode 100644 codegen/Cms/Performance/Model/ModelInterface.php delete mode 100644 codegen/Cms/Performance/Model/PerformanceView.php delete mode 100644 codegen/Cms/Performance/Model/PublicPerformanceResponse.php delete mode 100644 codegen/Cms/Performance/ObjectSerializer.php delete mode 100644 lib/Discovery/Cms/Performance/Discovery.php delete mode 100644 tests/spec/Discovery/Cms/Performance/DiscoverySpec.php diff --git a/codegen/Cms/Performance/Api/PublicPerformanceApi.php b/codegen/Cms/Performance/Api/PublicPerformanceApi.php deleted file mode 100644 index 3cd50a81e..000000000 --- a/codegen/Cms/Performance/Api/PublicPerformanceApi.php +++ /dev/null @@ -1,1040 +0,0 @@ - [ - 'application/json', - ], - 'getUptime' => [ - 'application/json', - ], - ]; - - /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ?ClientInterface $client = null, - ?Configuration $config = null, - ?HeaderSelector $selector = null, - int $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: Configuration::getDefaultConfiguration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation getPage - * - * View your website's performance. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path The url path of the domain to return data for. (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Performance\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse|\HubSpot\Client\Cms\Performance\Model\Error - */ - public function getPage($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getPage'][0]) - { - list($response) = $this->getPageWithHttpInfo($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - return $response; - } - - /** - * Operation getPageWithHttpInfo - * - * View your website's performance. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path The url path of the domain to return data for. (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Performance\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse|\HubSpot\Client\Cms\Performance\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getPageWithHttpInfo($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getPage'][0]) - { - $request = $this->getPageRequest($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Performance\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Performance\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Performance\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - $returnType = '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Performance\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getPageAsync - * - * View your website's performance. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path The url path of the domain to return data for. (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPageAsync($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getPage'][0]) - { - return $this->getPageAsyncWithHttpInfo($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getPageAsyncWithHttpInfo - * - * View your website's performance. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path The url path of the domain to return data for. (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPageAsyncWithHttpInfo($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getPage'][0]) - { - $returnType = '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse'; - $request = $this->getPageRequest($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getPage' - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path The url path of the domain to return data for. (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getPageRequest($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getPage'][0]) - { - - - - - - - - - - - $resourcePath = '/cms/v3/performance/'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $domain, - 'domain', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $path, - 'path', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $pad, - 'pad', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $sum, - 'sum', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $period, - 'period', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $interval, - 'interval', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $start, - 'start', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $end, - 'end', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getUptime - * - * View your website's uptime. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path path (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUptime'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Performance\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse|\HubSpot\Client\Cms\Performance\Model\Error - */ - public function getUptime($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getUptime'][0]) - { - list($response) = $this->getUptimeWithHttpInfo($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - return $response; - } - - /** - * Operation getUptimeWithHttpInfo - * - * View your website's uptime. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUptime'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Performance\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse|\HubSpot\Client\Cms\Performance\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getUptimeWithHttpInfo($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getUptime'][0]) - { - $request = $this->getUptimeRequest($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Performance\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Performance\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Performance\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - $returnType = '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Performance\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getUptimeAsync - * - * View your website's uptime. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUptime'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUptimeAsync($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getUptime'][0]) - { - return $this->getUptimeAsyncWithHttpInfo($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getUptimeAsyncWithHttpInfo - * - * View your website's uptime. - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUptime'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUptimeAsyncWithHttpInfo($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getUptime'][0]) - { - $returnType = '\HubSpot\Client\Cms\Performance\Model\PublicPerformanceResponse'; - $request = $this->getUptimeRequest($domain, $path, $pad, $sum, $period, $interval, $start, $end, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getUptime' - * - * @param string|null $domain The domain to search return data for. (optional) - * @param string|null $path (optional) - * @param bool|null $pad Specifies whether the time series data should have empty intervals if performance data is not present to create a continuous set. (optional) - * @param bool|null $sum Specifies whether the time series data should be summated for the given period. Defaults to false. (optional) - * @param string|null $period A relative period to return time series data for. This value is ignored if start and/or end are provided. Valid periods: [15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param string|null $interval The time series interval to group data by. Valid intervals: [1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w] (optional) - * @param int|null $start A timestamp in milliseconds that indicates the start of the time period. (optional) - * @param int|null $end A timestamp in milliseconds that indicates the end of the time period. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUptime'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getUptimeRequest($domain = null, $path = null, $pad = null, $sum = null, $period = null, $interval = null, $start = null, $end = null, string $contentType = self::contentTypes['getUptime'][0]) - { - - - - - - - - - - - $resourcePath = '/cms/v3/performance/uptime'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $domain, - 'domain', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $path, - 'path', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $pad, - 'pad', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $sum, - 'sum', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $period, - 'period', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $interval, - 'interval', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $start, - 'start', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $end, - 'end', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/codegen/Cms/Performance/ApiException.php b/codegen/Cms/Performance/ApiException.php deleted file mode 100644 index e6d2b24c9..000000000 --- a/codegen/Cms/Performance/ApiException.php +++ /dev/null @@ -1,119 +0,0 @@ -responseHeaders = $responseHeaders; - $this->responseBody = $responseBody; - } - - /** - * Gets the HTTP response header - * - * @return string[][]|null HTTP response header - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * Gets the HTTP body of the server response either as Json or string - * - * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string - */ - public function getResponseBody() - { - return $this->responseBody; - } - - /** - * Sets the deserialized response object (during deserialization) - * - * @param mixed $obj Deserialized response object - * - * @return void - */ - public function setResponseObject($obj) - { - $this->responseObject = $obj; - } - - /** - * Gets the deserialized response object (during deserialization) - * - * @return mixed the deserialized response object - */ - public function getResponseObject() - { - return $this->responseObject; - } -} diff --git a/codegen/Cms/Performance/Configuration.php b/codegen/Cms/Performance/Configuration.php deleted file mode 100644 index 860901180..000000000 --- a/codegen/Cms/Performance/Configuration.php +++ /dev/null @@ -1,531 +0,0 @@ -tempFolderPath = sys_get_temp_dir(); - } - - /** - * Sets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $key API key or token - * - * @return $this - */ - public function setApiKey($apiKeyIdentifier, $key) - { - $this->apiKeys[$apiKeyIdentifier] = $key; - return $this; - } - - /** - * Gets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string API key or token - */ - public function getApiKey($apiKeyIdentifier) - { - return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; - } - - /** - * Sets the prefix for API key (e.g. Bearer) - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $prefix API key prefix, e.g. Bearer - * - * @return $this - */ - public function setApiKeyPrefix($apiKeyIdentifier, $prefix) - { - $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; - return $this; - } - - /** - * Gets API key prefix - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string - */ - public function getApiKeyPrefix($apiKeyIdentifier) - { - return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; - } - - /** - * Sets the access token for OAuth - * - * @param string $accessToken Token for OAuth - * - * @return $this - */ - public function setAccessToken($accessToken) - { - $this->accessToken = $accessToken; - return $this; - } - - /** - * Gets the access token for OAuth - * - * @return string Access token for OAuth - */ - public function getAccessToken() - { - return $this->accessToken; - } - - /** - * Sets boolean format for query string. - * - * @param string $booleanFormat Boolean format for query string - * - * @return $this - */ - public function setBooleanFormatForQueryString(string $booleanFormat) - { - $this->booleanFormatForQueryString = $booleanFormat; - - return $this; - } - - /** - * Gets boolean format for query string. - * - * @return string Boolean format for query string - */ - public function getBooleanFormatForQueryString(): string - { - return $this->booleanFormatForQueryString; - } - - /** - * Sets the username for HTTP basic authentication - * - * @param string $username Username for HTTP basic authentication - * - * @return $this - */ - public function setUsername($username) - { - $this->username = $username; - return $this; - } - - /** - * Gets the username for HTTP basic authentication - * - * @return string Username for HTTP basic authentication - */ - public function getUsername() - { - return $this->username; - } - - /** - * Sets the password for HTTP basic authentication - * - * @param string $password Password for HTTP basic authentication - * - * @return $this - */ - public function setPassword($password) - { - $this->password = $password; - return $this; - } - - /** - * Gets the password for HTTP basic authentication - * - * @return string Password for HTTP basic authentication - */ - public function getPassword() - { - return $this->password; - } - - /** - * Sets the host - * - * @param string $host Host - * - * @return $this - */ - public function setHost($host) - { - $this->host = $host; - return $this; - } - - /** - * Gets the host - * - * @return string Host - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the user agent of the api client - * - * @param string $userAgent the user agent of the api client - * - * @throws \InvalidArgumentException - * @return $this - */ - public function setUserAgent($userAgent) - { - if (!is_string($userAgent)) { - throw new \InvalidArgumentException('User-agent must be a string.'); - } - - $this->userAgent = $userAgent; - return $this; - } - - /** - * Gets the user agent of the api client - * - * @return string user agent - */ - public function getUserAgent() - { - return $this->userAgent; - } - - /** - * Sets debug flag - * - * @param bool $debug Debug flag - * - * @return $this - */ - public function setDebug($debug) - { - $this->debug = $debug; - return $this; - } - - /** - * Gets the debug flag - * - * @return bool - */ - public function getDebug() - { - return $this->debug; - } - - /** - * Sets the debug file - * - * @param string $debugFile Debug file - * - * @return $this - */ - public function setDebugFile($debugFile) - { - $this->debugFile = $debugFile; - return $this; - } - - /** - * Gets the debug file - * - * @return string - */ - public function getDebugFile() - { - return $this->debugFile; - } - - /** - * Sets the temp folder path - * - * @param string $tempFolderPath Temp folder path - * - * @return $this - */ - public function setTempFolderPath($tempFolderPath) - { - $this->tempFolderPath = $tempFolderPath; - return $this; - } - - /** - * Gets the temp folder path - * - * @return string Temp folder path - */ - public function getTempFolderPath() - { - return $this->tempFolderPath; - } - - /** - * Gets the default configuration instance - * - * @return Configuration - */ - public static function getDefaultConfiguration() - { - if (self::$defaultConfiguration === null) { - self::$defaultConfiguration = new Configuration(); - } - - return self::$defaultConfiguration; - } - - /** - * Sets the default configuration instance - * - * @param Configuration $config An instance of the Configuration Object - * - * @return void - */ - public static function setDefaultConfiguration(Configuration $config) - { - self::$defaultConfiguration = $config; - } - - /** - * Gets the essential information for debugging - * - * @return string The report for debugging - */ - public static function toDebugReport() - { - $report = 'PHP SDK (HubSpot\Client\Cms\Performance) Debug Report:' . PHP_EOL; - $report .= ' OS: ' . php_uname() . PHP_EOL; - $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; - $report .= ' The version of the OpenAPI document: v3' . PHP_EOL; - $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; - - return $report; - } - - /** - * Get API key (with prefix if set) - * - * @param string $apiKeyIdentifier name of apikey - * - * @return null|string API key with the prefix - */ - public function getApiKeyWithPrefix($apiKeyIdentifier) - { - $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); - $apiKey = $this->getApiKey($apiKeyIdentifier); - - if ($apiKey === null) { - return null; - } - - if ($prefix === null) { - $keyWithPrefix = $apiKey; - } else { - $keyWithPrefix = $prefix . ' ' . $apiKey; - } - - return $keyWithPrefix; - } - - /** - * Returns an array of host settings - * - * @return array an array of host settings - */ - public function getHostSettings() - { - return [ - [ - "url" => "https://api.hubapi.com", - "description" => "No description provided", - ] - ]; - } - - /** - * Returns URL based on host settings, index and variables - * - * @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients - * @param int $hostIndex index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings - */ - public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null) - { - if (null === $variables) { - $variables = []; - } - - // check array index out of bound - if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { - throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostSettings)); - } - - $host = $hostSettings[$hostIndex]; - $url = $host["url"]; - - // go through variable and assign a value - foreach ($host["variables"] ?? [] as $name => $variable) { - if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user - if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum - $url = str_replace("{".$name."}", $variables[$name], $url); - } else { - throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); - } - } else { - // use default value - $url = str_replace("{".$name."}", $variable["default_value"], $url); - } - } - - return $url; - } - - /** - * Returns URL based on the index and variables - * - * @param int $index index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings - */ - public function getHostFromSettings($index, $variables = null) - { - return self::getHostString($this->getHostSettings(), $index, $variables); - } -} diff --git a/codegen/Cms/Performance/HeaderSelector.php b/codegen/Cms/Performance/HeaderSelector.php deleted file mode 100644 index d23cda3dd..000000000 --- a/codegen/Cms/Performance/HeaderSelector.php +++ /dev/null @@ -1,273 +0,0 @@ -selectAcceptHeader($accept); - if ($accept !== null) { - $headers['Accept'] = $accept; - } - - if (!$isMultipart) { - if($contentType === '') { - $contentType = 'application/json'; - } - - $headers['Content-Type'] = $contentType; - } - - return $headers; - } - - /** - * Return the header 'Accept' based on an array of Accept provided. - * - * @param string[] $accept Array of header - * - * @return null|string Accept (e.g. application/json) - */ - private function selectAcceptHeader(array $accept): ?string - { - # filter out empty entries - $accept = array_filter($accept); - - if (count($accept) === 0) { - return null; - } - - # If there's only one Accept header, just use it - if (count($accept) === 1) { - return reset($accept); - } - - # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = $this->selectJsonMimeList($accept); - if (count($headersWithJson) === 0) { - return implode(',', $accept); - } - - # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, - # to give the highest priority to json-like headers - recalculating the existing ones, if needed - return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); - } - - /** - * Detects whether a string contains a valid JSON mime type - * - * @param string $searchString - * @return bool - */ - public function isJsonMime(string $searchString): bool - { - return preg_match('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~', $searchString) === 1; - } - - /** - * Select all items from a list containing a JSON mime type - * - * @param array $mimeList - * @return array - */ - private function selectJsonMimeList(array $mimeList): array { - $jsonMimeList = []; - foreach ($mimeList as $mime) { - if($this->isJsonMime($mime)) { - $jsonMimeList[] = $mime; - } - } - return $jsonMimeList; - } - - - /** - * Create an Accept header string from the given "Accept" headers array, recalculating all weights - * - * @param string[] $accept Array of Accept Headers - * @param string[] $headersWithJson Array of Accept Headers of type "json" - * - * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") - */ - private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string - { - $processedHeaders = [ - 'withApplicationJson' => [], - 'withJson' => [], - 'withoutJson' => [], - ]; - - foreach ($accept as $header) { - - $headerData = $this->getHeaderAndWeight($header); - - if (stripos($headerData['header'], 'application/json') === 0) { - $processedHeaders['withApplicationJson'][] = $headerData; - } elseif (in_array($header, $headersWithJson, true)) { - $processedHeaders['withJson'][] = $headerData; - } else { - $processedHeaders['withoutJson'][] = $headerData; - } - } - - $acceptHeaders = []; - $currentWeight = 1000; - - $hasMoreThan28Headers = count($accept) > 28; - - foreach($processedHeaders as $headers) { - if (count($headers) > 0) { - $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); - } - } - - $acceptHeaders = array_merge(...$acceptHeaders); - - return implode(',', $acceptHeaders); - } - - /** - * Given an Accept header, returns an associative array splitting the header and its weight - * - * @param string $header "Accept" Header - * - * @return array with the header and its weight - */ - private function getHeaderAndWeight(string $header): array - { - # matches headers with weight, splitting the header and the weight in $outputArray - if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { - $headerData = [ - 'header' => $outputArray[1], - 'weight' => (int)($outputArray[2] * 1000), - ]; - } else { - $headerData = [ - 'header' => trim($header), - 'weight' => 1000, - ]; - } - - return $headerData; - } - - /** - * @param array[] $headers - * @param float $currentWeight - * @param bool $hasMoreThan28Headers - * @return string[] array of adjusted "Accept" headers - */ - private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array - { - usort($headers, function (array $a, array $b) { - return $b['weight'] - $a['weight']; - }); - - $acceptHeaders = []; - foreach ($headers as $index => $header) { - if($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) - { - $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); - } - - $weight = $currentWeight; - - $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); - } - - $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); - - return $acceptHeaders; - } - - /** - * @param string $header - * @param int $weight - * @return string - */ - private function buildAcceptHeader(string $header, int $weight): string - { - if($weight === 1000) { - return $header; - } - - return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); - } - - /** - * Calculate the next weight, based on the current one. - * - * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the - * following formula: - * - * next weight = current weight - 10 ^ (floor(log(current weight - 1))) - * - * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) - * - * Starting from 1000, this generates the following series: - * - * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 - * - * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works - * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 - * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. - * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int - */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int - { - if ($currentWeight <= 1) { - return 1; - } - - if ($hasMoreThan28Headers) { - return $currentWeight - 1; - } - - return $currentWeight - 10 ** floor( log10($currentWeight - 1) ); - } -} diff --git a/codegen/Cms/Performance/Model/Error.php b/codegen/Cms/Performance/Model/Error.php deleted file mode 100644 index 0c7fc66cf..000000000 --- a/codegen/Cms/Performance/Model/Error.php +++ /dev/null @@ -1,622 +0,0 @@ - - */ -class Error implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Error'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'sub_category' => 'string', - 'context' => 'array', - 'correlation_id' => 'string', - 'links' => 'array', - 'message' => 'string', - 'category' => 'string', - 'errors' => '\HubSpot\Client\Cms\Performance\Model\ErrorDetail[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'sub_category' => null, - 'context' => null, - 'correlation_id' => 'uuid', - 'links' => null, - 'message' => null, - 'category' => null, - 'errors' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'sub_category' => false, - 'context' => false, - 'correlation_id' => false, - 'links' => false, - 'message' => false, - 'category' => false, - 'errors' => 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 = [ - 'sub_category' => 'subCategory', - 'context' => 'context', - 'correlation_id' => 'correlationId', - 'links' => 'links', - 'message' => 'message', - 'category' => 'category', - 'errors' => 'errors' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'sub_category' => 'setSubCategory', - 'context' => 'setContext', - 'correlation_id' => 'setCorrelationId', - 'links' => 'setLinks', - 'message' => 'setMessage', - 'category' => 'setCategory', - 'errors' => 'setErrors' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'sub_category' => 'getSubCategory', - 'context' => 'getContext', - 'correlation_id' => 'getCorrelationId', - 'links' => 'getLinks', - 'message' => 'getMessage', - 'category' => 'getCategory', - 'errors' => 'getErrors' - ]; - - /** - * 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('sub_category', $data ?? [], null); - $this->setIfExists('context', $data ?? [], null); - $this->setIfExists('correlation_id', $data ?? [], null); - $this->setIfExists('links', $data ?? [], null); - $this->setIfExists('message', $data ?? [], null); - $this->setIfExists('category', $data ?? [], null); - $this->setIfExists('errors', $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['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; - } - - /** - * 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 sub_category - * - * @return string|null - */ - public function getSubCategory() - { - return $this->container['sub_category']; - } - - /** - * Sets sub_category - * - * @param string|null $sub_category A specific category that contains more specific detail about the error - * - * @return self - */ - public function setSubCategory($sub_category) - { - if (is_null($sub_category)) { - throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); - } - $this->container['sub_category'] = $sub_category; - - return $this; - } - - /** - * Gets context - * - * @return array|null - */ - public function getContext() - { - return $this->container['context']; - } - - /** - * Sets context - * - * @param array|null $context Context about the error condition - * - * @return self - */ - public function setContext($context) - { - if (is_null($context)) { - throw new \InvalidArgumentException('non-nullable context cannot be null'); - } - $this->container['context'] = $context; - - return $this; - } - - /** - * Gets correlation_id - * - * @return string - */ - public function getCorrelationId() - { - return $this->container['correlation_id']; - } - - /** - * Sets correlation_id - * - * @param string $correlation_id A unique identifier for the request. Include this value with any error reports or support tickets - * - * @return self - */ - public function setCorrelationId($correlation_id) - { - if (is_null($correlation_id)) { - throw new \InvalidArgumentException('non-nullable correlation_id cannot be null'); - } - $this->container['correlation_id'] = $correlation_id; - - return $this; - } - - /** - * Gets links - * - * @return array|null - */ - public function getLinks() - { - return $this->container['links']; - } - - /** - * Sets links - * - * @param array|null $links A map of link names to associated URIs containing documentation about the error or recommended remediation steps - * - * @return self - */ - public function setLinks($links) - { - if (is_null($links)) { - throw new \InvalidArgumentException('non-nullable links cannot be null'); - } - $this->container['links'] = $links; - - return $this; - } - - /** - * Gets message - * - * @return string - */ - public function getMessage() - { - return $this->container['message']; - } - - /** - * Sets message - * - * @param string $message A human readable message describing the error along with remediation steps where appropriate - * - * @return self - */ - public function setMessage($message) - { - if (is_null($message)) { - throw new \InvalidArgumentException('non-nullable message cannot be null'); - } - $this->container['message'] = $message; - - return $this; - } - - /** - * 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 - * - * @return \HubSpot\Client\Cms\Performance\Model\ErrorDetail[]|null - */ - public function getErrors() - { - return $this->container['errors']; - } - - /** - * Sets errors - * - * @param \HubSpot\Client\Cms\Performance\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; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($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 $offset Offset - * - * @return void - */ - public function offsetUnset($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/Cms/Performance/Model/ErrorDetail.php b/codegen/Cms/Performance/Model/ErrorDetail.php deleted file mode 100644 index e77d03c7c..000000000 --- a/codegen/Cms/Performance/Model/ErrorDetail.php +++ /dev/null @@ -1,548 +0,0 @@ - - */ -class ErrorDetail implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ErrorDetail'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'sub_category' => 'string', - 'code' => 'string', - 'in' => 'string', - 'context' => 'array', - 'message' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'sub_category' => null, - 'code' => null, - 'in' => null, - 'context' => null, - 'message' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'sub_category' => false, - 'code' => false, - 'in' => false, - 'context' => false, - 'message' => 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 = [ - 'sub_category' => 'subCategory', - 'code' => 'code', - 'in' => 'in', - 'context' => 'context', - 'message' => 'message' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'sub_category' => 'setSubCategory', - 'code' => 'setCode', - 'in' => 'setIn', - 'context' => 'setContext', - 'message' => 'setMessage' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'sub_category' => 'getSubCategory', - 'code' => 'getCode', - 'in' => 'getIn', - 'context' => 'getContext', - 'message' => 'getMessage' - ]; - - /** - * 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('sub_category', $data ?? [], null); - $this->setIfExists('code', $data ?? [], null); - $this->setIfExists('in', $data ?? [], null); - $this->setIfExists('context', $data ?? [], null); - $this->setIfExists('message', $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['message'] === null) { - $invalidProperties[] = "'message' 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 sub_category - * - * @return string|null - */ - public function getSubCategory() - { - return $this->container['sub_category']; - } - - /** - * Sets sub_category - * - * @param string|null $sub_category A specific category that contains more specific detail about the error - * - * @return self - */ - public function setSubCategory($sub_category) - { - if (is_null($sub_category)) { - throw new \InvalidArgumentException('non-nullable sub_category cannot be null'); - } - $this->container['sub_category'] = $sub_category; - - return $this; - } - - /** - * Gets code - * - * @return string|null - */ - public function getCode() - { - return $this->container['code']; - } - - /** - * Sets code - * - * @param string|null $code The status code associated with the error detail - * - * @return self - */ - public function setCode($code) - { - if (is_null($code)) { - throw new \InvalidArgumentException('non-nullable code cannot be null'); - } - $this->container['code'] = $code; - - return $this; - } - - /** - * Gets in - * - * @return string|null - */ - public function getIn() - { - return $this->container['in']; - } - - /** - * Sets in - * - * @param string|null $in The name of the field or parameter in which the error was found. - * - * @return self - */ - public function setIn($in) - { - if (is_null($in)) { - throw new \InvalidArgumentException('non-nullable in cannot be null'); - } - $this->container['in'] = $in; - - return $this; - } - - /** - * Gets context - * - * @return array|null - */ - public function getContext() - { - return $this->container['context']; - } - - /** - * Sets context - * - * @param array|null $context Context about the error condition - * - * @return self - */ - public function setContext($context) - { - if (is_null($context)) { - throw new \InvalidArgumentException('non-nullable context cannot be null'); - } - $this->container['context'] = $context; - - return $this; - } - - /** - * Gets message - * - * @return string - */ - public function getMessage() - { - return $this->container['message']; - } - - /** - * Sets message - * - * @param string $message A human readable message describing the error along with remediation steps where appropriate - * - * @return self - */ - public function setMessage($message) - { - if (is_null($message)) { - throw new \InvalidArgumentException('non-nullable message cannot be null'); - } - $this->container['message'] = $message; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($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 $offset Offset - * - * @return void - */ - public function offsetUnset($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/Cms/Performance/Model/ModelInterface.php b/codegen/Cms/Performance/Model/ModelInterface.php deleted file mode 100644 index cfd0c8207..000000000 --- a/codegen/Cms/Performance/Model/ModelInterface.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -class PerformanceView implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'PerformanceView'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - '_403' => 'int', - '_404' => 'int', - '_500' => 'int', - '_504' => 'int', - 'start_datetime' => 'string', - 'response_time_ms' => 'int', - '_95th' => 'int', - 'total_requests' => 'int', - 'cache_hit_rate' => 'float', - '_99th' => 'int', - 'total_request_time' => 'int', - '_100_x' => 'int', - '_50th' => 'int', - 'cache_hits' => 'int', - '_20_x' => 'int', - '_30_x' => 'int', - '_40_x' => 'int', - 'end_timestamp' => 'int', - '_50_x' => 'int', - 'start_timestamp' => 'int', - 'end_datetime' => 'string', - 'avg_origin_response_time' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - '_403' => 'int32', - '_404' => 'int32', - '_500' => 'int32', - '_504' => 'int32', - 'start_datetime' => null, - 'response_time_ms' => 'int32', - '_95th' => 'int32', - 'total_requests' => 'int32', - 'cache_hit_rate' => null, - '_99th' => 'int32', - 'total_request_time' => 'int32', - '_100_x' => 'int32', - '_50th' => 'int32', - 'cache_hits' => 'int32', - '_20_x' => 'int32', - '_30_x' => 'int32', - '_40_x' => 'int32', - 'end_timestamp' => 'int64', - '_50_x' => 'int32', - 'start_timestamp' => 'int64', - 'end_datetime' => null, - 'avg_origin_response_time' => 'int32' - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - '_403' => false, - '_404' => false, - '_500' => false, - '_504' => false, - 'start_datetime' => false, - 'response_time_ms' => false, - '_95th' => false, - 'total_requests' => false, - 'cache_hit_rate' => false, - '_99th' => false, - 'total_request_time' => false, - '_100_x' => false, - '_50th' => false, - 'cache_hits' => false, - '_20_x' => false, - '_30_x' => false, - '_40_x' => false, - 'end_timestamp' => false, - '_50_x' => false, - 'start_timestamp' => false, - 'end_datetime' => false, - 'avg_origin_response_time' => 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 = [ - '_403' => '403', - '_404' => '404', - '_500' => '500', - '_504' => '504', - 'start_datetime' => 'startDatetime', - 'response_time_ms' => 'responseTimeMs', - '_95th' => '95th', - 'total_requests' => 'totalRequests', - 'cache_hit_rate' => 'cacheHitRate', - '_99th' => '99th', - 'total_request_time' => 'totalRequestTime', - '_100_x' => '100X', - '_50th' => '50th', - 'cache_hits' => 'cacheHits', - '_20_x' => '20X', - '_30_x' => '30X', - '_40_x' => '40X', - 'end_timestamp' => 'endTimestamp', - '_50_x' => '50X', - 'start_timestamp' => 'startTimestamp', - 'end_datetime' => 'endDatetime', - 'avg_origin_response_time' => 'avgOriginResponseTime' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - '_403' => 'set403', - '_404' => 'set404', - '_500' => 'set500', - '_504' => 'set504', - 'start_datetime' => 'setStartDatetime', - 'response_time_ms' => 'setResponseTimeMs', - '_95th' => 'set95th', - 'total_requests' => 'setTotalRequests', - 'cache_hit_rate' => 'setCacheHitRate', - '_99th' => 'set99th', - 'total_request_time' => 'setTotalRequestTime', - '_100_x' => 'set100X', - '_50th' => 'set50th', - 'cache_hits' => 'setCacheHits', - '_20_x' => 'set20X', - '_30_x' => 'set30X', - '_40_x' => 'set40X', - 'end_timestamp' => 'setEndTimestamp', - '_50_x' => 'set50X', - 'start_timestamp' => 'setStartTimestamp', - 'end_datetime' => 'setEndDatetime', - 'avg_origin_response_time' => 'setAvgOriginResponseTime' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - '_403' => 'get403', - '_404' => 'get404', - '_500' => 'get500', - '_504' => 'get504', - 'start_datetime' => 'getStartDatetime', - 'response_time_ms' => 'getResponseTimeMs', - '_95th' => 'get95th', - 'total_requests' => 'getTotalRequests', - 'cache_hit_rate' => 'getCacheHitRate', - '_99th' => 'get99th', - 'total_request_time' => 'getTotalRequestTime', - '_100_x' => 'get100X', - '_50th' => 'get50th', - 'cache_hits' => 'getCacheHits', - '_20_x' => 'get20X', - '_30_x' => 'get30X', - '_40_x' => 'get40X', - 'end_timestamp' => 'getEndTimestamp', - '_50_x' => 'get50X', - 'start_timestamp' => 'getStartTimestamp', - 'end_datetime' => 'getEndDatetime', - 'avg_origin_response_time' => 'getAvgOriginResponseTime' - ]; - - /** - * 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('_403', $data ?? [], null); - $this->setIfExists('_404', $data ?? [], null); - $this->setIfExists('_500', $data ?? [], null); - $this->setIfExists('_504', $data ?? [], null); - $this->setIfExists('start_datetime', $data ?? [], null); - $this->setIfExists('response_time_ms', $data ?? [], null); - $this->setIfExists('_95th', $data ?? [], null); - $this->setIfExists('total_requests', $data ?? [], null); - $this->setIfExists('cache_hit_rate', $data ?? [], null); - $this->setIfExists('_99th', $data ?? [], null); - $this->setIfExists('total_request_time', $data ?? [], null); - $this->setIfExists('_100_x', $data ?? [], null); - $this->setIfExists('_50th', $data ?? [], null); - $this->setIfExists('cache_hits', $data ?? [], null); - $this->setIfExists('_20_x', $data ?? [], null); - $this->setIfExists('_30_x', $data ?? [], null); - $this->setIfExists('_40_x', $data ?? [], null); - $this->setIfExists('end_timestamp', $data ?? [], null); - $this->setIfExists('_50_x', $data ?? [], null); - $this->setIfExists('start_timestamp', $data ?? [], null); - $this->setIfExists('end_datetime', $data ?? [], null); - $this->setIfExists('avg_origin_response_time', $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['_403'] === null) { - $invalidProperties[] = "'_403' can't be null"; - } - if ($this->container['_404'] === null) { - $invalidProperties[] = "'_404' can't be null"; - } - if ($this->container['_500'] === null) { - $invalidProperties[] = "'_500' can't be null"; - } - if ($this->container['_504'] === null) { - $invalidProperties[] = "'_504' can't be null"; - } - if ($this->container['response_time_ms'] === null) { - $invalidProperties[] = "'response_time_ms' can't be null"; - } - if ($this->container['_95th'] === null) { - $invalidProperties[] = "'_95th' can't be null"; - } - if ($this->container['total_requests'] === null) { - $invalidProperties[] = "'total_requests' can't be null"; - } - if ($this->container['cache_hit_rate'] === null) { - $invalidProperties[] = "'cache_hit_rate' can't be null"; - } - if ($this->container['_99th'] === null) { - $invalidProperties[] = "'_99th' can't be null"; - } - if ($this->container['_100_x'] === null) { - $invalidProperties[] = "'_100_x' can't be null"; - } - if ($this->container['_50th'] === null) { - $invalidProperties[] = "'_50th' can't be null"; - } - if ($this->container['cache_hits'] === null) { - $invalidProperties[] = "'cache_hits' can't be null"; - } - if ($this->container['_20_x'] === null) { - $invalidProperties[] = "'_20_x' can't be null"; - } - if ($this->container['_30_x'] === null) { - $invalidProperties[] = "'_30_x' can't be null"; - } - if ($this->container['_40_x'] === null) { - $invalidProperties[] = "'_40_x' can't be null"; - } - if ($this->container['end_timestamp'] === null) { - $invalidProperties[] = "'end_timestamp' can't be null"; - } - if ($this->container['_50_x'] === null) { - $invalidProperties[] = "'_50_x' can't be null"; - } - if ($this->container['start_timestamp'] === null) { - $invalidProperties[] = "'start_timestamp' can't be null"; - } - if ($this->container['avg_origin_response_time'] === null) { - $invalidProperties[] = "'avg_origin_response_time' 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 _403 - * - * @return int - */ - public function get403() - { - return $this->container['_403']; - } - - /** - * Sets _403 - * - * @param int $_403 The number of responses that had an http status code of 403. - * - * @return self - */ - public function set403($_403) - { - if (is_null($_403)) { - throw new \InvalidArgumentException('non-nullable _403 cannot be null'); - } - $this->container['_403'] = $_403; - - return $this; - } - - /** - * Gets _404 - * - * @return int - */ - public function get404() - { - return $this->container['_404']; - } - - /** - * Sets _404 - * - * @param int $_404 The number of responses that had an http status code of 404. - * - * @return self - */ - public function set404($_404) - { - if (is_null($_404)) { - throw new \InvalidArgumentException('non-nullable _404 cannot be null'); - } - $this->container['_404'] = $_404; - - return $this; - } - - /** - * Gets _500 - * - * @return int - */ - public function get500() - { - return $this->container['_500']; - } - - /** - * Sets _500 - * - * @param int $_500 The number of responses that had an http status code of 500. - * - * @return self - */ - public function set500($_500) - { - if (is_null($_500)) { - throw new \InvalidArgumentException('non-nullable _500 cannot be null'); - } - $this->container['_500'] = $_500; - - return $this; - } - - /** - * Gets _504 - * - * @return int - */ - public function get504() - { - return $this->container['_504']; - } - - /** - * Sets _504 - * - * @param int $_504 The number of responses that had an http status code of 504. - * - * @return self - */ - public function set504($_504) - { - if (is_null($_504)) { - throw new \InvalidArgumentException('non-nullable _504 cannot be null'); - } - $this->container['_504'] = $_504; - - return $this; - } - - /** - * Gets start_datetime - * - * @return string|null - */ - public function getStartDatetime() - { - return $this->container['start_datetime']; - } - - /** - * Sets start_datetime - * - * @param string|null $start_datetime start_datetime - * - * @return self - */ - public function setStartDatetime($start_datetime) - { - if (is_null($start_datetime)) { - throw new \InvalidArgumentException('non-nullable start_datetime cannot be null'); - } - $this->container['start_datetime'] = $start_datetime; - - return $this; - } - - /** - * Gets response_time_ms - * - * @return int - */ - public function getResponseTimeMs() - { - return $this->container['response_time_ms']; - } - - /** - * Sets response_time_ms - * - * @param int $response_time_ms The average response time in milliseconds. - * - * @return self - */ - public function setResponseTimeMs($response_time_ms) - { - if (is_null($response_time_ms)) { - throw new \InvalidArgumentException('non-nullable response_time_ms cannot be null'); - } - $this->container['response_time_ms'] = $response_time_ms; - - return $this; - } - - /** - * Gets _95th - * - * @return int - */ - public function get95th() - { - return $this->container['_95th']; - } - - /** - * Sets _95th - * - * @param int $_95th The 95th percentile response time. - * - * @return self - */ - public function set95th($_95th) - { - if (is_null($_95th)) { - throw new \InvalidArgumentException('non-nullable _95th cannot be null'); - } - $this->container['_95th'] = $_95th; - - return $this; - } - - /** - * Gets total_requests - * - * @return int - */ - public function getTotalRequests() - { - return $this->container['total_requests']; - } - - /** - * Sets total_requests - * - * @param int $total_requests The total number of requests received in this period. - * - * @return self - */ - public function setTotalRequests($total_requests) - { - if (is_null($total_requests)) { - throw new \InvalidArgumentException('non-nullable total_requests cannot be null'); - } - $this->container['total_requests'] = $total_requests; - - return $this; - } - - /** - * Gets cache_hit_rate - * - * @return float - */ - public function getCacheHitRate() - { - return $this->container['cache_hit_rate']; - } - - /** - * Sets cache_hit_rate - * - * @param float $cache_hit_rate The percentage of requests that were served cached responses. - * - * @return self - */ - public function setCacheHitRate($cache_hit_rate) - { - if (is_null($cache_hit_rate)) { - throw new \InvalidArgumentException('non-nullable cache_hit_rate cannot be null'); - } - $this->container['cache_hit_rate'] = $cache_hit_rate; - - return $this; - } - - /** - * Gets _99th - * - * @return int - */ - public function get99th() - { - return $this->container['_99th']; - } - - /** - * Sets _99th - * - * @param int $_99th The 99th percentile response time. - * - * @return self - */ - public function set99th($_99th) - { - if (is_null($_99th)) { - throw new \InvalidArgumentException('non-nullable _99th cannot be null'); - } - $this->container['_99th'] = $_99th; - - return $this; - } - - /** - * Gets total_request_time - * - * @return int|null - */ - public function getTotalRequestTime() - { - return $this->container['total_request_time']; - } - - /** - * Sets total_request_time - * - * @param int|null $total_request_time total_request_time - * - * @return self - */ - public function setTotalRequestTime($total_request_time) - { - if (is_null($total_request_time)) { - throw new \InvalidArgumentException('non-nullable total_request_time cannot be null'); - } - $this->container['total_request_time'] = $total_request_time; - - return $this; - } - - /** - * Gets _100_x - * - * @return int - */ - public function get100X() - { - return $this->container['_100_x']; - } - - /** - * Sets _100_x - * - * @param int $_100_x The number of responses that had an http status code between 1000-1999. - * - * @return self - */ - public function set100X($_100_x) - { - if (is_null($_100_x)) { - throw new \InvalidArgumentException('non-nullable _100_x cannot be null'); - } - $this->container['_100_x'] = $_100_x; - - return $this; - } - - /** - * Gets _50th - * - * @return int - */ - public function get50th() - { - return $this->container['_50th']; - } - - /** - * Sets _50th - * - * @param int $_50th The 50th percentile response time. - * - * @return self - */ - public function set50th($_50th) - { - if (is_null($_50th)) { - throw new \InvalidArgumentException('non-nullable _50th cannot be null'); - } - $this->container['_50th'] = $_50th; - - return $this; - } - - /** - * Gets cache_hits - * - * @return int - */ - public function getCacheHits() - { - return $this->container['cache_hits']; - } - - /** - * Sets cache_hits - * - * @param int $cache_hits The total number of requests that were served cached responses. - * - * @return self - */ - public function setCacheHits($cache_hits) - { - if (is_null($cache_hits)) { - throw new \InvalidArgumentException('non-nullable cache_hits cannot be null'); - } - $this->container['cache_hits'] = $cache_hits; - - return $this; - } - - /** - * Gets _20_x - * - * @return int - */ - public function get20X() - { - return $this->container['_20_x']; - } - - /** - * Sets _20_x - * - * @param int $_20_x The number of responses that had an http status code between 200-299. - * - * @return self - */ - public function set20X($_20_x) - { - if (is_null($_20_x)) { - throw new \InvalidArgumentException('non-nullable _20_x cannot be null'); - } - $this->container['_20_x'] = $_20_x; - - return $this; - } - - /** - * Gets _30_x - * - * @return int - */ - public function get30X() - { - return $this->container['_30_x']; - } - - /** - * Sets _30_x - * - * @param int $_30_x The number of responses that had an http status code between 300-399. - * - * @return self - */ - public function set30X($_30_x) - { - if (is_null($_30_x)) { - throw new \InvalidArgumentException('non-nullable _30_x cannot be null'); - } - $this->container['_30_x'] = $_30_x; - - return $this; - } - - /** - * Gets _40_x - * - * @return int - */ - public function get40X() - { - return $this->container['_40_x']; - } - - /** - * Sets _40_x - * - * @param int $_40_x The number of responses that had an http status code between 400-499. - * - * @return self - */ - public function set40X($_40_x) - { - if (is_null($_40_x)) { - throw new \InvalidArgumentException('non-nullable _40_x cannot be null'); - } - $this->container['_40_x'] = $_40_x; - - return $this; - } - - /** - * Gets end_timestamp - * - * @return int - */ - public function getEndTimestamp() - { - return $this->container['end_timestamp']; - } - - /** - * Sets end_timestamp - * - * @param int $end_timestamp The timestamp in milliseconds of the end of this interval. - * - * @return self - */ - public function setEndTimestamp($end_timestamp) - { - if (is_null($end_timestamp)) { - throw new \InvalidArgumentException('non-nullable end_timestamp cannot be null'); - } - $this->container['end_timestamp'] = $end_timestamp; - - return $this; - } - - /** - * Gets _50_x - * - * @return int - */ - public function get50X() - { - return $this->container['_50_x']; - } - - /** - * Sets _50_x - * - * @param int $_50_x The number of responses that had an http status code between 500-599. - * - * @return self - */ - public function set50X($_50_x) - { - if (is_null($_50_x)) { - throw new \InvalidArgumentException('non-nullable _50_x cannot be null'); - } - $this->container['_50_x'] = $_50_x; - - return $this; - } - - /** - * Gets start_timestamp - * - * @return int - */ - public function getStartTimestamp() - { - return $this->container['start_timestamp']; - } - - /** - * Sets start_timestamp - * - * @param int $start_timestamp The timestamp in milliseconds of the start of this interval. - * - * @return self - */ - public function setStartTimestamp($start_timestamp) - { - if (is_null($start_timestamp)) { - throw new \InvalidArgumentException('non-nullable start_timestamp cannot be null'); - } - $this->container['start_timestamp'] = $start_timestamp; - - return $this; - } - - /** - * Gets end_datetime - * - * @return string|null - */ - public function getEndDatetime() - { - return $this->container['end_datetime']; - } - - /** - * Sets end_datetime - * - * @param string|null $end_datetime end_datetime - * - * @return self - */ - public function setEndDatetime($end_datetime) - { - if (is_null($end_datetime)) { - throw new \InvalidArgumentException('non-nullable end_datetime cannot be null'); - } - $this->container['end_datetime'] = $end_datetime; - - return $this; - } - - /** - * Gets avg_origin_response_time - * - * @return int - */ - public function getAvgOriginResponseTime() - { - return $this->container['avg_origin_response_time']; - } - - /** - * Sets avg_origin_response_time - * - * @param int $avg_origin_response_time The average response time in milliseconds from the origin to the edge. - * - * @return self - */ - public function setAvgOriginResponseTime($avg_origin_response_time) - { - if (is_null($avg_origin_response_time)) { - throw new \InvalidArgumentException('non-nullable avg_origin_response_time cannot be null'); - } - $this->container['avg_origin_response_time'] = $avg_origin_response_time; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($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 $offset Offset - * - * @return void - */ - public function offsetUnset($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/Cms/Performance/Model/PublicPerformanceResponse.php b/codegen/Cms/Performance/Model/PublicPerformanceResponse.php deleted file mode 100644 index 12ba6031a..000000000 --- a/codegen/Cms/Performance/Model/PublicPerformanceResponse.php +++ /dev/null @@ -1,725 +0,0 @@ - - */ -class PublicPerformanceResponse implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'PublicPerformanceResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'path' => 'string', - 'period' => 'string', - 'start_interval' => 'int', - 'data' => '\HubSpot\Client\Cms\Performance\Model\PerformanceView[]', - 'domain' => 'string', - 'interval' => 'string', - 'end_interval' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'path' => null, - 'period' => null, - 'start_interval' => 'int64', - 'data' => null, - 'domain' => null, - 'interval' => null, - 'end_interval' => 'int64' - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'path' => false, - 'period' => false, - 'start_interval' => false, - 'data' => false, - 'domain' => false, - 'interval' => false, - 'end_interval' => 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 = [ - 'path' => 'path', - 'period' => 'period', - 'start_interval' => 'startInterval', - 'data' => 'data', - 'domain' => 'domain', - 'interval' => 'interval', - 'end_interval' => 'endInterval' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'path' => 'setPath', - 'period' => 'setPeriod', - 'start_interval' => 'setStartInterval', - 'data' => 'setData', - 'domain' => 'setDomain', - 'interval' => 'setInterval', - 'end_interval' => 'setEndInterval' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'path' => 'getPath', - 'period' => 'getPeriod', - 'start_interval' => 'getStartInterval', - 'data' => 'getData', - 'domain' => 'getDomain', - 'interval' => 'getInterval', - 'end_interval' => 'getEndInterval' - ]; - - /** - * 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; - } - - public const PERIOD_ONE_MINUTE = 'ONE_MINUTE'; - public const PERIOD_FIVE_MINUTES = 'FIVE_MINUTES'; - public const PERIOD_TEN_MINUTES = 'TEN_MINUTES'; - public const PERIOD_FIFTEEN_MINUTES = 'FIFTEEN_MINUTES'; - public const PERIOD_THIRTY_MINUTES = 'THIRTY_MINUTES'; - public const PERIOD_ONE_HOUR = 'ONE_HOUR'; - public const PERIOD_FOUR_HOURS = 'FOUR_HOURS'; - public const PERIOD_TWELVE_HOURS = 'TWELVE_HOURS'; - public const PERIOD_ONE_DAY = 'ONE_DAY'; - public const PERIOD_ONE_WEEK = 'ONE_WEEK'; - public const INTERVAL_ONE_MINUTE = 'ONE_MINUTE'; - public const INTERVAL_FIVE_MINUTES = 'FIVE_MINUTES'; - public const INTERVAL_TEN_MINUTES = 'TEN_MINUTES'; - public const INTERVAL_FIFTEEN_MINUTES = 'FIFTEEN_MINUTES'; - public const INTERVAL_THIRTY_MINUTES = 'THIRTY_MINUTES'; - public const INTERVAL_ONE_HOUR = 'ONE_HOUR'; - public const INTERVAL_FOUR_HOURS = 'FOUR_HOURS'; - public const INTERVAL_TWELVE_HOURS = 'TWELVE_HOURS'; - public const INTERVAL_ONE_DAY = 'ONE_DAY'; - public const INTERVAL_ONE_WEEK = 'ONE_WEEK'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getPeriodAllowableValues() - { - return [ - self::PERIOD_ONE_MINUTE, - self::PERIOD_FIVE_MINUTES, - self::PERIOD_TEN_MINUTES, - self::PERIOD_FIFTEEN_MINUTES, - self::PERIOD_THIRTY_MINUTES, - self::PERIOD_ONE_HOUR, - self::PERIOD_FOUR_HOURS, - self::PERIOD_TWELVE_HOURS, - self::PERIOD_ONE_DAY, - self::PERIOD_ONE_WEEK, - ]; - } - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getIntervalAllowableValues() - { - return [ - self::INTERVAL_ONE_MINUTE, - self::INTERVAL_FIVE_MINUTES, - self::INTERVAL_TEN_MINUTES, - self::INTERVAL_FIFTEEN_MINUTES, - self::INTERVAL_THIRTY_MINUTES, - self::INTERVAL_ONE_HOUR, - self::INTERVAL_FOUR_HOURS, - self::INTERVAL_TWELVE_HOURS, - self::INTERVAL_ONE_DAY, - self::INTERVAL_ONE_WEEK, - ]; - } - - /** - * 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('path', $data ?? [], null); - $this->setIfExists('period', $data ?? [], null); - $this->setIfExists('start_interval', $data ?? [], null); - $this->setIfExists('data', $data ?? [], null); - $this->setIfExists('domain', $data ?? [], null); - $this->setIfExists('interval', $data ?? [], null); - $this->setIfExists('end_interval', $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 = []; - - $allowedValues = $this->getPeriodAllowableValues(); - if (!is_null($this->container['period']) && !in_array($this->container['period'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'period', must be one of '%s'", - $this->container['period'], - implode("', '", $allowedValues) - ); - } - - if ($this->container['start_interval'] === null) { - $invalidProperties[] = "'start_interval' can't be null"; - } - if ($this->container['data'] === null) { - $invalidProperties[] = "'data' can't be null"; - } - if ($this->container['interval'] === null) { - $invalidProperties[] = "'interval' can't be null"; - } - $allowedValues = $this->getIntervalAllowableValues(); - if (!is_null($this->container['interval']) && !in_array($this->container['interval'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'interval', must be one of '%s'", - $this->container['interval'], - implode("', '", $allowedValues) - ); - } - - if ($this->container['end_interval'] === null) { - $invalidProperties[] = "'end_interval' 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 path - * - * @return string|null - */ - public function getPath() - { - return $this->container['path']; - } - - /** - * Sets path - * - * @param string|null $path path - * - * @return self - */ - public function setPath($path) - { - if (is_null($path)) { - throw new \InvalidArgumentException('non-nullable path cannot be null'); - } - $this->container['path'] = $path; - - return $this; - } - - /** - * Gets period - * - * @return string|null - */ - public function getPeriod() - { - return $this->container['period']; - } - - /** - * Sets period - * - * @param string|null $period period - * - * @return self - */ - public function setPeriod($period) - { - if (is_null($period)) { - throw new \InvalidArgumentException('non-nullable period cannot be null'); - } - $allowedValues = $this->getPeriodAllowableValues(); - if (!in_array($period, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'period', must be one of '%s'", - $period, - implode("', '", $allowedValues) - ) - ); - } - $this->container['period'] = $period; - - return $this; - } - - /** - * Gets start_interval - * - * @return int - */ - public function getStartInterval() - { - return $this->container['start_interval']; - } - - /** - * Sets start_interval - * - * @param int $start_interval start_interval - * - * @return self - */ - public function setStartInterval($start_interval) - { - if (is_null($start_interval)) { - throw new \InvalidArgumentException('non-nullable start_interval cannot be null'); - } - $this->container['start_interval'] = $start_interval; - - return $this; - } - - /** - * Gets data - * - * @return \HubSpot\Client\Cms\Performance\Model\PerformanceView[] - */ - public function getData() - { - return $this->container['data']; - } - - /** - * Sets data - * - * @param \HubSpot\Client\Cms\Performance\Model\PerformanceView[] $data data - * - * @return self - */ - public function setData($data) - { - if (is_null($data)) { - throw new \InvalidArgumentException('non-nullable data cannot be null'); - } - $this->container['data'] = $data; - - return $this; - } - - /** - * Gets domain - * - * @return string|null - */ - public function getDomain() - { - return $this->container['domain']; - } - - /** - * Sets domain - * - * @param string|null $domain domain - * - * @return self - */ - public function setDomain($domain) - { - if (is_null($domain)) { - throw new \InvalidArgumentException('non-nullable domain cannot be null'); - } - $this->container['domain'] = $domain; - - return $this; - } - - /** - * Gets interval - * - * @return string - */ - public function getInterval() - { - return $this->container['interval']; - } - - /** - * Sets interval - * - * @param string $interval interval - * - * @return self - */ - public function setInterval($interval) - { - if (is_null($interval)) { - throw new \InvalidArgumentException('non-nullable interval cannot be null'); - } - $allowedValues = $this->getIntervalAllowableValues(); - if (!in_array($interval, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'interval', must be one of '%s'", - $interval, - implode("', '", $allowedValues) - ) - ); - } - $this->container['interval'] = $interval; - - return $this; - } - - /** - * Gets end_interval - * - * @return int - */ - public function getEndInterval() - { - return $this->container['end_interval']; - } - - /** - * Sets end_interval - * - * @param int $end_interval end_interval - * - * @return self - */ - public function setEndInterval($end_interval) - { - if (is_null($end_interval)) { - throw new \InvalidArgumentException('non-nullable end_interval cannot be null'); - } - $this->container['end_interval'] = $end_interval; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($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 $offset Offset - * - * @return void - */ - public function offsetUnset($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/Cms/Performance/ObjectSerializer.php b/codegen/Cms/Performance/ObjectSerializer.php deleted file mode 100644 index 8790009fb..000000000 --- a/codegen/Cms/Performance/ObjectSerializer.php +++ /dev/null @@ -1,617 +0,0 @@ -format('Y-m-d') : $data->format(self::$dateTimeFormat); - } - - if (is_array($data)) { - foreach ($data as $property => $value) { - $data[$property] = self::sanitizeForSerialization($value); - } - return $data; - } - - if (is_object($data)) { - $values = []; - if ($data instanceof ModelInterface) { - $formats = $data::openAPIFormats(); - foreach ($data::openAPITypes() as $property => $openAPIType) { - $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - $callable = [$openAPIType, 'getAllowableEnumValues']; - if (is_callable($callable)) { - /** array $callable */ - $allowedEnumTypes = $callable(); - if (!in_array($value, $allowedEnumTypes, true)) { - $imploded = implode("', '", $allowedEnumTypes); - throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); - } - } - } - if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); - } - } - } else { - foreach($data as $property => $value) { - $values[$property] = self::sanitizeForSerialization($value); - } - } - return (object)$values; - } else { - return (string)$data; - } - } - - /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param string $filename filename to be sanitized - * - * @return string the sanitized filename - */ - public static function sanitizeFilename($filename) - { - if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { - return $match[1]; - } else { - return $filename; - } - } - - /** - * Shorter timestamp microseconds to 6 digits length. - * - * @param string $timestamp Original timestamp - * - * @return string the shorten timestamp - */ - public static function sanitizeTimestamp($timestamp) - { - if (!is_string($timestamp)) return $timestamp; - - return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp); - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the path, by url-encoding. - * - * @param string $value a string which will be part of the path - * - * @return string the serialized object - */ - public static function toPathValue($value) - { - return rawurlencode(self::toString($value)); - } - - /** - * Checks if a value is empty, based on its OpenAPI type. - * - * @param mixed $value - * @param string $openApiType - * - * @return bool true if $value is empty - */ - private static function isEmptyValue($value, string $openApiType): bool - { - # If empty() returns false, it is not empty regardless of its type. - if (!empty($value)) { - return false; - } - - # Null is always empty, as we cannot send a real "null" value in a query parameter. - if ($value === null) { - return true; - } - - switch ($openApiType) { - # For numeric values, false and '' are considered empty. - # This comparison is safe for floating point values, since the previous call to empty() will - # filter out values that don't match 0. - case 'int': - case 'integer': - return $value !== 0; - - case 'number': - case 'float': - return $value !== 0 && $value !== 0.0; - - # For boolean values, '' is considered empty - case 'bool': - case 'boolean': - return !in_array($value, [false, 0], true); - - # For string values, '' is considered empty. - case 'string': - return $value === ''; - - # For all the other types, any value at this point can be considered empty. - default: - return true; - } - } - - /** - * Take query parameter properties and turn it into an array suitable for - * native http_build_query or GuzzleHttp\Psr7\Query::build. - * - * @param mixed $value Parameter value - * @param string $paramName Parameter name - * @param string $openApiType OpenAPIType eg. array or object - * @param string $style Parameter serialization style - * @param bool $explode Parameter explode option - * @param bool $required Whether query param is required or not - * - * @return array - */ - public static function toQueryValue( - $value, - string $paramName, - string $openApiType = 'string', - string $style = 'form', - bool $explode = true, - bool $required = true - ): array { - - # Check if we should omit this parameter from the query. This should only happen when: - # - Parameter is NOT required; AND - # - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For - # example, 0 as "int" or "boolean" is NOT an empty value. - if (self::isEmptyValue($value, $openApiType)) { - if ($required) { - return ["{$paramName}" => '']; - } else { - return []; - } - } - - # Handle DateTime objects in query - if($openApiType === "\\DateTime" && $value instanceof \DateTime) { - return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; - } - - $query = []; - $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; - - // since \GuzzleHttp\Psr7\Query::build fails with nested arrays - // need to flatten array first - $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { - if (!is_array($arr)) return $arr; - - foreach ($arr as $k => $v) { - $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; - - if (is_array($v)) { - $flattenArray($v, $prop, $result); - } else { - if ($style !== 'deepObject' && !$explode) { - // push key itself - $result[] = $prop; - } - $result[$prop] = $v; - } - } - return $result; - }; - - $value = $flattenArray($value, $paramName); - - // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values - if ($openApiType === 'array' && $style === 'deepObject' && $explode) { - return $value; - } - - if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { - return $value; - } - - if ('boolean' === $openApiType && is_bool($value)) { - $value = self::convertBoolToQueryStringFormat($value); - } - - // handle style in serializeCollection - $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); - - return $query; - } - - /** - * Convert boolean value to format for query string. - * - * @param bool $value Boolean value - * - * @return int|string Boolean value in format - */ - public static function convertBoolToQueryStringFormat(bool $value) - { - if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { - return $value ? 'true' : 'false'; - } - - return (int) $value; - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the header. If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string $value a string which will be part of the header - * - * @return string the header string - */ - public static function toHeaderValue($value) - { - $callable = [$value, 'toHeaderValue']; - if (is_callable($callable)) { - return $callable(); - } - - 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 - * If it's a datetime object, format it in ISO8601 - * If it's a boolean, convert it to "true" or "false". - * - * @param float|int|bool|\DateTime $value the value of the parameter - * - * @return string the header string - */ - public static function toString($value) - { - if ($value instanceof \DateTime) { // datetime in ISO8601 format - return $value->format(self::$dateTimeFormat); - } elseif (is_bool($value)) { - return $value ? 'true' : 'false'; - } else { - return (string) $value; - } - } - - /** - * Serialize an array to a string. - * - * @param array $collection collection to serialize to a string - * @param string $style the format use for serialization (csv, - * ssv, tsv, pipes, multi) - * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array - * - * @return string - */ - public static function serializeCollection(array $collection, $style, $allowCollectionFormatMulti = false) - { - if ($allowCollectionFormatMulti && ('multi' === $style)) { - // http_build_query() almost does the job for us. We just - // need to fix the result of multidimensional arrays. - return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); - } - switch ($style) { - case 'pipeDelimited': - case 'pipes': - return implode('|', $collection); - - case 'tsv': - return implode("\t", $collection); - - case 'spaceDelimited': - case 'ssv': - return implode(' ', $collection); - - case 'simple': - case 'csv': - // Deliberate fall through. CSV is default format. - default: - return implode(',', $collection); - } - } - - /** - * Deserialize a JSON string into an object - * - * @param mixed $data object or primitive to be deserialized - * @param string $class class name is passed as a string - * @param string[]|null $httpHeaders HTTP headers - * - * @return object|array|null a single or an array of $class instances - */ - public static function deserialize($data, $class, $httpHeaders = null) - { - if (null === $data) { - return null; - } - - if (strcasecmp(substr($class, -2), '[]') === 0) { - $data = is_string($data) ? json_decode($data) : $data; - - if (!is_array($data)) { - throw new \InvalidArgumentException("Invalid array '$class'"); - } - - $subClass = substr($class, 0, -2); - $values = []; - foreach ($data as $key => $value) { - $values[] = self::deserialize($value, $subClass, null); - } - return $values; - } - - if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array - $data = is_string($data) ? json_decode($data) : $data; - settype($data, 'array'); - $inner = substr($class, 4, -1); - $deserialized = []; - if (strrpos($inner, ",") !== false) { - $subClass_array = explode(',', $inner, 2); - $subClass = $subClass_array[1]; - foreach ($data as $key => $value) { - $deserialized[$key] = self::deserialize($value, $subClass, null); - } - } - return $deserialized; - } - - if ($class === 'object') { - settype($data, 'array'); - return $data; - } elseif ($class === 'mixed') { - settype($data, gettype($data)); - return $data; - } - - if ($class === '\DateTime') { - // Some APIs return an invalid, empty string as a - // date-time property. DateTime::__construct() will return - // the current time for empty input which is probably not - // what is meant. The invalid empty string is probably to - // be interpreted as a missing field/value. Let's handle - // this graceful. - if (!empty($data)) { - try { - return new \DateTime($data); - } catch (\Exception $exception) { - // Some APIs return a date-time with too high nanosecond - // precision for php's DateTime to handle. - // With provided regexp 6 digits of microseconds saved - return new \DateTime(self::sanitizeTimestamp($data)); - } - } else { - return null; - } - } - - if ($class === '\SplFileObject') { - $data = Utils::streamFor($data); - - /** @var \Psr\Http\Message\StreamInterface $data */ - - // determine file name - if ( - is_array($httpHeaders) - && array_key_exists('Content-Disposition', $httpHeaders) - && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) - ) { - $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); - } else { - $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); - } - - $file = fopen($filename, 'w'); - while ($chunk = $data->read(200)) { - fwrite($file, $chunk); - } - fclose($file); - - return new \SplFileObject($filename, 'r'); - } - - /** @psalm-suppress ParadoxicalCondition */ - if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - settype($data, $class); - return $data; - } - - - if (method_exists($class, 'getAllowableEnumValues')) { - if (!in_array($data, $class::getAllowableEnumValues(), true)) { - $imploded = implode("', '", $class::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); - } - return $data; - } else { - $data = is_string($data) ? json_decode($data) : $data; - - if (is_array($data)) { - $data = (object)$data; - } - - // If a discriminator is defined and points to a valid subclass, use it. - $discriminator = $class::DISCRIMINATOR; - if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { - $subclass = '\HubSpot\Client\Cms\Performance\Model\\' . $data->{$discriminator}; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - } - } - - /** @var ModelInterface $instance */ - $instance = new $class(); - foreach ($instance::openAPITypes() as $property => $type) { - $propertySetter = $instance::setters()[$property]; - - if (!isset($propertySetter)) { - continue; - } - - if (!isset($data->{$instance::attributeMap()[$property]})) { - if ($instance::isNullable($property)) { - $instance->$propertySetter(null); - } - - continue; - } - - if (isset($data->{$instance::attributeMap()[$property]})) { - $propertyValue = $data->{$instance::attributeMap()[$property]}; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); - } - } - return $instance; - } - } - - /** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of `parse()` to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like `http_build_query()` would). - * - * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 - * with a modification which is described in https://github.com/guzzle/psr7/pull/603 - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - */ - public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): string - { - if (!$params) { - return ''; - } - - if ($encoding === false) { - $encoder = function (string $str): string { - return $str; - }; - } elseif ($encoding === PHP_QUERY_RFC3986) { - $encoder = 'rawurlencode'; - } elseif ($encoding === PHP_QUERY_RFC1738) { - $encoder = 'urlencode'; - } else { - throw new \InvalidArgumentException('Invalid type'); - } - - $castBool = Configuration::BOOLEAN_FORMAT_INT == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString() - ? function ($v) { return (int) $v; } - : function ($v) { return $v ? 'true' : 'false'; }; - - $qs = ''; - foreach ($params as $k => $v) { - $k = $encoder((string) $k); - if (!is_array($v)) { - $qs .= $k; - $v = is_bool($v) ? $castBool($v) : $v; - if ($v !== null) { - $qs .= '='.$encoder((string) $v); - } - $qs .= '&'; - } else { - foreach ($v as $vv) { - $qs .= $k; - $vv = is_bool($vv) ? $castBool($vv) : $vv; - if ($vv !== null) { - $qs .= '='.$encoder((string) $vv); - } - $qs .= '&'; - } - } - } - - return $qs ? (string) substr($qs, 0, -1) : ''; - } -} diff --git a/lib/Discovery/Cms/Discovery.php b/lib/Discovery/Cms/Discovery.php index e1bf52ccb..8f5e6301d 100644 --- a/lib/Discovery/Cms/Discovery.php +++ b/lib/Discovery/Cms/Discovery.php @@ -10,7 +10,6 @@ * @method Domains\Discovery domains() * @method Hubdb\Discovery hubdb() * @method Pages\Discovery pages() - * @method Performance\Discovery performance() * @method SiteSearch\Discovery siteSearch() * @method SourceCode\Discovery sourceCode() * @method UrlRedirects\Discovery urlRedirects() diff --git a/lib/Discovery/Cms/Performance/Discovery.php b/lib/Discovery/Cms/Performance/Discovery.php deleted file mode 100644 index 8a0a09d57..000000000 --- a/lib/Discovery/Cms/Performance/Discovery.php +++ /dev/null @@ -1,11 +0,0 @@ -domains()->shouldHaveType(\HubSpot\Discovery\Cms\Domains\Discovery::class); $this->hubdb()->shouldHaveType(\HubSpot\Discovery\Cms\Hubdb\Discovery::class); $this->pages()->shouldHaveType(\HubSpot\Discovery\Cms\Pages\Discovery::class); - $this->performance()->shouldHaveType(\HubSpot\Discovery\Cms\Performance\Discovery::class); $this->siteSearch()->shouldHaveType(\HubSpot\Discovery\Cms\SiteSearch\Discovery::class); $this->sourceCode()->shouldHaveType(\HubSpot\Discovery\Cms\SourceCode\Discovery::class); $this->urlRedirects()->shouldHaveType(\HubSpot\Discovery\Cms\UrlRedirects\Discovery::class); diff --git a/tests/spec/Discovery/Cms/Performance/DiscoverySpec.php b/tests/spec/Discovery/Cms/Performance/DiscoverySpec.php deleted file mode 100644 index a5ea2be8a..000000000 --- a/tests/spec/Discovery/Cms/Performance/DiscoverySpec.php +++ /dev/null @@ -1,27 +0,0 @@ -beConstructedWith($client, $config); - } - - public function it_is_initializable() - { - $this->shouldHaveType(Discovery::class); - } - - public function it_creates_clients() - { - $this->publicPerformanceApi()->shouldHaveType(PublicPerformanceApi::class); - } -}