diff --git a/codegen/Crm/Extensions/Calling/Api/ChannelConnectionSettingsApi.php b/codegen/Crm/Extensions/Calling/Api/ChannelConnectionSettingsApi.php new file mode 100644 index 000000000..1882abef0 --- /dev/null +++ b/codegen/Crm/Extensions/Calling/Api/ChannelConnectionSettingsApi.php @@ -0,0 +1,1464 @@ + [ + 'application/json', + ], + 'create' => [ + 'application/json', + ], + 'getById' => [ + 'application/json', + ], + 'update' => [ + '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 archive + * + * Delete channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function archive($app_id, string $contentType = self::contentTypes['archive'][0]) + { + $this->archiveWithHttpInfo($app_id, $contentType); + } + + /** + * Operation archiveWithHttpInfo + * + * Delete channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function archiveWithHttpInfo($app_id, string $contentType = self::contentTypes['archive'][0]) + { + $request = $this->archiveRequest($app_id, $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(); + + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Extensions\Calling\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation archiveAsync + * + * Delete channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function archiveAsync($app_id, string $contentType = self::contentTypes['archive'][0]) + { + return $this->archiveAsyncWithHttpInfo($app_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation archiveAsyncWithHttpInfo + * + * Delete channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function archiveAsyncWithHttpInfo($app_id, string $contentType = self::contentTypes['archive'][0]) + { + $returnType = ''; + $request = $this->archiveRequest($app_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'archive' + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function archiveRequest($app_id, string $contentType = self::contentTypes['archive'][0]) + { + + // verify the required parameter 'app_id' is set + if ($app_id === null || (is_array($app_id) && count($app_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $app_id when calling archive' + ); + } + + + $resourcePath = '/crm/v3/extensions/calling/{appId}/settings/channel-connection'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($app_id !== null) { + $resourcePath = str_replace( + '{' . 'appId' . '}', + ObjectSerializer::toPathValue($app_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $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 API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + + $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( + 'DELETE', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation create + * + * Configure channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsRequest $channel_connection_settings_request channel_connection_settings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error + */ + public function create($app_id, $channel_connection_settings_request, string $contentType = self::contentTypes['create'][0]) + { + list($response) = $this->createWithHttpInfo($app_id, $channel_connection_settings_request, $contentType); + return $response; + } + + /** + * Operation createWithHttpInfo + * + * Configure channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsRequest $channel_connection_settings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function createWithHttpInfo($app_id, $channel_connection_settings_request, string $contentType = self::contentTypes['create'][0]) + { + $request = $this->createRequest($app_id, $channel_connection_settings_request, $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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' !== '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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\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\Crm\Extensions\Calling\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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + 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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Extensions\Calling\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createAsync + * + * Configure channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsRequest $channel_connection_settings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createAsync($app_id, $channel_connection_settings_request, string $contentType = self::contentTypes['create'][0]) + { + return $this->createAsyncWithHttpInfo($app_id, $channel_connection_settings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createAsyncWithHttpInfo + * + * Configure channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsRequest $channel_connection_settings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createAsyncWithHttpInfo($app_id, $channel_connection_settings_request, string $contentType = self::contentTypes['create'][0]) + { + $returnType = '\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + $request = $this->createRequest($app_id, $channel_connection_settings_request, $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 'create' + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsRequest $channel_connection_settings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createRequest($app_id, $channel_connection_settings_request, string $contentType = self::contentTypes['create'][0]) + { + + // verify the required parameter 'app_id' is set + if ($app_id === null || (is_array($app_id) && count($app_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $app_id when calling create' + ); + } + + // verify the required parameter 'channel_connection_settings_request' is set + if ($channel_connection_settings_request === null || (is_array($channel_connection_settings_request) && count($channel_connection_settings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $channel_connection_settings_request when calling create' + ); + } + + + $resourcePath = '/crm/v3/extensions/calling/{appId}/settings/channel-connection'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($app_id !== null) { + $resourcePath = str_replace( + '{' . 'appId' . '}', + ObjectSerializer::toPathValue($app_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($channel_connection_settings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($channel_connection_settings_request)); + } else { + $httpBody = $channel_connection_settings_request; + } + } elseif (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 API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + + $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( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getById + * + * Retrieve channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error + */ + public function getById($app_id, string $contentType = self::contentTypes['getById'][0]) + { + list($response) = $this->getByIdWithHttpInfo($app_id, $contentType); + return $response; + } + + /** + * Operation getByIdWithHttpInfo + * + * Retrieve channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function getByIdWithHttpInfo($app_id, string $contentType = self::contentTypes['getById'][0]) + { + $request = $this->getByIdRequest($app_id, $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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' !== '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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\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\Crm\Extensions\Calling\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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + 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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Extensions\Calling\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getByIdAsync + * + * Retrieve channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getByIdAsync($app_id, string $contentType = self::contentTypes['getById'][0]) + { + return $this->getByIdAsyncWithHttpInfo($app_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getByIdAsyncWithHttpInfo + * + * Retrieve channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getByIdAsyncWithHttpInfo($app_id, string $contentType = self::contentTypes['getById'][0]) + { + $returnType = '\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + $request = $this->getByIdRequest($app_id, $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 'getById' + * + * @param int $app_id The ID of the app. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getByIdRequest($app_id, string $contentType = self::contentTypes['getById'][0]) + { + + // verify the required parameter 'app_id' is set + if ($app_id === null || (is_array($app_id) && count($app_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $app_id when calling getById' + ); + } + + + $resourcePath = '/crm/v3/extensions/calling/{appId}/settings/channel-connection'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($app_id !== null) { + $resourcePath = str_replace( + '{' . 'appId' . '}', + ObjectSerializer::toPathValue($app_id), + $resourcePath + ); + } + + + $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 API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + + $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 update + * + * Update channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsPatchRequest $channel_connection_settings_patch_request channel_connection_settings_patch_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error + */ + public function update($app_id, $channel_connection_settings_patch_request, string $contentType = self::contentTypes['update'][0]) + { + list($response) = $this->updateWithHttpInfo($app_id, $channel_connection_settings_patch_request, $contentType); + return $response; + } + + /** + * Operation updateWithHttpInfo + * + * Update channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsPatchRequest $channel_connection_settings_patch_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Crm\Extensions\Calling\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse|\HubSpot\Client\Crm\Extensions\Calling\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function updateWithHttpInfo($app_id, $channel_connection_settings_patch_request, string $contentType = self::contentTypes['update'][0]) + { + $request = $this->updateRequest($app_id, $channel_connection_settings_patch_request, $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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse' !== '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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Crm\Extensions\Calling\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Crm\Extensions\Calling\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\Crm\Extensions\Calling\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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + 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\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Extensions\Calling\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateAsync + * + * Update channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsPatchRequest $channel_connection_settings_patch_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAsync($app_id, $channel_connection_settings_patch_request, string $contentType = self::contentTypes['update'][0]) + { + return $this->updateAsyncWithHttpInfo($app_id, $channel_connection_settings_patch_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateAsyncWithHttpInfo + * + * Update channel connection settings + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsPatchRequest $channel_connection_settings_patch_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAsyncWithHttpInfo($app_id, $channel_connection_settings_patch_request, string $contentType = self::contentTypes['update'][0]) + { + $returnType = '\HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsResponse'; + $request = $this->updateRequest($app_id, $channel_connection_settings_patch_request, $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 'update' + * + * @param int $app_id The ID of the app. (required) + * @param \HubSpot\Client\Crm\Extensions\Calling\Model\ChannelConnectionSettingsPatchRequest $channel_connection_settings_patch_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateRequest($app_id, $channel_connection_settings_patch_request, string $contentType = self::contentTypes['update'][0]) + { + + // verify the required parameter 'app_id' is set + if ($app_id === null || (is_array($app_id) && count($app_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $app_id when calling update' + ); + } + + // verify the required parameter 'channel_connection_settings_patch_request' is set + if ($channel_connection_settings_patch_request === null || (is_array($channel_connection_settings_patch_request) && count($channel_connection_settings_patch_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $channel_connection_settings_patch_request when calling update' + ); + } + + + $resourcePath = '/crm/v3/extensions/calling/{appId}/settings/channel-connection'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($app_id !== null) { + $resourcePath = str_replace( + '{' . 'appId' . '}', + ObjectSerializer::toPathValue($app_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($channel_connection_settings_patch_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($channel_connection_settings_patch_request)); + } else { + $httpBody = $channel_connection_settings_patch_request; + } + } elseif (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 API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + + $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( + 'PATCH', + $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/Crm/Extensions/Calling/Api/RecordingSettingsApi.php b/codegen/Crm/Extensions/Calling/Api/RecordingSettingsApi.php index 017ba5731..0c16ec06c 100644 --- a/codegen/Crm/Extensions/Calling/Api/RecordingSettingsApi.php +++ b/codegen/Crm/Extensions/Calling/Api/RecordingSettingsApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -92,13 +92,13 @@ class RecordingSettingsApi * @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, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -134,7 +134,7 @@ public function getConfig() /** * Operation getUrlFormat * - * Read calling app recording settings + * Retrieve recording settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUrlFormat'] to see the possible values for this operation @@ -152,7 +152,7 @@ public function getUrlFormat($app_id, string $contentType = self::contentTypes[' /** * Operation getUrlFormatWithHttpInfo * - * Read calling app recording settings + * Retrieve recording settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUrlFormat'] to see the possible values for this operation @@ -187,18 +187,6 @@ public function getUrlFormatWithHttpInfo($app_id, string $contentType = self::co $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -257,6 +245,19 @@ public function getUrlFormatWithHttpInfo($app_id, string $contentType = self::co ]; } + 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\Crm\Extensions\Calling\Model\RecordingSettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -311,7 +312,7 @@ public function getUrlFormatWithHttpInfo($app_id, string $contentType = self::co /** * Operation getUrlFormatAsync * - * Read calling app recording settings + * Retrieve recording settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUrlFormat'] to see the possible values for this operation @@ -332,7 +333,7 @@ function ($response) { /** * Operation getUrlFormatAsyncWithHttpInfo * - * Read calling app recording settings + * Retrieve recording settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUrlFormat'] to see the possible values for this operation @@ -533,18 +534,6 @@ public function markAsReadyWithHttpInfo($mark_recording_as_ready_request, string $statusCode = $response->getStatusCode(); - 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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -721,7 +710,7 @@ public function markAsReadyRequest($mark_recording_as_ready_request, string $con /** * Operation registerUrlFormat * - * Register calling app for recording + * Enable the app for call recording * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsRequest $recording_settings_request recording_settings_request (required) @@ -740,7 +729,7 @@ public function registerUrlFormat($app_id, $recording_settings_request, string $ /** * Operation registerUrlFormatWithHttpInfo * - * Register calling app for recording + * Enable the app for call recording * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsRequest $recording_settings_request (required) @@ -776,18 +765,6 @@ public function registerUrlFormatWithHttpInfo($app_id, $recording_settings_reque $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -846,6 +823,19 @@ public function registerUrlFormatWithHttpInfo($app_id, $recording_settings_reque ]; } + 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\Crm\Extensions\Calling\Model\RecordingSettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -900,7 +890,7 @@ public function registerUrlFormatWithHttpInfo($app_id, $recording_settings_reque /** * Operation registerUrlFormatAsync * - * Register calling app for recording + * Enable the app for call recording * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsRequest $recording_settings_request (required) @@ -922,7 +912,7 @@ function ($response) { /** * Operation registerUrlFormatAsyncWithHttpInfo * - * Register calling app for recording + * Enable the app for call recording * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsRequest $recording_settings_request (required) @@ -1087,7 +1077,7 @@ public function registerUrlFormatRequest($app_id, $recording_settings_request, s /** * Operation updateUrlFormat * - * Update calling app's recording settings + * Update recording settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsPatchRequest $recording_settings_patch_request recording_settings_patch_request (required) @@ -1106,7 +1096,7 @@ public function updateUrlFormat($app_id, $recording_settings_patch_request, stri /** * Operation updateUrlFormatWithHttpInfo * - * Update calling app's recording settings + * Update recording settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsPatchRequest $recording_settings_patch_request (required) @@ -1142,18 +1132,6 @@ public function updateUrlFormatWithHttpInfo($app_id, $recording_settings_patch_r $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -1212,6 +1190,19 @@ public function updateUrlFormatWithHttpInfo($app_id, $recording_settings_patch_r ]; } + 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\Crm\Extensions\Calling\Model\RecordingSettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1266,7 +1257,7 @@ public function updateUrlFormatWithHttpInfo($app_id, $recording_settings_patch_r /** * Operation updateUrlFormatAsync * - * Update calling app's recording settings + * Update recording settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsPatchRequest $recording_settings_patch_request (required) @@ -1288,7 +1279,7 @@ function ($response) { /** * Operation updateUrlFormatAsyncWithHttpInfo * - * Update calling app's recording settings + * Update recording settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Crm\Extensions\Calling\Model\RecordingSettingsPatchRequest $recording_settings_patch_request (required) diff --git a/codegen/Crm/Extensions/Calling/Api/SettingsApi.php b/codegen/Crm/Extensions/Calling/Api/SettingsApi.php index 5daae8ad7..7f8211e4d 100644 --- a/codegen/Crm/Extensions/Calling/Api/SettingsApi.php +++ b/codegen/Crm/Extensions/Calling/Api/SettingsApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -92,13 +92,13 @@ class SettingsApi * @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, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -186,18 +186,6 @@ public function archiveWithHttpInfo($app_id, string $contentType = self::content $statusCode = $response->getStatusCode(); - 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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -431,18 +419,6 @@ public function createWithHttpInfo($app_id, $settings_request, string $contentTy $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -501,6 +477,19 @@ public function createWithHttpInfo($app_id, $settings_request, string $contentTy ]; } + 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\Crm\Extensions\Calling\Model\SettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -742,7 +731,7 @@ public function createRequest($app_id, $settings_request, string $contentType = /** * Operation getById * - * Get calling settings + * Retrieve settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation @@ -760,7 +749,7 @@ public function getById($app_id, string $contentType = self::contentTypes['getBy /** * Operation getByIdWithHttpInfo * - * Get calling settings + * Retrieve settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation @@ -795,18 +784,6 @@ public function getByIdWithHttpInfo($app_id, string $contentType = self::content $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -865,6 +842,19 @@ public function getByIdWithHttpInfo($app_id, string $contentType = self::content ]; } + 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\Crm\Extensions\Calling\Model\SettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -919,7 +909,7 @@ public function getByIdWithHttpInfo($app_id, string $contentType = self::content /** * Operation getByIdAsync * - * Get calling settings + * Retrieve settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation @@ -940,7 +930,7 @@ function ($response) { /** * Operation getByIdAsyncWithHttpInfo * - * Get calling settings + * Retrieve settings * * @param int $app_id The ID of the app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation @@ -1144,18 +1134,6 @@ public function updateWithHttpInfo($app_id, $settings_patch_request, string $con $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -1214,6 +1192,19 @@ public function updateWithHttpInfo($app_id, $settings_patch_request, string $con ]; } + 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\Crm\Extensions\Calling\Model\SettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Crm/Extensions/Calling/ApiException.php b/codegen/Crm/Extensions/Calling/ApiException.php index b7c0d8452..191f081e8 100644 --- a/codegen/Crm/Extensions/Calling/ApiException.php +++ b/codegen/Crm/Extensions/Calling/ApiException.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -49,7 +49,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[][]|null */ protected $responseHeaders; @@ -65,7 +65,7 @@ class ApiException extends Exception * * @param string $message Error message * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header + * @param string[][]|null $responseHeaders HTTP response header * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) @@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[][]|null HTTP response header */ public function getResponseHeaders() { diff --git a/codegen/Crm/Extensions/Calling/Configuration.php b/codegen/Crm/Extensions/Calling/Configuration.php index e172b3e5b..e1244b85f 100644 --- a/codegen/Crm/Extensions/Calling/Configuration.php +++ b/codegen/Crm/Extensions/Calling/Configuration.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -486,7 +486,7 @@ public function getHostSettings() * @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) + public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null) { if (null === $variables) { $variables = []; diff --git a/codegen/Crm/Extensions/Calling/HeaderSelector.php b/codegen/Crm/Extensions/Calling/HeaderSelector.php index 15db593b9..9319e9fb7 100644 --- a/codegen/Crm/Extensions/Calling/HeaderSelector.php +++ b/codegen/Crm/Extensions/Calling/HeaderSelector.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string } # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + $headersWithJson = $this->selectJsonMimeList($accept); if (count($headersWithJson) === 0) { return implode(',', $accept); } @@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string 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 * diff --git a/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsPatchRequest.php b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsPatchRequest.php new file mode 100644 index 000000000..c5e0e27b2 --- /dev/null +++ b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsPatchRequest.php @@ -0,0 +1,443 @@ + + */ +class ChannelConnectionSettingsPatchRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChannelConnectionSettingsPatchRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'is_ready' => 'bool', + 'url' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'is_ready' => null, + 'url' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'is_ready' => false, + 'url' => 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 = [ + 'is_ready' => 'isReady', + 'url' => 'url' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'is_ready' => 'setIsReady', + 'url' => 'setUrl' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'is_ready' => 'getIsReady', + 'url' => 'getUrl' + ]; + + /** + * 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('is_ready', $data ?? [], null); + $this->setIfExists('url', $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 = []; + + 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 is_ready + * + * @return bool|null + */ + public function getIsReady() + { + return $this->container['is_ready']; + } + + /** + * Sets is_ready + * + * @param bool|null $is_ready If true, this app will be considered to support channel connection + * + * @return self + */ + public function setIsReady($is_ready) + { + if (is_null($is_ready)) { + throw new \InvalidArgumentException('non-nullable is_ready cannot be null'); + } + $this->container['is_ready'] = $is_ready; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url The URL to fetch phone numbers available for channel connection + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + 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/Crm/Extensions/Calling/Model/ChannelConnectionSettingsRequest.php b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsRequest.php new file mode 100644 index 000000000..c3302f1bc --- /dev/null +++ b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsRequest.php @@ -0,0 +1,449 @@ + + */ +class ChannelConnectionSettingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChannelConnectionSettingsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'is_ready' => 'bool', + 'url' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'is_ready' => null, + 'url' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'is_ready' => false, + 'url' => 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 = [ + 'is_ready' => 'isReady', + 'url' => 'url' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'is_ready' => 'setIsReady', + 'url' => 'setUrl' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'is_ready' => 'getIsReady', + 'url' => 'getUrl' + ]; + + /** + * 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('is_ready', $data ?? [], null); + $this->setIfExists('url', $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['is_ready'] === null) { + $invalidProperties[] = "'is_ready' can't be null"; + } + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' 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 is_ready + * + * @return bool + */ + public function getIsReady() + { + return $this->container['is_ready']; + } + + /** + * Sets is_ready + * + * @param bool $is_ready If true, this app will be considered to support channel connection + * + * @return self + */ + public function setIsReady($is_ready) + { + if (is_null($is_ready)) { + throw new \InvalidArgumentException('non-nullable is_ready cannot be null'); + } + $this->container['is_ready'] = $is_ready; + + return $this; + } + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url The URL to fetch phone numbers available for channel connection + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + 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/Crm/Extensions/Calling/Model/ChannelConnectionSettingsResponse.php b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsResponse.php new file mode 100644 index 000000000..216f4a694 --- /dev/null +++ b/codegen/Crm/Extensions/Calling/Model/ChannelConnectionSettingsResponse.php @@ -0,0 +1,523 @@ + + */ +class ChannelConnectionSettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChannelConnectionSettingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'created_at' => '\DateTime', + 'is_ready' => 'bool', + 'url' => 'string', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'created_at' => 'date-time', + 'is_ready' => null, + 'url' => null, + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'created_at' => false, + 'is_ready' => false, + 'url' => false, + 'updated_at' => 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 = [ + 'created_at' => 'createdAt', + 'is_ready' => 'isReady', + 'url' => 'url', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'created_at' => 'setCreatedAt', + 'is_ready' => 'setIsReady', + 'url' => 'setUrl', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'created_at' => 'getCreatedAt', + 'is_ready' => 'getIsReady', + 'url' => 'getUrl', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * 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('created_at', $data ?? [], null); + $this->setIfExists('is_ready', $data ?? [], null); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('updated_at', $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['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['is_ready'] === null) { + $invalidProperties[] = "'is_ready' can't be null"; + } + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' can't be null"; + } + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' 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 created_at + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime $created_at The timestamp this setting was created + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets is_ready + * + * @return bool + */ + public function getIsReady() + { + return $this->container['is_ready']; + } + + /** + * Sets is_ready + * + * @param bool $is_ready If true, this app will be considered to support channel connection + * + * @return self + */ + public function setIsReady($is_ready) + { + if (is_null($is_ready)) { + throw new \InvalidArgumentException('non-nullable is_ready cannot be null'); + } + $this->container['is_ready'] = $is_ready; + + return $this; + } + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url The URL to fetch phone numbers available for channel connection + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at The timestamp this setting was last updated + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + 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/Crm/Extensions/Calling/Model/Error.php b/codegen/Crm/Extensions/Calling/Model/Error.php index a121d574b..beeffec0c 100644 --- a/codegen/Crm/Extensions/Calling/Model/Error.php +++ b/codegen/Crm/Extensions/Calling/Model/Error.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -275,10 +275,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Calling/Model/ErrorDetail.php b/codegen/Crm/Extensions/Calling/Model/ErrorDetail.php index e89922f4b..5b75812fc 100644 --- a/codegen/Crm/Extensions/Calling/Model/ErrorDetail.php +++ b/codegen/Crm/Extensions/Calling/Model/ErrorDetail.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('code', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Calling/Model/MarkRecordingAsReadyRequest.php b/codegen/Crm/Extensions/Calling/Model/MarkRecordingAsReadyRequest.php index 75da7755c..276410bc8 100644 --- a/codegen/Crm/Extensions/Calling/Model/MarkRecordingAsReadyRequest.php +++ b/codegen/Crm/Extensions/Calling/Model/MarkRecordingAsReadyRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('engagement_id', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Calling/Model/ModelInterface.php b/codegen/Crm/Extensions/Calling/Model/ModelInterface.php index 10582de52..91f95b42a 100644 --- a/codegen/Crm/Extensions/Calling/Model/ModelInterface.php +++ b/codegen/Crm/Extensions/Calling/Model/ModelInterface.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsPatchRequest.php b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsPatchRequest.php index 031e06003..b5b50c8cc 100644 --- a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsPatchRequest.php +++ b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsPatchRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('url_to_retrieve_authed_recording', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsRequest.php b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsRequest.php index f304dee4f..4fc04af16 100644 --- a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsRequest.php +++ b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('url_to_retrieve_authed_recording', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsResponse.php b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsResponse.php index e7718a4de..a59fb4e3b 100644 --- a/codegen/Crm/Extensions/Calling/Model/RecordingSettingsResponse.php +++ b/codegen/Crm/Extensions/Calling/Model/RecordingSettingsResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('url_to_retrieve_authed_recording', $data ?? [], null); } @@ -305,7 +305,7 @@ public function getUrlToRetrieveAuthedRecording() /** * Sets url_to_retrieve_authed_recording * - * @param string $url_to_retrieve_authed_recording url_to_retrieve_authed_recording + * @param string $url_to_retrieve_authed_recording * * @return self */ diff --git a/codegen/Crm/Extensions/Calling/Model/SettingsPatchRequest.php b/codegen/Crm/Extensions/Calling/Model/SettingsPatchRequest.php index bdc2eaed7..be259f679 100644 --- a/codegen/Crm/Extensions/Calling/Model/SettingsPatchRequest.php +++ b/codegen/Crm/Extensions/Calling/Model/SettingsPatchRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,9 +58,11 @@ class SettingsPatchRequest implements ModelInterface, ArrayAccess, \JsonSerializ */ protected static $openAPITypes = [ 'supports_custom_objects' => 'bool', + 'uses_remote' => 'bool', 'is_ready' => 'bool', 'name' => 'string', 'width' => 'int', + 'uses_calling_window' => 'bool', 'supports_inbound_calling' => 'bool', 'url' => 'string', 'height' => 'int' @@ -75,9 +77,11 @@ class SettingsPatchRequest implements ModelInterface, ArrayAccess, \JsonSerializ */ protected static $openAPIFormats = [ 'supports_custom_objects' => null, + 'uses_remote' => null, 'is_ready' => null, 'name' => null, 'width' => 'int32', + 'uses_calling_window' => null, 'supports_inbound_calling' => null, 'url' => null, 'height' => 'int32' @@ -90,9 +94,11 @@ class SettingsPatchRequest implements ModelInterface, ArrayAccess, \JsonSerializ */ protected static array $openAPINullables = [ 'supports_custom_objects' => false, + 'uses_remote' => false, 'is_ready' => false, 'name' => false, 'width' => false, + 'uses_calling_window' => false, 'supports_inbound_calling' => false, 'url' => false, 'height' => false @@ -185,9 +191,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'supports_custom_objects' => 'supportsCustomObjects', + 'uses_remote' => 'usesRemote', 'is_ready' => 'isReady', 'name' => 'name', 'width' => 'width', + 'uses_calling_window' => 'usesCallingWindow', 'supports_inbound_calling' => 'supportsInboundCalling', 'url' => 'url', 'height' => 'height' @@ -200,9 +208,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'supports_custom_objects' => 'setSupportsCustomObjects', + 'uses_remote' => 'setUsesRemote', 'is_ready' => 'setIsReady', 'name' => 'setName', 'width' => 'setWidth', + 'uses_calling_window' => 'setUsesCallingWindow', 'supports_inbound_calling' => 'setSupportsInboundCalling', 'url' => 'setUrl', 'height' => 'setHeight' @@ -215,9 +225,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'supports_custom_objects' => 'getSupportsCustomObjects', + 'uses_remote' => 'getUsesRemote', 'is_ready' => 'getIsReady', 'name' => 'getName', 'width' => 'getWidth', + 'uses_calling_window' => 'getUsesCallingWindow', 'supports_inbound_calling' => 'getSupportsInboundCalling', 'url' => 'getUrl', 'height' => 'getHeight' @@ -275,15 +287,17 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('supports_custom_objects', $data ?? [], null); + $this->setIfExists('uses_remote', $data ?? [], null); $this->setIfExists('is_ready', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('uses_calling_window', $data ?? [], null); $this->setIfExists('supports_inbound_calling', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); $this->setIfExists('height', $data ?? [], null); @@ -358,6 +372,33 @@ public function setSupportsCustomObjects($supports_custom_objects) return $this; } + /** + * Gets uses_remote + * + * @return bool|null + */ + public function getUsesRemote() + { + return $this->container['uses_remote']; + } + + /** + * Sets uses_remote + * + * @param bool|null $uses_remote When false, this indicates that your calling app does not use the anchored calling remote within the HubSpot app. + * + * @return self + */ + public function setUsesRemote($uses_remote) + { + if (is_null($uses_remote)) { + throw new \InvalidArgumentException('non-nullable uses_remote cannot be null'); + } + $this->container['uses_remote'] = $uses_remote; + + return $this; + } + /** * Gets is_ready * @@ -439,6 +480,33 @@ public function setWidth($width) return $this; } + /** + * Gets uses_calling_window + * + * @return bool|null + */ + public function getUsesCallingWindow() + { + return $this->container['uses_calling_window']; + } + + /** + * Sets uses_calling_window + * + * @param bool|null $uses_calling_window When false, this indicates that your calling app does not require the use of the separate calling window to hold the call connection. + * + * @return self + */ + public function setUsesCallingWindow($uses_calling_window) + { + if (is_null($uses_calling_window)) { + throw new \InvalidArgumentException('non-nullable uses_calling_window cannot be null'); + } + $this->container['uses_calling_window'] = $uses_calling_window; + + return $this; + } + /** * Gets supports_inbound_calling * diff --git a/codegen/Crm/Extensions/Calling/Model/SettingsRequest.php b/codegen/Crm/Extensions/Calling/Model/SettingsRequest.php index 5290a8166..e3697f470 100644 --- a/codegen/Crm/Extensions/Calling/Model/SettingsRequest.php +++ b/codegen/Crm/Extensions/Calling/Model/SettingsRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,9 +58,11 @@ class SettingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPITypes = [ 'supports_custom_objects' => 'bool', + 'uses_remote' => 'bool', 'is_ready' => 'bool', 'name' => 'string', 'width' => 'int', + 'uses_calling_window' => 'bool', 'supports_inbound_calling' => 'bool', 'url' => 'string', 'height' => 'int' @@ -75,9 +77,11 @@ class SettingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'supports_custom_objects' => null, + 'uses_remote' => null, 'is_ready' => null, 'name' => null, 'width' => 'int32', + 'uses_calling_window' => null, 'supports_inbound_calling' => null, 'url' => null, 'height' => 'int32' @@ -90,9 +94,11 @@ class SettingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static array $openAPINullables = [ 'supports_custom_objects' => false, + 'uses_remote' => false, 'is_ready' => false, 'name' => false, 'width' => false, + 'uses_calling_window' => false, 'supports_inbound_calling' => false, 'url' => false, 'height' => false @@ -185,9 +191,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'supports_custom_objects' => 'supportsCustomObjects', + 'uses_remote' => 'usesRemote', 'is_ready' => 'isReady', 'name' => 'name', 'width' => 'width', + 'uses_calling_window' => 'usesCallingWindow', 'supports_inbound_calling' => 'supportsInboundCalling', 'url' => 'url', 'height' => 'height' @@ -200,9 +208,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'supports_custom_objects' => 'setSupportsCustomObjects', + 'uses_remote' => 'setUsesRemote', 'is_ready' => 'setIsReady', 'name' => 'setName', 'width' => 'setWidth', + 'uses_calling_window' => 'setUsesCallingWindow', 'supports_inbound_calling' => 'setSupportsInboundCalling', 'url' => 'setUrl', 'height' => 'setHeight' @@ -215,9 +225,11 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'supports_custom_objects' => 'getSupportsCustomObjects', + 'uses_remote' => 'getUsesRemote', 'is_ready' => 'getIsReady', 'name' => 'getName', 'width' => 'getWidth', + 'uses_calling_window' => 'getUsesCallingWindow', 'supports_inbound_calling' => 'getSupportsInboundCalling', 'url' => 'getUrl', 'height' => 'getHeight' @@ -275,15 +287,17 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('supports_custom_objects', $data ?? [], null); + $this->setIfExists('uses_remote', $data ?? [], null); $this->setIfExists('is_ready', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('uses_calling_window', $data ?? [], null); $this->setIfExists('supports_inbound_calling', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); $this->setIfExists('height', $data ?? [], null); @@ -364,6 +378,33 @@ public function setSupportsCustomObjects($supports_custom_objects) return $this; } + /** + * Gets uses_remote + * + * @return bool|null + */ + public function getUsesRemote() + { + return $this->container['uses_remote']; + } + + /** + * Sets uses_remote + * + * @param bool|null $uses_remote When false, this indicates that your calling app does not use the anchored calling remote within the HubSpot app. + * + * @return self + */ + public function setUsesRemote($uses_remote) + { + if (is_null($uses_remote)) { + throw new \InvalidArgumentException('non-nullable uses_remote cannot be null'); + } + $this->container['uses_remote'] = $uses_remote; + + return $this; + } + /** * Gets is_ready * @@ -445,6 +486,33 @@ public function setWidth($width) return $this; } + /** + * Gets uses_calling_window + * + * @return bool|null + */ + public function getUsesCallingWindow() + { + return $this->container['uses_calling_window']; + } + + /** + * Sets uses_calling_window + * + * @param bool|null $uses_calling_window When false, this indicates that your calling app does not require the use of the separate calling window to hold the call connection. + * + * @return self + */ + public function setUsesCallingWindow($uses_calling_window) + { + if (is_null($uses_calling_window)) { + throw new \InvalidArgumentException('non-nullable uses_calling_window cannot be null'); + } + $this->container['uses_calling_window'] = $uses_calling_window; + + return $this; + } + /** * Gets supports_inbound_calling * diff --git a/codegen/Crm/Extensions/Calling/Model/SettingsResponse.php b/codegen/Crm/Extensions/Calling/Model/SettingsResponse.php index 40092a042..7d2dc42e8 100644 --- a/codegen/Crm/Extensions/Calling/Model/SettingsResponse.php +++ b/codegen/Crm/Extensions/Calling/Model/SettingsResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -59,9 +59,11 @@ class SettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPITypes = [ 'created_at' => '\DateTime', 'supports_custom_objects' => 'bool', + 'uses_remote' => 'bool', 'is_ready' => 'bool', 'name' => 'string', 'width' => 'int', + 'uses_calling_window' => 'bool', 'supports_inbound_calling' => 'bool', 'url' => 'string', 'height' => 'int', @@ -78,9 +80,11 @@ class SettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPIFormats = [ 'created_at' => 'date-time', 'supports_custom_objects' => null, + 'uses_remote' => null, 'is_ready' => null, 'name' => null, 'width' => 'int32', + 'uses_calling_window' => null, 'supports_inbound_calling' => null, 'url' => null, 'height' => 'int32', @@ -95,9 +99,11 @@ class SettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable protected static array $openAPINullables = [ 'created_at' => false, 'supports_custom_objects' => false, + 'uses_remote' => false, 'is_ready' => false, 'name' => false, 'width' => false, + 'uses_calling_window' => false, 'supports_inbound_calling' => false, 'url' => false, 'height' => false, @@ -192,9 +198,11 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'created_at' => 'createdAt', 'supports_custom_objects' => 'supportsCustomObjects', + 'uses_remote' => 'usesRemote', 'is_ready' => 'isReady', 'name' => 'name', 'width' => 'width', + 'uses_calling_window' => 'usesCallingWindow', 'supports_inbound_calling' => 'supportsInboundCalling', 'url' => 'url', 'height' => 'height', @@ -209,9 +217,11 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'created_at' => 'setCreatedAt', 'supports_custom_objects' => 'setSupportsCustomObjects', + 'uses_remote' => 'setUsesRemote', 'is_ready' => 'setIsReady', 'name' => 'setName', 'width' => 'setWidth', + 'uses_calling_window' => 'setUsesCallingWindow', 'supports_inbound_calling' => 'setSupportsInboundCalling', 'url' => 'setUrl', 'height' => 'setHeight', @@ -226,9 +236,11 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'created_at' => 'getCreatedAt', 'supports_custom_objects' => 'getSupportsCustomObjects', + 'uses_remote' => 'getUsesRemote', 'is_ready' => 'getIsReady', 'name' => 'getName', 'width' => 'getWidth', + 'uses_calling_window' => 'getUsesCallingWindow', 'supports_inbound_calling' => 'getSupportsInboundCalling', 'url' => 'getUrl', 'height' => 'getHeight', @@ -287,16 +299,18 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('created_at', $data ?? [], null); $this->setIfExists('supports_custom_objects', $data ?? [], null); + $this->setIfExists('uses_remote', $data ?? [], null); $this->setIfExists('is_ready', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('uses_calling_window', $data ?? [], null); $this->setIfExists('supports_inbound_calling', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); $this->setIfExists('height', $data ?? [], null); @@ -336,6 +350,9 @@ public function listInvalidProperties() if ($this->container['supports_custom_objects'] === null) { $invalidProperties[] = "'supports_custom_objects' can't be null"; } + if ($this->container['uses_remote'] === null) { + $invalidProperties[] = "'uses_remote' can't be null"; + } if ($this->container['is_ready'] === null) { $invalidProperties[] = "'is_ready' can't be null"; } @@ -345,6 +362,9 @@ public function listInvalidProperties() if ($this->container['width'] === null) { $invalidProperties[] = "'width' can't be null"; } + if ($this->container['uses_calling_window'] === null) { + $invalidProperties[] = "'uses_calling_window' can't be null"; + } if ($this->container['supports_inbound_calling'] === null) { $invalidProperties[] = "'supports_inbound_calling' can't be null"; } @@ -426,6 +446,33 @@ public function setSupportsCustomObjects($supports_custom_objects) return $this; } + /** + * Gets uses_remote + * + * @return bool + */ + public function getUsesRemote() + { + return $this->container['uses_remote']; + } + + /** + * Sets uses_remote + * + * @param bool $uses_remote When false, this indicates that your calling app does not use the anchored calling remote within the HubSpot app. + * + * @return self + */ + public function setUsesRemote($uses_remote) + { + if (is_null($uses_remote)) { + throw new \InvalidArgumentException('non-nullable uses_remote cannot be null'); + } + $this->container['uses_remote'] = $uses_remote; + + return $this; + } + /** * Gets is_ready * @@ -507,6 +554,33 @@ public function setWidth($width) return $this; } + /** + * Gets uses_calling_window + * + * @return bool + */ + public function getUsesCallingWindow() + { + return $this->container['uses_calling_window']; + } + + /** + * Sets uses_calling_window + * + * @param bool $uses_calling_window When false, this indicates that your calling app does not require the use of the separate calling window to hold the call connection. + * + * @return self + */ + public function setUsesCallingWindow($uses_calling_window) + { + if (is_null($uses_calling_window)) { + throw new \InvalidArgumentException('non-nullable uses_calling_window cannot be null'); + } + $this->container['uses_calling_window'] = $uses_calling_window; + + return $this; + } + /** * Gets supports_inbound_calling * diff --git a/codegen/Crm/Extensions/Calling/ObjectSerializer.php b/codegen/Crm/Extensions/Calling/ObjectSerializer.php index 3297ff2ab..ebd275866 100644 --- a/codegen/Crm/Extensions/Calling/ObjectSerializer.php +++ b/codegen/Crm/Extensions/Calling/ObjectSerializer.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,8 +58,8 @@ public static function setDateTimeFormat($format) * Serialize data * * @param mixed $data the data to serialize - * @param string $type the OpenAPIToolsType of the data - * @param string $format the format of the OpenAPITools type of the data + * @param string|null $type the OpenAPIToolsType of the data + * @param string|null $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ @@ -194,6 +194,10 @@ private static function isEmptyValue($value, string $openApiType): 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; @@ -265,6 +269,11 @@ public static function toQueryValue( $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; } @@ -338,7 +347,7 @@ public static function toFormValue($value) * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|\DateTime $value the value of the parameter + * @param float|int|bool|\DateTime $value the value of the parameter * * @return string the header string */ @@ -395,8 +404,7 @@ public static function serializeCollection(array $collection, $style, $allowColl * * @param mixed $data object or primitive to be deserialized * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * @param string $discriminator discriminator if polymorphism is used + * @param string[]|null $httpHeaders HTTP headers * * @return object|array|null a single or an array of $class instances */ @@ -473,7 +481,7 @@ public static function deserialize($data, $class, $httpHeaders = null) // determine file name if ( is_array($httpHeaders) - && array_key_exists('Content-Disposition', $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]); @@ -546,22 +554,64 @@ public static function deserialize($data, $class, $httpHeaders = null) } /** - * Native `http_build_query` wrapper. - * @see https://www.php.net/manual/en/function.http-build-query - * - * @param array|object $data May be an array or object containing properties. - * @param string $numeric_prefix If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. - * @param string|null $arg_separator arg_separator.output is used to separate arguments but may be overridden by specifying this parameter. - * @param int $encoding_type Encoding type. By default, PHP_QUERY_RFC1738. - * - * @return string - */ - public static function buildQuery( - $data, - string $numeric_prefix = '', - ?string $arg_separator = null, - int $encoding_type = \PHP_QUERY_RFC3986 - ): string { - return \GuzzleHttp\Psr7\Query::build($data, $encoding_type); + * 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/codegen/Crm/Extensions/Cards/Api/CardsApi.php b/codegen/Crm/Extensions/Cards/Api/CardsApi.php index a437850b4..fcbfe4b21 100644 --- a/codegen/Crm/Extensions/Cards/Api/CardsApi.php +++ b/codegen/Crm/Extensions/Cards/Api/CardsApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -95,13 +95,13 @@ class CardsApi * @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, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -191,18 +191,6 @@ public function archiveWithHttpInfo($card_id, $app_id, string $contentType = sel $statusCode = $response->getStatusCode(); - 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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -454,18 +442,6 @@ public function createWithHttpInfo($app_id, $card_create_request, string $conten $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 201: @@ -524,6 +500,19 @@ public function createWithHttpInfo($app_id, $card_create_request, string $conten ]; } + 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\Crm\Extensions\Cards\Model\PublicCardResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -818,18 +807,6 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -888,6 +865,19 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT ]; } + 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\Crm\Extensions\Cards\Model\PublicCardListResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1167,18 +1157,6 @@ public function getByIdWithHttpInfo($card_id, $app_id, string $contentType = sel $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -1237,6 +1215,19 @@ public function getByIdWithHttpInfo($card_id, $app_id, string $contentType = sel ]; } + 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\Crm\Extensions\Cards\Model\PublicCardResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1536,18 +1527,6 @@ public function updateWithHttpInfo($card_id, $app_id, $card_patch_request, strin $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -1606,6 +1585,19 @@ public function updateWithHttpInfo($card_id, $app_id, $card_patch_request, strin ]; } + 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\Crm\Extensions\Cards\Model\PublicCardResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Crm/Extensions/Cards/Api/SampleResponseApi.php b/codegen/Crm/Extensions/Cards/Api/SampleResponseApi.php index 77cd2651f..a6f9d61ab 100644 --- a/codegen/Crm/Extensions/Cards/Api/SampleResponseApi.php +++ b/codegen/Crm/Extensions/Cards/Api/SampleResponseApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -83,13 +83,13 @@ class SampleResponseApi * @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, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -176,18 +176,6 @@ public function getCardsSampleResponseWithHttpInfo(string $contentType = self::c $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -246,6 +234,19 @@ public function getCardsSampleResponseWithHttpInfo(string $contentType = self::c ]; } + 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\Crm\Extensions\Cards\Model\IntegratorCardPayloadResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Crm/Extensions/Cards/ApiException.php b/codegen/Crm/Extensions/Cards/ApiException.php index 0bfe0ed27..abd45abf1 100644 --- a/codegen/Crm/Extensions/Cards/ApiException.php +++ b/codegen/Crm/Extensions/Cards/ApiException.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -49,7 +49,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[][]|null */ protected $responseHeaders; @@ -65,7 +65,7 @@ class ApiException extends Exception * * @param string $message Error message * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header + * @param string[][]|null $responseHeaders HTTP response header * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) @@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[][]|null HTTP response header */ public function getResponseHeaders() { diff --git a/codegen/Crm/Extensions/Cards/Configuration.php b/codegen/Crm/Extensions/Cards/Configuration.php index 1a122a690..9df5d68f9 100644 --- a/codegen/Crm/Extensions/Cards/Configuration.php +++ b/codegen/Crm/Extensions/Cards/Configuration.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -486,7 +486,7 @@ public function getHostSettings() * @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) + public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null) { if (null === $variables) { $variables = []; diff --git a/codegen/Crm/Extensions/Cards/HeaderSelector.php b/codegen/Crm/Extensions/Cards/HeaderSelector.php index 4202cec7e..f64007c63 100644 --- a/codegen/Crm/Extensions/Cards/HeaderSelector.php +++ b/codegen/Crm/Extensions/Cards/HeaderSelector.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string } # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + $headersWithJson = $this->selectJsonMimeList($accept); if (count($headersWithJson) === 0) { return implode(',', $accept); } @@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string 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 * diff --git a/codegen/Crm/Extensions/Cards/Model/ActionConfirmationBody.php b/codegen/Crm/Extensions/Cards/Model/ActionConfirmationBody.php index 402814d86..87629d480 100644 --- a/codegen/Crm/Extensions/Cards/Model/ActionConfirmationBody.php +++ b/codegen/Crm/Extensions/Cards/Model/ActionConfirmationBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -251,10 +251,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('confirm_button_label', $data ?? [], null); $this->setIfExists('cancel_button_label', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/ActionHookActionBody.php b/codegen/Crm/Extensions/Cards/Model/ActionHookActionBody.php index 60d18f59c..1a70056fe 100644 --- a/codegen/Crm/Extensions/Cards/Model/ActionHookActionBody.php +++ b/codegen/Crm/Extensions/Cards/Model/ActionHookActionBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -311,10 +311,10 @@ public function getHttpMethodAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('property_names_included', $data ?? [], null); $this->setIfExists('confirmation', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardActions.php b/codegen/Crm/Extensions/Cards/Model/CardActions.php index d6254c2b6..bfca6a377 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardActions.php +++ b/codegen/Crm/Extensions/Cards/Model/CardActions.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -240,10 +240,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('base_urls', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Cards/Model/CardAuditResponse.php b/codegen/Crm/Extensions/Cards/Model/CardAuditResponse.php index 911b2fab7..78662da53 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardAuditResponse.php +++ b/codegen/Crm/Extensions/Cards/Model/CardAuditResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -303,10 +303,10 @@ public function getAuthSourceAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('action_type', $data ?? [], null); $this->setIfExists('object_type_id', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardCreateRequest.php b/codegen/Crm/Extensions/Cards/Model/CardCreateRequest.php index 04ed7a831..8c6fdbe77 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardCreateRequest.php +++ b/codegen/Crm/Extensions/Cards/Model/CardCreateRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -258,10 +258,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('fetch', $data ?? [], null); $this->setIfExists('display', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardDisplayBody.php b/codegen/Crm/Extensions/Cards/Model/CardDisplayBody.php index 85535cb80..b4c13f7dc 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardDisplayBody.php +++ b/codegen/Crm/Extensions/Cards/Model/CardDisplayBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -240,10 +240,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('properties', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Cards/Model/CardDisplayProperty.php b/codegen/Crm/Extensions/Cards/Model/CardDisplayProperty.php index b8de71f06..aa516eb22 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardDisplayProperty.php +++ b/codegen/Crm/Extensions/Cards/Model/CardDisplayProperty.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -287,10 +287,10 @@ public function getDataTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('data_type', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardFetchBody.php b/codegen/Crm/Extensions/Cards/Model/CardFetchBody.php index eec862a13..920c19ef9 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardFetchBody.php +++ b/codegen/Crm/Extensions/Cards/Model/CardFetchBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -273,10 +273,10 @@ public function getCardTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('serverless_function', $data ?? [], null); $this->setIfExists('card_type', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardFetchBodyPatch.php b/codegen/Crm/Extensions/Cards/Model/CardFetchBodyPatch.php index 89fc67a26..67b86aee6 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardFetchBodyPatch.php +++ b/codegen/Crm/Extensions/Cards/Model/CardFetchBodyPatch.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -273,10 +273,10 @@ public function getCardTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('serverless_function', $data ?? [], null); $this->setIfExists('card_type', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardObjectTypeBody.php b/codegen/Crm/Extensions/Cards/Model/CardObjectTypeBody.php index f283068b0..b059c8ba3 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardObjectTypeBody.php +++ b/codegen/Crm/Extensions/Cards/Model/CardObjectTypeBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -266,10 +266,10 @@ public function getNameAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('name', $data ?? [], null); $this->setIfExists('properties_to_send', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/CardPatchRequest.php b/codegen/Crm/Extensions/Cards/Model/CardPatchRequest.php index 584b54ef7..ccc847a4c 100644 --- a/codegen/Crm/Extensions/Cards/Model/CardPatchRequest.php +++ b/codegen/Crm/Extensions/Cards/Model/CardPatchRequest.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -258,10 +258,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('fetch', $data ?? [], null); $this->setIfExists('display', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/DisplayOption.php b/codegen/Crm/Extensions/Cards/Model/DisplayOption.php index 16f476648..d0903bb7b 100644 --- a/codegen/Crm/Extensions/Cards/Model/DisplayOption.php +++ b/codegen/Crm/Extensions/Cards/Model/DisplayOption.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -273,10 +273,10 @@ public function getTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('name', $data ?? [], null); $this->setIfExists('label', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/Error.php b/codegen/Crm/Extensions/Cards/Model/Error.php index 87653104c..74af8d8b2 100644 --- a/codegen/Crm/Extensions/Cards/Model/Error.php +++ b/codegen/Crm/Extensions/Cards/Model/Error.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -275,10 +275,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/ErrorDetail.php b/codegen/Crm/Extensions/Cards/Model/ErrorDetail.php index feead66d3..38f4c56b6 100644 --- a/codegen/Crm/Extensions/Cards/Model/ErrorDetail.php +++ b/codegen/Crm/Extensions/Cards/Model/ErrorDetail.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('code', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/IFrameActionBody.php b/codegen/Crm/Extensions/Cards/Model/IFrameActionBody.php index 38d8e8b6b..943ca7cf0 100644 --- a/codegen/Crm/Extensions/Cards/Model/IFrameActionBody.php +++ b/codegen/Crm/Extensions/Cards/Model/IFrameActionBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -282,10 +282,10 @@ public function getTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('property_names_included', $data ?? [], null); $this->setIfExists('width', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/IntegratorCardPayloadResponse.php b/codegen/Crm/Extensions/Cards/Model/IntegratorCardPayloadResponse.php index 6dd58c8cb..c97c99828 100644 --- a/codegen/Crm/Extensions/Cards/Model/IntegratorCardPayloadResponse.php +++ b/codegen/Crm/Extensions/Cards/Model/IntegratorCardPayloadResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -285,10 +285,10 @@ public function getResponseVersionAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('response_version', $data ?? [], null); $this->setIfExists('card_label', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResult.php b/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResult.php index 829ed5a5a..401fc7dea 100644 --- a/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResult.php +++ b/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResult.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('link_url', $data ?? [], null); $this->setIfExists('tokens', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResultActionsInner.php b/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResultActionsInner.php index 8b4eb8291..34f367e98 100644 --- a/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResultActionsInner.php +++ b/codegen/Crm/Extensions/Cards/Model/IntegratorObjectResultActionsInner.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -325,10 +325,10 @@ public function getHttpMethodAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('property_names_included', $data ?? [], null); $this->setIfExists('confirmation', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/ModelInterface.php b/codegen/Crm/Extensions/Cards/Model/ModelInterface.php index 6cd6a0c76..c3ac81a15 100644 --- a/codegen/Crm/Extensions/Cards/Model/ModelInterface.php +++ b/codegen/Crm/Extensions/Cards/Model/ModelInterface.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Crm/Extensions/Cards/Model/ObjectToken.php b/codegen/Crm/Extensions/Cards/Model/ObjectToken.php index 6ff802fec..aa3de3a3a 100644 --- a/codegen/Crm/Extensions/Cards/Model/ObjectToken.php +++ b/codegen/Crm/Extensions/Cards/Model/ObjectToken.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -286,10 +286,10 @@ public function getDataTypeAllowableValues() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('data_type', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/PublicCardFetchBody.php b/codegen/Crm/Extensions/Cards/Model/PublicCardFetchBody.php index c08a224da..f892b3504 100644 --- a/codegen/Crm/Extensions/Cards/Model/PublicCardFetchBody.php +++ b/codegen/Crm/Extensions/Cards/Model/PublicCardFetchBody.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -245,10 +245,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('object_types', $data ?? [], null); $this->setIfExists('target_url', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/PublicCardListResponse.php b/codegen/Crm/Extensions/Cards/Model/PublicCardListResponse.php index df2e41052..30257926f 100644 --- a/codegen/Crm/Extensions/Cards/Model/PublicCardListResponse.php +++ b/codegen/Crm/Extensions/Cards/Model/PublicCardListResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('results', $data ?? [], null); } diff --git a/codegen/Crm/Extensions/Cards/Model/PublicCardResponse.php b/codegen/Crm/Extensions/Cards/Model/PublicCardResponse.php index 564d2a68b..b9cb96562 100644 --- a/codegen/Crm/Extensions/Cards/Model/PublicCardResponse.php +++ b/codegen/Crm/Extensions/Cards/Model/PublicCardResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -281,10 +281,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('created_at', $data ?? [], null); $this->setIfExists('fetch', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/Model/TopLevelActions.php b/codegen/Crm/Extensions/Cards/Model/TopLevelActions.php index 36e65c2ff..db9da1269 100644 --- a/codegen/Crm/Extensions/Cards/Model/TopLevelActions.php +++ b/codegen/Crm/Extensions/Cards/Model/TopLevelActions.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -251,10 +251,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('secondary', $data ?? [], null); $this->setIfExists('settings', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Cards/ObjectSerializer.php b/codegen/Crm/Extensions/Cards/ObjectSerializer.php index 9e698636b..612446c11 100644 --- a/codegen/Crm/Extensions/Cards/ObjectSerializer.php +++ b/codegen/Crm/Extensions/Cards/ObjectSerializer.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,8 +58,8 @@ public static function setDateTimeFormat($format) * Serialize data * * @param mixed $data the data to serialize - * @param string $type the OpenAPIToolsType of the data - * @param string $format the format of the OpenAPITools type of the data + * @param string|null $type the OpenAPIToolsType of the data + * @param string|null $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ @@ -194,6 +194,10 @@ private static function isEmptyValue($value, string $openApiType): 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; @@ -265,6 +269,11 @@ public static function toQueryValue( $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; } @@ -338,7 +347,7 @@ public static function toFormValue($value) * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|\DateTime $value the value of the parameter + * @param float|int|bool|\DateTime $value the value of the parameter * * @return string the header string */ @@ -395,8 +404,7 @@ public static function serializeCollection(array $collection, $style, $allowColl * * @param mixed $data object or primitive to be deserialized * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * @param string $discriminator discriminator if polymorphism is used + * @param string[]|null $httpHeaders HTTP headers * * @return object|array|null a single or an array of $class instances */ @@ -473,7 +481,7 @@ public static function deserialize($data, $class, $httpHeaders = null) // determine file name if ( is_array($httpHeaders) - && array_key_exists('Content-Disposition', $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]); @@ -546,22 +554,64 @@ public static function deserialize($data, $class, $httpHeaders = null) } /** - * Native `http_build_query` wrapper. - * @see https://www.php.net/manual/en/function.http-build-query - * - * @param array|object $data May be an array or object containing properties. - * @param string $numeric_prefix If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. - * @param string|null $arg_separator arg_separator.output is used to separate arguments but may be overridden by specifying this parameter. - * @param int $encoding_type Encoding type. By default, PHP_QUERY_RFC1738. - * - * @return string - */ - public static function buildQuery( - $data, - string $numeric_prefix = '', - ?string $arg_separator = null, - int $encoding_type = \PHP_QUERY_RFC3986 - ): string { - return \GuzzleHttp\Psr7\Query::build($data, $encoding_type); + * 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/codegen/Crm/Extensions/Videoconferencing/Api/SettingsApi.php b/codegen/Crm/Extensions/Videoconferencing/Api/SettingsApi.php index bd60232c1..acd477c7b 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Api/SettingsApi.php +++ b/codegen/Crm/Extensions/Videoconferencing/Api/SettingsApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -89,13 +89,13 @@ class SettingsApi * @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, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -183,18 +183,6 @@ public function archiveWithHttpInfo($app_id, string $contentType = self::content $statusCode = $response->getStatusCode(); - 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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -426,18 +414,6 @@ public function getByIdWithHttpInfo($app_id, string $contentType = self::content $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -496,6 +472,19 @@ public function getByIdWithHttpInfo($app_id, string $contentType = self::content ]; } + 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\Crm\Extensions\Videoconferencing\Model\ExternalSettings'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -775,18 +764,6 @@ public function replaceWithHttpInfo($app_id, $external_settings, string $content $statusCode = $response->getStatusCode(); - 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() - ); - } switch($statusCode) { case 200: @@ -845,6 +822,19 @@ public function replaceWithHttpInfo($app_id, $external_settings, string $content ]; } + 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\Crm\Extensions\Videoconferencing\Model\ExternalSettings'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Crm/Extensions/Videoconferencing/ApiException.php b/codegen/Crm/Extensions/Videoconferencing/ApiException.php index b62b36bd7..4dc3622fb 100644 --- a/codegen/Crm/Extensions/Videoconferencing/ApiException.php +++ b/codegen/Crm/Extensions/Videoconferencing/ApiException.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -49,7 +49,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[][]|null */ protected $responseHeaders; @@ -65,7 +65,7 @@ class ApiException extends Exception * * @param string $message Error message * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header + * @param string[][]|null $responseHeaders HTTP response header * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) @@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[][]|null HTTP response header */ public function getResponseHeaders() { diff --git a/codegen/Crm/Extensions/Videoconferencing/Configuration.php b/codegen/Crm/Extensions/Videoconferencing/Configuration.php index 80759829c..ce9cad7d8 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Configuration.php +++ b/codegen/Crm/Extensions/Videoconferencing/Configuration.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -486,7 +486,7 @@ public function getHostSettings() * @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) + public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null) { if (null === $variables) { $variables = []; diff --git a/codegen/Crm/Extensions/Videoconferencing/HeaderSelector.php b/codegen/Crm/Extensions/Videoconferencing/HeaderSelector.php index 8fa9a9276..04cb47ebb 100644 --- a/codegen/Crm/Extensions/Videoconferencing/HeaderSelector.php +++ b/codegen/Crm/Extensions/Videoconferencing/HeaderSelector.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string } # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + $headersWithJson = $this->selectJsonMimeList($accept); if (count($headersWithJson) === 0) { return implode(',', $accept); } @@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string 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 * diff --git a/codegen/Crm/Extensions/Videoconferencing/Model/Error.php b/codegen/Crm/Extensions/Videoconferencing/Model/Error.php index b64363c20..f6d121f0c 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Model/Error.php +++ b/codegen/Crm/Extensions/Videoconferencing/Model/Error.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -275,10 +275,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Videoconferencing/Model/ErrorDetail.php b/codegen/Crm/Extensions/Videoconferencing/Model/ErrorDetail.php index bfa33d103..bdcbee7db 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Model/ErrorDetail.php +++ b/codegen/Crm/Extensions/Videoconferencing/Model/ErrorDetail.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('code', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Videoconferencing/Model/ExternalSettings.php b/codegen/Crm/Extensions/Videoconferencing/Model/ExternalSettings.php index 375bf6145..6384269ed 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Model/ExternalSettings.php +++ b/codegen/Crm/Extensions/Videoconferencing/Model/ExternalSettings.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -264,10 +264,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('user_verify_url', $data ?? [], null); $this->setIfExists('fetch_accounts_uri', $data ?? [], null); diff --git a/codegen/Crm/Extensions/Videoconferencing/Model/ModelInterface.php b/codegen/Crm/Extensions/Videoconferencing/Model/ModelInterface.php index c591eb2d3..7410ca03b 100644 --- a/codegen/Crm/Extensions/Videoconferencing/Model/ModelInterface.php +++ b/codegen/Crm/Extensions/Videoconferencing/Model/ModelInterface.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Crm/Extensions/Videoconferencing/ObjectSerializer.php b/codegen/Crm/Extensions/Videoconferencing/ObjectSerializer.php index 783172781..080d608bc 100644 --- a/codegen/Crm/Extensions/Videoconferencing/ObjectSerializer.php +++ b/codegen/Crm/Extensions/Videoconferencing/ObjectSerializer.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,8 +58,8 @@ public static function setDateTimeFormat($format) * Serialize data * * @param mixed $data the data to serialize - * @param string $type the OpenAPIToolsType of the data - * @param string $format the format of the OpenAPITools type of the data + * @param string|null $type the OpenAPIToolsType of the data + * @param string|null $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ @@ -194,6 +194,10 @@ private static function isEmptyValue($value, string $openApiType): 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; @@ -265,6 +269,11 @@ public static function toQueryValue( $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; } @@ -338,7 +347,7 @@ public static function toFormValue($value) * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|\DateTime $value the value of the parameter + * @param float|int|bool|\DateTime $value the value of the parameter * * @return string the header string */ @@ -395,8 +404,7 @@ public static function serializeCollection(array $collection, $style, $allowColl * * @param mixed $data object or primitive to be deserialized * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * @param string $discriminator discriminator if polymorphism is used + * @param string[]|null $httpHeaders HTTP headers * * @return object|array|null a single or an array of $class instances */ @@ -473,7 +481,7 @@ public static function deserialize($data, $class, $httpHeaders = null) // determine file name if ( is_array($httpHeaders) - && array_key_exists('Content-Disposition', $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]); @@ -546,22 +554,64 @@ public static function deserialize($data, $class, $httpHeaders = null) } /** - * Native `http_build_query` wrapper. - * @see https://www.php.net/manual/en/function.http-build-query - * - * @param array|object $data May be an array or object containing properties. - * @param string $numeric_prefix If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. - * @param string|null $arg_separator arg_separator.output is used to separate arguments but may be overridden by specifying this parameter. - * @param int $encoding_type Encoding type. By default, PHP_QUERY_RFC1738. - * - * @return string - */ - public static function buildQuery( - $data, - string $numeric_prefix = '', - ?string $arg_separator = null, - int $encoding_type = \PHP_QUERY_RFC3986 - ): string { - return \GuzzleHttp\Psr7\Query::build($data, $encoding_type); + * 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) : ''; } }