From 2fcceff7c5ee4912e509ba87add60261a0f1bed9 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 17 Apr 2025 12:00:30 +0300 Subject: [PATCH] CODEGE --- codegen/Webhooks/Api/SettingsApi.php | 82 +++++----- codegen/Webhooks/Api/SubscriptionsApi.php | 149 +++++++++--------- codegen/Webhooks/ApiException.php | 8 +- codegen/Webhooks/Configuration.php | 4 +- codegen/Webhooks/HeaderSelector.php | 32 +++- ...tchInputSubscriptionBatchUpdateRequest.php | 6 +- .../BatchResponseSubscriptionResponse.php | 6 +- ...ResponseSubscriptionResponseWithErrors.php | 6 +- codegen/Webhooks/Model/Error.php | 6 +- codegen/Webhooks/Model/ErrorDetail.php | 6 +- codegen/Webhooks/Model/ModelInterface.php | 2 +- .../Webhooks/Model/SettingsChangeRequest.php | 6 +- codegen/Webhooks/Model/SettingsResponse.php | 6 +- codegen/Webhooks/Model/StandardError.php | 6 +- .../Model/SubscriptionBatchUpdateRequest.php | 6 +- .../Model/SubscriptionCreateRequest.php | 6 +- .../Model/SubscriptionListResponse.php | 6 +- .../Model/SubscriptionPatchRequest.php | 6 +- .../Webhooks/Model/SubscriptionResponse.php | 6 +- codegen/Webhooks/Model/ThrottlingSettings.php | 6 +- codegen/Webhooks/ObjectSerializer.php | 98 +++++++++--- 21 files changed, 260 insertions(+), 199 deletions(-) diff --git a/codegen/Webhooks/Api/SettingsApi.php b/codegen/Webhooks/Api/SettingsApi.php index 4cd2a201f..e0f002d78 100644 --- a/codegen/Webhooks/Api/SettingsApi.php +++ b/codegen/Webhooks/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 clearWithHttpInfo($app_id, string $contentType = self::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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -373,7 +361,7 @@ public function clearRequest($app_id, string $contentType = self::contentTypes[' /** * Operation configure * - * Delete webhook settings + * Update webhook settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Webhooks\Model\SettingsChangeRequest $settings_change_request settings_change_request (required) @@ -392,7 +380,7 @@ public function configure($app_id, $settings_change_request, string $contentType /** * Operation configureWithHttpInfo * - * Delete webhook settings + * Update webhook settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Webhooks\Model\SettingsChangeRequest $settings_change_request (required) @@ -428,18 +416,6 @@ public function configureWithHttpInfo($app_id, $settings_change_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() - ); - } switch($statusCode) { case 200: @@ -498,6 +474,19 @@ public function configureWithHttpInfo($app_id, $settings_change_request, string ]; } + 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\Webhooks\Model\SettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -552,7 +541,7 @@ public function configureWithHttpInfo($app_id, $settings_change_request, string /** * Operation configureAsync * - * Delete webhook settings + * Update webhook settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Webhooks\Model\SettingsChangeRequest $settings_change_request (required) @@ -574,7 +563,7 @@ function ($response) { /** * Operation configureAsyncWithHttpInfo * - * Delete webhook settings + * Update webhook settings * * @param int $app_id The ID of the app. (required) * @param \HubSpot\Client\Webhooks\Model\SettingsChangeRequest $settings_change_request (required) @@ -792,18 +781,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: @@ -862,6 +839,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\Webhooks\Model\SettingsResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Webhooks/Api/SubscriptionsApi.php b/codegen/Webhooks/Api/SubscriptionsApi.php index 0ee570f9e..e700f706e 100644 --- a/codegen/Webhooks/Api/SubscriptionsApi.php +++ b/codegen/Webhooks/Api/SubscriptionsApi.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 */ /** @@ -98,13 +98,13 @@ class SubscriptionsApi * @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; } @@ -194,18 +194,6 @@ public function archiveWithHttpInfo($subscription_id, $app_id, 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() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -457,18 +445,6 @@ public function createWithHttpInfo($app_id, $subscription_create_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() - ); - } switch($statusCode) { case 201: @@ -527,6 +503,19 @@ public function createWithHttpInfo($app_id, $subscription_create_request, string ]; } + 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\Webhooks\Model\SubscriptionResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -821,18 +810,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: @@ -891,6 +868,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\Webhooks\Model\SubscriptionListResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1170,18 +1160,6 @@ public function getByIdWithHttpInfo($subscription_id, $app_id, 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: @@ -1240,6 +1218,19 @@ public function getByIdWithHttpInfo($subscription_id, $app_id, 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\Webhooks\Model\SubscriptionResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1539,18 +1530,6 @@ public function updateWithHttpInfo($subscription_id, $app_id, $subscription_patc $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: @@ -1609,6 +1588,19 @@ public function updateWithHttpInfo($subscription_id, $app_id, $subscription_patc ]; } + 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\Webhooks\Model\SubscriptionResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1923,18 +1915,6 @@ public function updateBatchWithHttpInfo($app_id, $batch_input_subscription_batch $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: @@ -2020,6 +2000,19 @@ public function updateBatchWithHttpInfo($app_id, $batch_input_subscription_batch ]; } + 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\Webhooks\Model\BatchResponseSubscriptionResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Webhooks/ApiException.php b/codegen/Webhooks/ApiException.php index f343d5c6a..aba1f5887 100644 --- a/codegen/Webhooks/ApiException.php +++ b/codegen/Webhooks/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/Webhooks/Configuration.php b/codegen/Webhooks/Configuration.php index 364157e1d..2a2acc105 100644 --- a/codegen/Webhooks/Configuration.php +++ b/codegen/Webhooks/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/Webhooks/HeaderSelector.php b/codegen/Webhooks/HeaderSelector.php index 8ecce21d9..a3a8e4aad 100644 --- a/codegen/Webhooks/HeaderSelector.php +++ b/codegen/Webhooks/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/Webhooks/Model/BatchInputSubscriptionBatchUpdateRequest.php b/codegen/Webhooks/Model/BatchInputSubscriptionBatchUpdateRequest.php index c9cf9da57..111015069 100644 --- a/codegen/Webhooks/Model/BatchInputSubscriptionBatchUpdateRequest.php +++ b/codegen/Webhooks/Model/BatchInputSubscriptionBatchUpdateRequest.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('inputs', $data ?? [], null); } diff --git a/codegen/Webhooks/Model/BatchResponseSubscriptionResponse.php b/codegen/Webhooks/Model/BatchResponseSubscriptionResponse.php index 76319b27f..e20c6e0c6 100644 --- a/codegen/Webhooks/Model/BatchResponseSubscriptionResponse.php +++ b/codegen/Webhooks/Model/BatchResponseSubscriptionResponse.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 */ /** @@ -288,10 +288,10 @@ public function getStatusAllowableValues() /** * 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('completed_at', $data ?? [], null); $this->setIfExists('requested_at', $data ?? [], null); diff --git a/codegen/Webhooks/Model/BatchResponseSubscriptionResponseWithErrors.php b/codegen/Webhooks/Model/BatchResponseSubscriptionResponseWithErrors.php index 730ba6b1c..3dca8463e 100644 --- a/codegen/Webhooks/Model/BatchResponseSubscriptionResponseWithErrors.php +++ b/codegen/Webhooks/Model/BatchResponseSubscriptionResponseWithErrors.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 */ /** @@ -300,10 +300,10 @@ public function getStatusAllowableValues() /** * 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('completed_at', $data ?? [], null); $this->setIfExists('num_errors', $data ?? [], null); diff --git a/codegen/Webhooks/Model/Error.php b/codegen/Webhooks/Model/Error.php index d08b31442..8a50ad805 100644 --- a/codegen/Webhooks/Model/Error.php +++ b/codegen/Webhooks/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/Webhooks/Model/ErrorDetail.php b/codegen/Webhooks/Model/ErrorDetail.php index 72cf456ea..23d8e6c87 100644 --- a/codegen/Webhooks/Model/ErrorDetail.php +++ b/codegen/Webhooks/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/Webhooks/Model/ModelInterface.php b/codegen/Webhooks/Model/ModelInterface.php index e7d7381ab..057c081aa 100644 --- a/codegen/Webhooks/Model/ModelInterface.php +++ b/codegen/Webhooks/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/Webhooks/Model/SettingsChangeRequest.php b/codegen/Webhooks/Model/SettingsChangeRequest.php index ae5c05e92..d7ac6ebba 100644 --- a/codegen/Webhooks/Model/SettingsChangeRequest.php +++ b/codegen/Webhooks/Model/SettingsChangeRequest.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 */ /** @@ -246,10 +246,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('throttling', $data ?? [], null); $this->setIfExists('target_url', $data ?? [], null); diff --git a/codegen/Webhooks/Model/SettingsResponse.php b/codegen/Webhooks/Model/SettingsResponse.php index 8aa238086..12b1b394c 100644 --- a/codegen/Webhooks/Model/SettingsResponse.php +++ b/codegen/Webhooks/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 */ /** @@ -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('created_at', $data ?? [], null); $this->setIfExists('throttling', $data ?? [], null); diff --git a/codegen/Webhooks/Model/StandardError.php b/codegen/Webhooks/Model/StandardError.php index a910fe3d5..134888f88 100644 --- a/codegen/Webhooks/Model/StandardError.php +++ b/codegen/Webhooks/Model/StandardError.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('sub_category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); diff --git a/codegen/Webhooks/Model/SubscriptionBatchUpdateRequest.php b/codegen/Webhooks/Model/SubscriptionBatchUpdateRequest.php index e2d5df3fb..b9edac5d8 100644 --- a/codegen/Webhooks/Model/SubscriptionBatchUpdateRequest.php +++ b/codegen/Webhooks/Model/SubscriptionBatchUpdateRequest.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('active', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); diff --git a/codegen/Webhooks/Model/SubscriptionCreateRequest.php b/codegen/Webhooks/Model/SubscriptionCreateRequest.php index 17ec4600f..34b58f9c5 100644 --- a/codegen/Webhooks/Model/SubscriptionCreateRequest.php +++ b/codegen/Webhooks/Model/SubscriptionCreateRequest.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 */ /** @@ -363,10 +363,10 @@ public function getEventTypeAllowableValues() /** * 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_type_id', $data ?? [], null); $this->setIfExists('property_name', $data ?? [], null); diff --git a/codegen/Webhooks/Model/SubscriptionListResponse.php b/codegen/Webhooks/Model/SubscriptionListResponse.php index b4b6b9087..3b0e288d2 100644 --- a/codegen/Webhooks/Model/SubscriptionListResponse.php +++ b/codegen/Webhooks/Model/SubscriptionListResponse.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('results', $data ?? [], null); } diff --git a/codegen/Webhooks/Model/SubscriptionPatchRequest.php b/codegen/Webhooks/Model/SubscriptionPatchRequest.php index cccd98be7..71e485b23 100644 --- a/codegen/Webhooks/Model/SubscriptionPatchRequest.php +++ b/codegen/Webhooks/Model/SubscriptionPatchRequest.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('active', $data ?? [], null); } diff --git a/codegen/Webhooks/Model/SubscriptionResponse.php b/codegen/Webhooks/Model/SubscriptionResponse.php index 1dd9fabdd..b55af9f84 100644 --- a/codegen/Webhooks/Model/SubscriptionResponse.php +++ b/codegen/Webhooks/Model/SubscriptionResponse.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 */ /** @@ -381,10 +381,10 @@ public function getEventTypeAllowableValues() /** * 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('object_type_id', $data ?? [], null); diff --git a/codegen/Webhooks/Model/ThrottlingSettings.php b/codegen/Webhooks/Model/ThrottlingSettings.php index 053d2a16d..84a5eab5d 100644 --- a/codegen/Webhooks/Model/ThrottlingSettings.php +++ b/codegen/Webhooks/Model/ThrottlingSettings.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('max_concurrent_requests', $data ?? [], null); } diff --git a/codegen/Webhooks/ObjectSerializer.php b/codegen/Webhooks/ObjectSerializer.php index a2cb6e502..d46e17bab 100644 --- a/codegen/Webhooks/ObjectSerializer.php +++ b/codegen/Webhooks/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) : ''; } }