From b7421a314ccaf8732f4c220f41b040ee2e2ca558 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 16 Apr 2025 16:59:17 +0300 Subject: [PATCH] Codegen: Marketing Transactional --- .../Transactional/Api/PublicSMTPTokensApi.php | 166 +++++++++--------- .../Transactional/Api/SingleSendApi.php | 39 ++-- .../Marketing/Transactional/ApiException.php | 10 +- .../Marketing/Transactional/Configuration.php | 6 +- .../Transactional/HeaderSelector.php | 34 +++- ...nResponseSmtpApiTokenViewForwardPaging.php | 8 +- .../Model/EmailSendStatusView.php | 8 +- .../Marketing/Transactional/Model/Error.php | 8 +- .../Transactional/Model/ErrorDetail.php | 8 +- .../Transactional/Model/EventIdView.php | 8 +- .../Transactional/Model/ForwardPaging.php | 8 +- .../Transactional/Model/ModelInterface.php | 4 +- .../Transactional/Model/NextPage.php | 8 +- .../Model/PublicSingleSendEmail.php | 8 +- .../Model/PublicSingleSendRequestEgg.php | 8 +- .../Model/SmtpApiTokenRequestEgg.php | 8 +- .../Transactional/Model/SmtpApiTokenView.php | 8 +- .../Transactional/ObjectSerializer.php | 100 ++++++++--- 18 files changed, 259 insertions(+), 188 deletions(-) diff --git a/codegen/Marketing/Transactional/Api/PublicSMTPTokensApi.php b/codegen/Marketing/Transactional/Api/PublicSMTPTokensApi.php index 9d3a821ae..dcb357a82 100644 --- a/codegen/Marketing/Transactional/Api/PublicSMTPTokensApi.php +++ b/codegen/Marketing/Transactional/Api/PublicSMTPTokensApi.php @@ -10,13 +10,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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 PublicSMTPTokensApi * @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; } @@ -189,18 +189,6 @@ public function archiveTokenWithHttpInfo($token_id, string $contentType = self:: $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 createTokenWithHttpInfo($smtp_api_token_request_egg, 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 201: @@ -501,6 +477,19 @@ public function createTokenWithHttpInfo($smtp_api_token_request_egg, 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\Marketing\Transactional\Model\SmtpApiTokenView'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -776,18 +765,6 @@ public function getTokenByIdWithHttpInfo($token_id, string $contentType = self:: $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 getTokenByIdWithHttpInfo($token_id, string $contentType = self:: ]; } + 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\Marketing\Transactional\Model\SmtpApiTokenView'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1071,10 +1061,10 @@ public function getTokenByIdRequest($token_id, string $contentType = self::conte * * Query SMTP API tokens by campaign name or an emailCampaignId. * - * @param string $campaign_name A name for the campaign tied to the SMTP API token. (optional) - * @param string $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) - * @param string $after Starting point to get the next set of results. (optional) - * @param int $limit Maximum number of tokens to return. (optional) + * @param string|null $campaign_name A name for the campaign tied to the SMTP API token. (optional) + * @param string|null $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) + * @param string|null $after Starting point to get the next set of results. (optional) + * @param int|null $limit Maximum number of tokens to return. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getTokensPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Marketing\Transactional\ApiException on non-2xx response or if the response body is not in the expected format @@ -1092,10 +1082,10 @@ public function getTokensPage($campaign_name = null, $email_campaign_id = null, * * Query SMTP API tokens by campaign name or an emailCampaignId. * - * @param string $campaign_name A name for the campaign tied to the SMTP API token. (optional) - * @param string $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) - * @param string $after Starting point to get the next set of results. (optional) - * @param int $limit Maximum number of tokens to return. (optional) + * @param string|null $campaign_name A name for the campaign tied to the SMTP API token. (optional) + * @param string|null $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) + * @param string|null $after Starting point to get the next set of results. (optional) + * @param int|null $limit Maximum number of tokens to return. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getTokensPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Marketing\Transactional\ApiException on non-2xx response or if the response body is not in the expected format @@ -1128,18 +1118,6 @@ public function getTokensPageWithHttpInfo($campaign_name = null, $email_campaign $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: @@ -1198,6 +1176,19 @@ public function getTokensPageWithHttpInfo($campaign_name = null, $email_campaign ]; } + 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\Marketing\Transactional\Model\CollectionResponseSmtpApiTokenViewForwardPaging'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -1254,10 +1245,10 @@ public function getTokensPageWithHttpInfo($campaign_name = null, $email_campaign * * Query SMTP API tokens by campaign name or an emailCampaignId. * - * @param string $campaign_name A name for the campaign tied to the SMTP API token. (optional) - * @param string $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) - * @param string $after Starting point to get the next set of results. (optional) - * @param int $limit Maximum number of tokens to return. (optional) + * @param string|null $campaign_name A name for the campaign tied to the SMTP API token. (optional) + * @param string|null $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) + * @param string|null $after Starting point to get the next set of results. (optional) + * @param int|null $limit Maximum number of tokens to return. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getTokensPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1278,10 +1269,10 @@ function ($response) { * * Query SMTP API tokens by campaign name or an emailCampaignId. * - * @param string $campaign_name A name for the campaign tied to the SMTP API token. (optional) - * @param string $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) - * @param string $after Starting point to get the next set of results. (optional) - * @param int $limit Maximum number of tokens to return. (optional) + * @param string|null $campaign_name A name for the campaign tied to the SMTP API token. (optional) + * @param string|null $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) + * @param string|null $after Starting point to get the next set of results. (optional) + * @param int|null $limit Maximum number of tokens to return. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getTokensPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1331,10 +1322,10 @@ function ($exception) { /** * Create request for operation 'getTokensPage' * - * @param string $campaign_name A name for the campaign tied to the SMTP API token. (optional) - * @param string $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) - * @param string $after Starting point to get the next set of results. (optional) - * @param int $limit Maximum number of tokens to return. (optional) + * @param string|null $campaign_name A name for the campaign tied to the SMTP API token. (optional) + * @param string|null $email_campaign_id Identifier assigned to the campaign provided during the token creation. (optional) + * @param string|null $after Starting point to get the next set of results. (optional) + * @param int|null $limit Maximum number of tokens to return. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getTokensPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1508,18 +1499,6 @@ public function resetPasswordWithHttpInfo($token_id, string $contentType = self: $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: @@ -1578,6 +1557,19 @@ public function resetPasswordWithHttpInfo($token_id, string $contentType = self: ]; } + 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\Marketing\Transactional\Model\SmtpApiTokenView'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Marketing/Transactional/Api/SingleSendApi.php b/codegen/Marketing/Transactional/Api/SingleSendApi.php index 6199808e1..7586554d1 100644 --- a/codegen/Marketing/Transactional/Api/SingleSendApi.php +++ b/codegen/Marketing/Transactional/Api/SingleSendApi.php @@ -10,13 +10,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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 SingleSendApi * @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; } @@ -178,18 +178,6 @@ public function sendEmailWithHttpInfo($public_single_send_request_egg, string $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: @@ -248,6 +236,19 @@ public function sendEmailWithHttpInfo($public_single_send_request_egg, string $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\Marketing\Transactional\Model\EmailSendStatusView'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Marketing/Transactional/ApiException.php b/codegen/Marketing/Transactional/ApiException.php index 12b98e742..620bdc1b4 100644 --- a/codegen/Marketing/Transactional/ApiException.php +++ b/codegen/Marketing/Transactional/ApiException.php @@ -10,13 +10,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/Configuration.php b/codegen/Marketing/Transactional/Configuration.php index 4ed6238a6..d764ea7ce 100644 --- a/codegen/Marketing/Transactional/Configuration.php +++ b/codegen/Marketing/Transactional/Configuration.php @@ -10,13 +10,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/HeaderSelector.php b/codegen/Marketing/Transactional/HeaderSelector.php index 99334fead..c8db1b3ad 100644 --- a/codegen/Marketing/Transactional/HeaderSelector.php +++ b/codegen/Marketing/Transactional/HeaderSelector.php @@ -10,13 +10,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/Model/CollectionResponseSmtpApiTokenViewForwardPaging.php b/codegen/Marketing/Transactional/Model/CollectionResponseSmtpApiTokenViewForwardPaging.php index 2fa815105..708ef518d 100644 --- a/codegen/Marketing/Transactional/Model/CollectionResponseSmtpApiTokenViewForwardPaging.php +++ b/codegen/Marketing/Transactional/Model/CollectionResponseSmtpApiTokenViewForwardPaging.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('paging', $data ?? [], null); $this->setIfExists('results', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/EmailSendStatusView.php b/codegen/Marketing/Transactional/Model/EmailSendStatusView.php index ce06412a5..207427840 100644 --- a/codegen/Marketing/Transactional/Model/EmailSendStatusView.php +++ b/codegen/Marketing/Transactional/Model/EmailSendStatusView.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -392,10 +392,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('event_id', $data ?? [], null); $this->setIfExists('completed_at', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/Error.php b/codegen/Marketing/Transactional/Model/Error.php index 2a74a0f7b..4be589260 100644 --- a/codegen/Marketing/Transactional/Model/Error.php +++ b/codegen/Marketing/Transactional/Model/Error.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/Model/ErrorDetail.php b/codegen/Marketing/Transactional/Model/ErrorDetail.php index 55ff9056e..a55cc9779 100644 --- a/codegen/Marketing/Transactional/Model/ErrorDetail.php +++ b/codegen/Marketing/Transactional/Model/ErrorDetail.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/Model/EventIdView.php b/codegen/Marketing/Transactional/Model/EventIdView.php index d7038f9c3..540063985 100644 --- a/codegen/Marketing/Transactional/Model/EventIdView.php +++ b/codegen/Marketing/Transactional/Model/EventIdView.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('created', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/ForwardPaging.php b/codegen/Marketing/Transactional/Model/ForwardPaging.php index 180f95022..ce8a5d9b6 100644 --- a/codegen/Marketing/Transactional/Model/ForwardPaging.php +++ b/codegen/Marketing/Transactional/Model/ForwardPaging.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('next', $data ?? [], null); } diff --git a/codegen/Marketing/Transactional/Model/ModelInterface.php b/codegen/Marketing/Transactional/Model/ModelInterface.php index 0ac74a6d9..6fc892d7e 100644 --- a/codegen/Marketing/Transactional/Model/ModelInterface.php +++ b/codegen/Marketing/Transactional/Model/ModelInterface.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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/Marketing/Transactional/Model/NextPage.php b/codegen/Marketing/Transactional/Model/NextPage.php index 4d55bc3dd..3bc2fb785 100644 --- a/codegen/Marketing/Transactional/Model/NextPage.php +++ b/codegen/Marketing/Transactional/Model/NextPage.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('link', $data ?? [], null); $this->setIfExists('after', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/PublicSingleSendEmail.php b/codegen/Marketing/Transactional/Model/PublicSingleSendEmail.php index 8a03668b9..652c9abca 100644 --- a/codegen/Marketing/Transactional/Model/PublicSingleSendEmail.php +++ b/codegen/Marketing/Transactional/Model/PublicSingleSendEmail.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -270,10 +270,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('cc', $data ?? [], null); $this->setIfExists('send_id', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/PublicSingleSendRequestEgg.php b/codegen/Marketing/Transactional/Model/PublicSingleSendRequestEgg.php index 283dc76f1..d3936b270 100644 --- a/codegen/Marketing/Transactional/Model/PublicSingleSendRequestEgg.php +++ b/codegen/Marketing/Transactional/Model/PublicSingleSendRequestEgg.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('custom_properties', $data ?? [], null); $this->setIfExists('email_id', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/SmtpApiTokenRequestEgg.php b/codegen/Marketing/Transactional/Model/SmtpApiTokenRequestEgg.php index d6e373e70..2c8a20705 100644 --- a/codegen/Marketing/Transactional/Model/SmtpApiTokenRequestEgg.php +++ b/codegen/Marketing/Transactional/Model/SmtpApiTokenRequestEgg.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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('create_contact', $data ?? [], null); $this->setIfExists('campaign_name', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/Model/SmtpApiTokenView.php b/codegen/Marketing/Transactional/Model/SmtpApiTokenView.php index b75fedf01..9448e2aed 100644 --- a/codegen/Marketing/Transactional/Model/SmtpApiTokenView.php +++ b/codegen/Marketing/Transactional/Model/SmtpApiTokenView.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -276,10 +276,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('password', $data ?? [], null); diff --git a/codegen/Marketing/Transactional/ObjectSerializer.php b/codegen/Marketing/Transactional/ObjectSerializer.php index db8aa45d8..b2a820987 100644 --- a/codegen/Marketing/Transactional/ObjectSerializer.php +++ b/codegen/Marketing/Transactional/ObjectSerializer.php @@ -11,13 +11,13 @@ */ /** - * Marketing Transactional Single Send + * Transactional Single Send * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * 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) : ''; } }