From f9e87e2402749d406dd66502f7df255ca3db54a0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 23:00:28 +0000 Subject: [PATCH 1/4] Update dependency guzzlehttp/guzzle to v8 --- composer.json | 2 +- examples/EchoBot/composer.json | 2 +- examples/KitchenSink/composer.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 36263d77..f9ed47fe 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require": { "php": "^8.2", "composer-runtime-api": "^2.0", - "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/guzzle": "^8.0", "guzzlehttp/psr7": "^1.7 || ^2.0 || ^3.0" }, "require-dev": { diff --git a/examples/EchoBot/composer.json b/examples/EchoBot/composer.json index cabd54da..8a612811 100644 --- a/examples/EchoBot/composer.json +++ b/examples/EchoBot/composer.json @@ -32,7 +32,7 @@ "slim/psr7": "^1.6", "slim/http": "^1.3", "monolog/monolog": "^3.0.0", - "guzzlehttp/guzzle": "^7.5", + "guzzlehttp/guzzle": "^8.0", "guzzlehttp/psr7": "^3.0", "php-di/slim-bridge": "^3.3", "linecorp/line-bot-sdk": "*" diff --git a/examples/KitchenSink/composer.json b/examples/KitchenSink/composer.json index 5ae7a1d9..9b656aed 100644 --- a/examples/KitchenSink/composer.json +++ b/examples/KitchenSink/composer.json @@ -32,7 +32,7 @@ "slim/psr7": "^1.6", "slim/http": "^1.3", "monolog/monolog": "^3.0.0", - "guzzlehttp/guzzle": "^7.5", + "guzzlehttp/guzzle": "^8.0", "guzzlehttp/psr7": "^3.0", "php-di/slim-bridge": "^3.3", "linecorp/line-bot-sdk": "*" From aa0f9d580b3243aa0adf34a452109c10f87d602a Mon Sep 17 00:00:00 2001 From: Motoi Okuzono Date: Tue, 28 Jul 2026 14:01:38 +0900 Subject: [PATCH 2/4] Support Guzzle 8 while keeping Guzzle 7 compatibility Update the api.pebble template for two Guzzle 8 breaking changes: - Replace GuzzleHttp\Utils::jsonEncode(), removed in Guzzle 8, with native json_encode() using JSON_THROW_ON_ERROR. - Stop calling RequestException::getResponse(), which was moved to ResponseException in Guzzle 8. Catch BadResponseException for error responses instead, which carries the response in both Guzzle 7 and 8, and TransferException for failures without a response such as connection errors (both in sync and async paths). Also widen the guzzlehttp/guzzle constraint to ^7.3 || ^8.0. orchestra/testbench (via laravel/framework, which still requires guzzle ^7.8.2) cannot be installed together with guzzle ^8.0 only, which made composer install unresolvable and broke CI. --- composer.json | 2 +- .../line-bot-sdk-php-generator/api.pebble | 45 +++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index f9ed47fe..89ba76c8 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require": { "php": "^8.2", "composer-runtime-api": "^2.0", - "guzzlehttp/guzzle": "^8.0", + "guzzlehttp/guzzle": "^7.3 || ^8.0", "guzzlehttp/psr7": "^1.7 || ^2.0 || ^3.0" }, "require-dev": { diff --git a/generator/src/main/resources/line-bot-sdk-php-generator/api.pebble b/generator/src/main/resources/line-bot-sdk-php-generator/api.pebble index 5f698585..f18120d4 100644 --- a/generator/src/main/resources/line-bot-sdk-php-generator/api.pebble +++ b/generator/src/main/resources/line-bot-sdk-php-generator/api.pebble @@ -20,8 +20,8 @@ namespace {{ apiPackage }}; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -229,14 +229,15 @@ class {{ operations.classname }} $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -453,17 +454,25 @@ class {{ operations.classname }} {%- endif %} }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -621,7 +630,7 @@ class {{ operations.classname }} if (isset(${{ p.paramName }})) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{ p.paramName }})); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{ p.paramName }}), JSON_THROW_ON_ERROR); } else { $httpBody = ${{ p.paramName }}; } @@ -646,7 +655,7 @@ class {{ operations.classname }} } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); From 30ed03c709f16ff029d39154b18fa084613a8fa0 Mon Sep 17 00:00:00 2001 From: Motoi Okuzono Date: Tue, 28 Jul 2026 14:01:46 +0900 Subject: [PATCH 3/4] Regenerate code Generated by python3 generate-code.py from the updated api.pebble template. No manual edits. --- .../lib/Api/ChannelAccessTokenApi.php | 326 +- src/clients/insight/lib/Api/InsightApi.php | 277 +- src/clients/liff/lib/Api/LiffApi.php | 164 +- .../lib/Api/ManageAudienceApi.php | 404 ++- .../lib/Api/ManageAudienceBlobApi.php | 82 +- .../messaging-api/lib/Api/MessagingApiApi.php | 2706 ++++++++++------- .../lib/Api/MessagingApiBlobApi.php | 201 +- src/webhook/lib/Api/DummyApi.php | 45 +- 8 files changed, 2575 insertions(+), 1630 deletions(-) diff --git a/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php b/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php index 0b50b2cc..9129b39d 100644 --- a/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php +++ b/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -194,14 +194,15 @@ public function getsAllValidChannelAccessTokenKeyIdsWithHttpInfo($clientAssertio $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -314,17 +315,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -411,7 +420,7 @@ public function getsAllValidChannelAccessTokenKeyIdsRequest($clientAssertionType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -478,14 +487,15 @@ public function issueChannelTokenWithHttpInfo($grantType, $clientId, $clientSecr $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -614,17 +624,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -712,7 +730,7 @@ public function issueChannelTokenRequest($grantType, $clientId, $clientSecret, s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -779,14 +797,15 @@ public function issueChannelTokenByJWTWithHttpInfo($grantType, $clientAssertionT $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -901,17 +920,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -999,7 +1026,7 @@ public function issueChannelTokenByJWTRequest($grantType, $clientAssertionType, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1074,14 +1101,15 @@ public function issueStatelessChannelTokenWithHttpInfo($grantType = null, $clien $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1204,17 +1232,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1290,7 +1326,7 @@ public function issueStatelessChannelTokenRequest($grantType = null, $clientAsse } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1322,7 +1358,7 @@ public function issueStatelessChannelTokenRequest($grantType = null, $clientAsse /** * Operation revokeChannelToken * - * @param string $accessToken A short-lived or long-lived channel access token. (required) + * @param string $accessToken Channel access token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \LINE\Clients\ChannelAccessToken\ApiException on non-2xx response or if the response body is not in the expected format @@ -1337,7 +1373,7 @@ public function revokeChannelToken($accessToken, string $contentType = self::con /** * Operation revokeChannelTokenWithHttpInfo * - * @param string $accessToken A short-lived or long-lived channel access token. (required) + * @param string $accessToken Channel access token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \LINE\Clients\ChannelAccessToken\ApiException on non-2xx response or if the response body is not in the expected format @@ -1352,14 +1388,15 @@ public function revokeChannelTokenWithHttpInfo($accessToken, string $contentType $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1384,7 +1421,7 @@ public function revokeChannelTokenWithHttpInfo($accessToken, string $contentType /** * Operation revokeChannelTokenAsync * - * @param string $accessToken A short-lived or long-lived channel access token. (required) + * @param string $accessToken Channel access token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1403,7 +1440,7 @@ function ($response) { /** * Operation revokeChannelTokenAsyncWithHttpInfo * - * @param string $accessToken A short-lived or long-lived channel access token. (required) + * @param string $accessToken Channel access token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1421,17 +1458,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1440,7 +1485,7 @@ function ($exception) { /** * Create request for operation 'revokeChannelToken' * - * @param string $accessToken A short-lived or long-lived channel access token. (required) + * @param string $accessToken Channel access token (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1501,7 +1546,7 @@ public function revokeChannelTokenRequest($accessToken, string $contentType = se } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1567,14 +1612,15 @@ public function revokeChannelTokenByJWTWithHttpInfo($clientId, $clientSecret, $a $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1640,17 +1686,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1738,7 +1792,7 @@ public function revokeChannelTokenByJWTRequest($clientId, $clientSecret, $access } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1801,14 +1855,15 @@ public function verifyChannelTokenWithHttpInfo($accessToken, string $contentType $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1919,17 +1974,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1999,7 +2062,7 @@ public function verifyChannelTokenRequest($accessToken, string $contentType = se } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2062,14 +2125,15 @@ public function verifyChannelTokenByJWTWithHttpInfo($accessToken, string $conten $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2180,17 +2244,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2260,7 +2332,7 @@ public function verifyChannelTokenByJWTRequest($accessToken, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/insight/lib/Api/InsightApi.php b/src/clients/insight/lib/Api/InsightApi.php index 773e7d37..2b66b53e 100644 --- a/src/clients/insight/lib/Api/InsightApi.php +++ b/src/clients/insight/lib/Api/InsightApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -187,14 +187,15 @@ public function getFriendsDemographicsWithHttpInfo(string $contentType = self::c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -303,17 +304,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -366,7 +375,7 @@ public function getFriendsDemographicsRequest(string $contentType = self::conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -437,14 +446,15 @@ public function getMessageEventWithHttpInfo($requestId, string $contentType = se $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -559,17 +569,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -642,7 +660,7 @@ public function getMessageEventRequest($requestId, string $contentType = self::c } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -713,14 +731,15 @@ public function getNumberOfFollowersWithHttpInfo($date = null, string $contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -835,17 +854,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -918,7 +945,7 @@ public function getNumberOfFollowersRequest($date = null, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -989,14 +1016,15 @@ public function getNumberOfMessageDeliveriesWithHttpInfo($date, string $contentT $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1111,17 +1139,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1200,7 +1236,7 @@ public function getNumberOfMessageDeliveriesRequest($date, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1275,14 +1311,15 @@ public function getRichMenuInsightDailyWithHttpInfo($richMenuId, $from, $to, str $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1429,17 +1466,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1560,7 +1605,7 @@ public function getRichMenuInsightDailyRequest($richMenuId, $from, $to, string $ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1635,14 +1680,15 @@ public function getRichMenuInsightSummaryWithHttpInfo($richMenuId, $from, $to, s $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1789,17 +1835,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1920,7 +1974,7 @@ public function getRichMenuInsightSummaryRequest($richMenuId, $from, $to, string } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1991,14 +2045,15 @@ public function getStatisticsPerUnitWithHttpInfo($customAggregationUnit, $from, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2113,17 +2168,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2254,7 +2317,7 @@ public function getStatisticsPerUnitRequest($customAggregationUnit, $from, $to, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/liff/lib/Api/LiffApi.php b/src/clients/liff/lib/Api/LiffApi.php index a8321980..7fbb1fd2 100644 --- a/src/clients/liff/lib/Api/LiffApi.php +++ b/src/clients/liff/lib/Api/LiffApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -184,14 +184,15 @@ public function addLIFFAppWithHttpInfo($addLiffAppRequest, string $contentType = $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -306,17 +307,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -363,7 +372,7 @@ public function addLIFFAppRequest($addLiffAppRequest, string $contentType = self if (isset($addLiffAppRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($addLiffAppRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($addLiffAppRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $addLiffAppRequest; } @@ -384,7 +393,7 @@ public function addLIFFAppRequest($addLiffAppRequest, string $contentType = self } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -454,14 +463,15 @@ public function deleteLIFFAppWithHttpInfo($liffId, string $contentType = self::c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -527,17 +537,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -606,7 +624,7 @@ public function deleteLIFFAppRequest($liffId, string $contentType = self::conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -675,14 +693,15 @@ public function getAllLIFFAppsWithHttpInfo(string $contentType = self::contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -795,17 +814,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -858,7 +885,7 @@ public function getAllLIFFAppsRequest(string $contentType = self::contentTypes[' } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -930,14 +957,15 @@ public function updateLIFFAppWithHttpInfo($liffId, $updateLiffAppRequest, string $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1005,17 +1033,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1078,7 +1114,7 @@ public function updateLIFFAppRequest($liffId, $updateLiffAppRequest, string $con if (isset($updateLiffAppRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($updateLiffAppRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($updateLiffAppRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $updateLiffAppRequest; } @@ -1099,7 +1135,7 @@ public function updateLIFFAppRequest($liffId, $updateLiffAppRequest, string $con } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/manage-audience/lib/Api/ManageAudienceApi.php b/src/clients/manage-audience/lib/Api/ManageAudienceApi.php index 99ee26c2..2cf656ef 100644 --- a/src/clients/manage-audience/lib/Api/ManageAudienceApi.php +++ b/src/clients/manage-audience/lib/Api/ManageAudienceApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -197,14 +197,15 @@ public function addAudienceToAudienceGroupWithHttpInfo($addAudienceToAudienceGro $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -266,17 +267,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -323,7 +332,7 @@ public function addAudienceToAudienceGroupRequest($addAudienceToAudienceGroupReq if (isset($addAudienceToAudienceGroupRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($addAudienceToAudienceGroupRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($addAudienceToAudienceGroupRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $addAudienceToAudienceGroupRequest; } @@ -344,7 +353,7 @@ public function addAudienceToAudienceGroupRequest($addAudienceToAudienceGroupReq } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -411,14 +420,15 @@ public function createAudienceGroupWithHttpInfo($createAudienceGroupRequest, str $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -529,17 +539,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -586,7 +604,7 @@ public function createAudienceGroupRequest($createAudienceGroupRequest, string $ if (isset($createAudienceGroupRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($createAudienceGroupRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($createAudienceGroupRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $createAudienceGroupRequest; } @@ -607,7 +625,7 @@ public function createAudienceGroupRequest($createAudienceGroupRequest, string $ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -674,14 +692,15 @@ public function createClickBasedAudienceGroupWithHttpInfo($createClickBasedAudie $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -792,17 +811,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -849,7 +876,7 @@ public function createClickBasedAudienceGroupRequest($createClickBasedAudienceGr if (isset($createClickBasedAudienceGroupRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($createClickBasedAudienceGroupRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($createClickBasedAudienceGroupRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $createClickBasedAudienceGroupRequest; } @@ -870,7 +897,7 @@ public function createClickBasedAudienceGroupRequest($createClickBasedAudienceGr } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -937,14 +964,15 @@ public function createImpBasedAudienceGroupWithHttpInfo($createImpBasedAudienceG $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1055,17 +1083,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1112,7 +1148,7 @@ public function createImpBasedAudienceGroupRequest($createImpBasedAudienceGroupR if (isset($createImpBasedAudienceGroupRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($createImpBasedAudienceGroupRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($createImpBasedAudienceGroupRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $createImpBasedAudienceGroupRequest; } @@ -1133,7 +1169,7 @@ public function createImpBasedAudienceGroupRequest($createImpBasedAudienceGroupR } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1199,14 +1235,15 @@ public function deleteAudienceGroupWithHttpInfo($audienceGroupId, string $conten $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1268,17 +1305,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1347,7 +1392,7 @@ public function deleteAudienceGroupRequest($audienceGroupId, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1414,14 +1459,15 @@ public function getAudienceDataWithHttpInfo($audienceGroupId, string $contentTyp $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1546,17 +1592,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1625,7 +1679,7 @@ public function getAudienceDataRequest($audienceGroupId, string $contentType = s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1702,14 +1756,15 @@ public function getAudienceGroupsWithHttpInfo($page, $description = null, $statu $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1830,17 +1885,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1971,7 +2034,7 @@ public function getAudienceGroupsRequest($page, $description = null, $status = n } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2038,14 +2101,15 @@ public function getSharedAudienceDataWithHttpInfo($audienceGroupId, string $cont $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2170,17 +2234,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2249,7 +2321,7 @@ public function getSharedAudienceDataRequest($audienceGroupId, string $contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2326,14 +2398,15 @@ public function getSharedAudienceGroupsWithHttpInfo($page, $description = null, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2454,17 +2527,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2595,7 +2676,7 @@ public function getSharedAudienceGroupsRequest($page, $description = null, $stat } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2663,14 +2744,15 @@ public function updateAudienceGroupDescriptionWithHttpInfo($audienceGroupId, $up $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2734,17 +2816,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2807,7 +2897,7 @@ public function updateAudienceGroupDescriptionRequest($audienceGroupId, $updateA if (isset($updateAudienceGroupDescriptionRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($updateAudienceGroupDescriptionRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($updateAudienceGroupDescriptionRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $updateAudienceGroupDescriptionRequest; } @@ -2828,7 +2918,7 @@ public function updateAudienceGroupDescriptionRequest($audienceGroupId, $updateA } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/manage-audience/lib/Api/ManageAudienceBlobApi.php b/src/clients/manage-audience/lib/Api/ManageAudienceBlobApi.php index 18c0eef7..8f5cc8a3 100644 --- a/src/clients/manage-audience/lib/Api/ManageAudienceBlobApi.php +++ b/src/clients/manage-audience/lib/Api/ManageAudienceBlobApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -189,14 +189,15 @@ public function addUserIdsToAudienceWithHttpInfo($file, $audienceGroupId = null, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -274,17 +275,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -367,7 +376,7 @@ public function addUserIdsToAudienceRequest($file, $audienceGroupId = null, $upl } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -477,14 +486,15 @@ public function createAudienceForUploadingUserIdsWithHttpInfo($file, $descriptio $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -613,17 +623,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -712,7 +730,7 @@ public function createAudienceForUploadingUserIdsRequest($file, $description = n } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/messaging-api/lib/Api/MessagingApiApi.php b/src/clients/messaging-api/lib/Api/MessagingApiApi.php index f6817f1a..cdda606c 100644 --- a/src/clients/messaging-api/lib/Api/MessagingApiApi.php +++ b/src/clients/messaging-api/lib/Api/MessagingApiApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -374,14 +374,15 @@ public function broadcastWithHttpInfo($broadcastRequest, $xLineRetryKey = null, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -550,17 +551,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -613,7 +622,7 @@ public function broadcastRequest($broadcastRequest, $xLineRetryKey = null, strin if (isset($broadcastRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($broadcastRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($broadcastRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $broadcastRequest; } @@ -634,7 +643,7 @@ public function broadcastRequest($broadcastRequest, $xLineRetryKey = null, strin } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -698,14 +707,15 @@ public function cancelDefaultRichMenuWithHttpInfo(string $contentType = self::co $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -765,17 +775,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -828,7 +846,7 @@ public function cancelDefaultRichMenuRequest(string $contentType = self::content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -894,14 +912,15 @@ public function closeCouponWithHttpInfo($couponId, string $contentType = self::c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -987,17 +1006,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1066,7 +1093,7 @@ public function closeCouponRequest($couponId, string $contentType = self::conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1133,14 +1160,15 @@ public function createCouponWithHttpInfo($couponCreateRequest = null, string $co $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1265,17 +1293,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1316,7 +1352,7 @@ public function createCouponRequest($couponCreateRequest = null, string $content if (isset($couponCreateRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($couponCreateRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($couponCreateRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $couponCreateRequest; } @@ -1337,7 +1373,7 @@ public function createCouponRequest($couponCreateRequest = null, string $content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1404,14 +1440,15 @@ public function createRichMenuWithHttpInfo($richMenuRequest, string $contentType $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1522,17 +1559,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1579,7 +1624,7 @@ public function createRichMenuRequest($richMenuRequest, string $contentType = se if (isset($richMenuRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuRequest; } @@ -1600,7 +1645,7 @@ public function createRichMenuRequest($richMenuRequest, string $contentType = se } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1666,14 +1711,15 @@ public function createRichMenuAliasWithHttpInfo($createRichMenuAliasRequest, str $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1743,17 +1789,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1800,7 +1854,7 @@ public function createRichMenuAliasRequest($createRichMenuAliasRequest, string $ if (isset($createRichMenuAliasRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($createRichMenuAliasRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($createRichMenuAliasRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $createRichMenuAliasRequest; } @@ -1821,7 +1875,7 @@ public function createRichMenuAliasRequest($createRichMenuAliasRequest, string $ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1887,14 +1941,15 @@ public function deleteRichMenuWithHttpInfo($richMenuId, string $contentType = se $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1956,17 +2011,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2035,7 +2098,7 @@ public function deleteRichMenuRequest($richMenuId, string $contentType = self::c } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2101,14 +2164,15 @@ public function deleteRichMenuAliasWithHttpInfo($richMenuAliasId, string $conten $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2178,17 +2242,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2257,7 +2329,7 @@ public function deleteRichMenuAliasRequest($richMenuAliasId, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2326,14 +2398,15 @@ public function getAggregationUnitNameListWithHttpInfo($limit = null, $start = n $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2446,17 +2519,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2531,7 +2612,7 @@ public function getAggregationUnitNameListRequest($limit = null, $start = null, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2596,14 +2677,15 @@ public function getAggregationUnitUsageWithHttpInfo(string $contentType = self:: $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2712,17 +2794,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -2775,7 +2865,7 @@ public function getAggregationUnitUsageRequest(string $contentType = self::conte } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2840,14 +2930,15 @@ public function getBotInfoWithHttpInfo(string $contentType = self::contentTypes[ $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -2956,17 +3047,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -3019,7 +3118,7 @@ public function getBotInfoRequest(string $contentType = self::contentTypes['getB } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3086,14 +3185,15 @@ public function getCouponDetailWithHttpInfo($couponId, string $contentType = sel $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -3232,17 +3332,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -3311,7 +3419,7 @@ public function getCouponDetailRequest($couponId, string $contentType = self::co } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3376,14 +3484,15 @@ public function getDefaultRichMenuIdWithHttpInfo(string $contentType = self::con $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -3492,17 +3601,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -3555,7 +3672,7 @@ public function getDefaultRichMenuIdRequest(string $contentType = self::contentT } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3624,14 +3741,15 @@ public function getFollowersWithHttpInfo($start = null, $limit = 300, string $co $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -3744,17 +3862,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -3832,7 +3958,7 @@ public function getFollowersRequest($start = null, $limit = 300, string $content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3899,14 +4025,15 @@ public function getGroupMemberCountWithHttpInfo($groupId, string $contentType = $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -4017,17 +4144,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -4096,7 +4231,7 @@ public function getGroupMemberCountRequest($groupId, string $contentType = self: } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4165,14 +4300,15 @@ public function getGroupMemberProfileWithHttpInfo($groupId, $userId, string $con $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -4285,17 +4421,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -4380,7 +4524,7 @@ public function getGroupMemberProfileRequest($groupId, $userId, string $contentT } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4449,14 +4593,15 @@ public function getGroupMembersIdsWithHttpInfo($groupId, $start = null, string $ $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -4569,17 +4714,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -4659,7 +4812,7 @@ public function getGroupMembersIdsRequest($groupId, $start = null, string $conte } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4726,14 +4879,15 @@ public function getGroupSummaryWithHttpInfo($groupId, string $contentType = self $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -4844,17 +4998,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -4923,7 +5085,7 @@ public function getGroupSummaryRequest($groupId, string $contentType = self::con } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4994,14 +5156,15 @@ public function getJoinedMembershipUsersWithHttpInfo($membershipId, $start = nul $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -5144,17 +5307,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -5251,7 +5422,7 @@ public function getJoinedMembershipUsersRequest($membershipId, $start = null, $l } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5316,14 +5487,15 @@ public function getMembershipListWithHttpInfo(string $contentType = self::conten $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -5446,17 +5618,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -5509,7 +5689,7 @@ public function getMembershipListRequest(string $contentType = self::contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5576,14 +5756,15 @@ public function getMembershipSubscriptionWithHttpInfo($userId, string $contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -5722,17 +5903,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -5801,7 +5990,7 @@ public function getMembershipSubscriptionRequest($userId, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5866,14 +6055,15 @@ public function getMessageQuotaWithHttpInfo(string $contentType = self::contentT $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -5982,17 +6172,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -6045,7 +6243,7 @@ public function getMessageQuotaRequest(string $contentType = self::contentTypes[ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6110,14 +6308,15 @@ public function getMessageQuotaConsumptionWithHttpInfo(string $contentType = sel $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -6226,17 +6425,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -6289,7 +6496,7 @@ public function getMessageQuotaConsumptionRequest(string $contentType = self::co } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6356,14 +6563,15 @@ public function getNarrowcastProgressWithHttpInfo($requestId, string $contentTyp $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -6474,17 +6682,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -6554,7 +6770,7 @@ public function getNarrowcastProgressRequest($requestId, string $contentType = s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6621,14 +6837,15 @@ public function getNumberOfSentBroadcastMessagesWithHttpInfo($date, string $cont $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -6739,17 +6956,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -6819,7 +7044,7 @@ public function getNumberOfSentBroadcastMessagesRequest($date, string $contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6886,14 +7111,15 @@ public function getNumberOfSentMulticastMessagesWithHttpInfo($date, string $cont $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -7004,17 +7230,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -7084,7 +7318,7 @@ public function getNumberOfSentMulticastMessagesRequest($date, string $contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7151,14 +7385,15 @@ public function getNumberOfSentPushMessagesWithHttpInfo($date, string $contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -7269,17 +7504,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -7349,7 +7592,7 @@ public function getNumberOfSentPushMessagesRequest($date, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7416,14 +7659,15 @@ public function getNumberOfSentReplyMessagesWithHttpInfo($date, string $contentT $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -7534,17 +7778,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -7614,7 +7866,7 @@ public function getNumberOfSentReplyMessagesRequest($date, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7681,14 +7933,15 @@ public function getPNPMessageStatisticsWithHttpInfo($date, string $contentType = $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -7799,17 +8052,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -7882,7 +8143,7 @@ public function getPNPMessageStatisticsRequest($date, string $contentType = self } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7949,14 +8210,15 @@ public function getProfileWithHttpInfo($userId, string $contentType = self::cont $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -8067,17 +8329,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -8146,7 +8416,7 @@ public function getProfileRequest($userId, string $contentType = self::contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -8213,14 +8483,15 @@ public function getRichMenuWithHttpInfo($richMenuId, string $contentType = self: $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -8331,17 +8602,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -8410,7 +8689,7 @@ public function getRichMenuRequest($richMenuId, string $contentType = self::cont } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -8477,14 +8756,15 @@ public function getRichMenuAliasWithHttpInfo($richMenuAliasId, string $contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -8595,17 +8875,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -8674,7 +8962,7 @@ public function getRichMenuAliasRequest($richMenuAliasId, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -8739,14 +9027,15 @@ public function getRichMenuAliasListWithHttpInfo(string $contentType = self::con $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -8855,17 +9144,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -8918,7 +9215,7 @@ public function getRichMenuAliasListRequest(string $contentType = self::contentT } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -8985,14 +9282,15 @@ public function getRichMenuBatchProgressWithHttpInfo($requestId, string $content $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -9103,17 +9401,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -9183,7 +9489,7 @@ public function getRichMenuBatchProgressRequest($requestId, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -9250,14 +9556,15 @@ public function getRichMenuIdOfUserWithHttpInfo($userId, string $contentType = s $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -9368,17 +9675,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -9447,7 +9762,7 @@ public function getRichMenuIdOfUserRequest($userId, string $contentType = self:: } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -9512,14 +9827,15 @@ public function getRichMenuListWithHttpInfo(string $contentType = self::contentT $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -9628,17 +9944,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -9691,7 +10015,7 @@ public function getRichMenuListRequest(string $contentType = self::contentTypes[ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -9758,14 +10082,15 @@ public function getRoomMemberCountWithHttpInfo($roomId, string $contentType = se $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -9876,17 +10201,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -9955,7 +10288,7 @@ public function getRoomMemberCountRequest($roomId, string $contentType = self::c } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -10024,14 +10357,15 @@ public function getRoomMemberProfileWithHttpInfo($roomId, $userId, string $conte $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -10144,17 +10478,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -10239,7 +10581,7 @@ public function getRoomMemberProfileRequest($roomId, $userId, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -10308,14 +10650,15 @@ public function getRoomMembersIdsWithHttpInfo($roomId, $start = null, string $co $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -10428,17 +10771,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -10518,7 +10869,7 @@ public function getRoomMembersIdsRequest($roomId, $start = null, string $content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -10583,14 +10934,15 @@ public function getWebhookEndpointWithHttpInfo(string $contentType = self::conte $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -10699,17 +11051,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -10762,7 +11122,7 @@ public function getWebhookEndpointRequest(string $contentType = self::contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -10829,14 +11189,15 @@ public function issueLinkTokenWithHttpInfo($userId, string $contentType = self:: $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -10947,17 +11308,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -11026,7 +11395,7 @@ public function issueLinkTokenRequest($userId, string $contentType = self::conte } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -11092,14 +11461,15 @@ public function leaveGroupWithHttpInfo($groupId, string $contentType = self::con $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -11177,17 +11547,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -11256,7 +11634,7 @@ public function leaveGroupRequest($groupId, string $contentType = self::contentT } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -11322,14 +11700,15 @@ public function leaveRoomWithHttpInfo($roomId, string $contentType = self::conte $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -11391,17 +11770,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -11470,7 +11857,7 @@ public function leaveRoomRequest($roomId, string $contentType = self::contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -11538,14 +11925,15 @@ public function linkRichMenuIdToUserWithHttpInfo($userId, $richMenuId, string $c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -11609,17 +11997,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -11704,7 +12100,7 @@ public function linkRichMenuIdToUserRequest($userId, $richMenuId, string $conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -11770,14 +12166,15 @@ public function linkRichMenuIdToUsersWithHttpInfo($richMenuBulkLinkRequest, stri $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -11839,17 +12236,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -11896,7 +12301,7 @@ public function linkRichMenuIdToUsersRequest($richMenuBulkLinkRequest, string $c if (isset($richMenuBulkLinkRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuBulkLinkRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuBulkLinkRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuBulkLinkRequest; } @@ -11917,7 +12322,7 @@ public function linkRichMenuIdToUsersRequest($richMenuBulkLinkRequest, string $c } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -11988,14 +12393,15 @@ public function listCouponWithHttpInfo($status = null, $start = null, $limit = 2 $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -12124,17 +12530,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -12226,7 +12640,7 @@ public function listCouponRequest($status = null, $start = null, $limit = 20, st } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -12292,14 +12706,15 @@ public function markMessagesAsReadWithHttpInfo($markMessagesAsReadRequest, strin $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -12361,17 +12776,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -12418,7 +12841,7 @@ public function markMessagesAsReadRequest($markMessagesAsReadRequest, string $co if (isset($markMessagesAsReadRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($markMessagesAsReadRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($markMessagesAsReadRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $markMessagesAsReadRequest; } @@ -12439,7 +12862,7 @@ public function markMessagesAsReadRequest($markMessagesAsReadRequest, string $co } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -12505,14 +12928,15 @@ public function markMessagesAsReadByTokenWithHttpInfo($markMessagesAsReadByToken $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -12582,17 +13006,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -12639,7 +13071,7 @@ public function markMessagesAsReadByTokenRequest($markMessagesAsReadByTokenReque if (isset($markMessagesAsReadByTokenRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($markMessagesAsReadByTokenRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($markMessagesAsReadByTokenRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $markMessagesAsReadByTokenRequest; } @@ -12660,7 +13092,7 @@ public function markMessagesAsReadByTokenRequest($markMessagesAsReadByTokenReque } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -12729,14 +13161,15 @@ public function multicastWithHttpInfo($multicastRequest, $xLineRetryKey = null, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -12905,17 +13338,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -12968,7 +13409,7 @@ public function multicastRequest($multicastRequest, $xLineRetryKey = null, strin if (isset($multicastRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($multicastRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($multicastRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $multicastRequest; } @@ -12989,7 +13430,7 @@ public function multicastRequest($multicastRequest, $xLineRetryKey = null, strin } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -13058,14 +13499,15 @@ public function narrowcastWithHttpInfo($narrowcastRequest, $xLineRetryKey = null $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -13234,17 +13676,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -13297,7 +13747,7 @@ public function narrowcastRequest($narrowcastRequest, $xLineRetryKey = null, str if (isset($narrowcastRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($narrowcastRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($narrowcastRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $narrowcastRequest; } @@ -13318,7 +13768,7 @@ public function narrowcastRequest($narrowcastRequest, $xLineRetryKey = null, str } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -13387,14 +13837,15 @@ public function pushMessageWithHttpInfo($pushMessageRequest, $xLineRetryKey = nu $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -13563,17 +14014,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -13626,7 +14085,7 @@ public function pushMessageRequest($pushMessageRequest, $xLineRetryKey = null, s if (isset($pushMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pushMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pushMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $pushMessageRequest; } @@ -13647,7 +14106,7 @@ public function pushMessageRequest($pushMessageRequest, $xLineRetryKey = null, s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -13715,14 +14174,15 @@ public function pushMessagesByPhoneWithHttpInfo($pnpMessagesRequest, $xLineDeliv $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -13794,17 +14254,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -13863,7 +14331,7 @@ public function pushMessagesByPhoneRequest($pnpMessagesRequest, $xLineDeliveryTa if (isset($pnpMessagesRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pnpMessagesRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pnpMessagesRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $pnpMessagesRequest; } @@ -13884,7 +14352,7 @@ public function pushMessagesByPhoneRequest($pnpMessagesRequest, $xLineDeliveryTa } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -13951,14 +14419,15 @@ public function replyMessageWithHttpInfo($replyMessageRequest, string $contentTy $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -14097,17 +14566,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -14154,7 +14631,7 @@ public function replyMessageRequest($replyMessageRequest, string $contentType = if (isset($replyMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($replyMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($replyMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $replyMessageRequest; } @@ -14175,7 +14652,7 @@ public function replyMessageRequest($replyMessageRequest, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -14241,14 +14718,15 @@ public function richMenuBatchWithHttpInfo($richMenuBatchRequest, string $content $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -14310,17 +14788,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -14367,7 +14853,7 @@ public function richMenuBatchRequest($richMenuBatchRequest, string $contentType if (isset($richMenuBatchRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuBatchRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuBatchRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuBatchRequest; } @@ -14388,7 +14874,7 @@ public function richMenuBatchRequest($richMenuBatchRequest, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -14454,14 +14940,15 @@ public function setDefaultRichMenuWithHttpInfo($richMenuId, string $contentType $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -14523,17 +15010,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -14602,7 +15097,7 @@ public function setDefaultRichMenuRequest($richMenuId, string $contentType = sel } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -14668,14 +15163,15 @@ public function setWebhookEndpointWithHttpInfo($setWebhookEndpointRequest, strin $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -14737,17 +15233,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -14794,7 +15298,7 @@ public function setWebhookEndpointRequest($setWebhookEndpointRequest, string $co if (isset($setWebhookEndpointRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($setWebhookEndpointRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($setWebhookEndpointRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $setWebhookEndpointRequest; } @@ -14815,7 +15319,7 @@ public function setWebhookEndpointRequest($setWebhookEndpointRequest, string $co } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -14882,14 +15386,15 @@ public function showLoadingAnimationWithHttpInfo($showLoadingAnimationRequest, s $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -15014,17 +15519,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -15071,7 +15584,7 @@ public function showLoadingAnimationRequest($showLoadingAnimationRequest, string if (isset($showLoadingAnimationRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($showLoadingAnimationRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($showLoadingAnimationRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $showLoadingAnimationRequest; } @@ -15092,7 +15605,7 @@ public function showLoadingAnimationRequest($showLoadingAnimationRequest, string } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -15159,14 +15672,15 @@ public function testWebhookEndpointWithHttpInfo($testWebhookEndpointRequest = nu $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -15277,17 +15791,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -15328,7 +15850,7 @@ public function testWebhookEndpointRequest($testWebhookEndpointRequest = null, s if (isset($testWebhookEndpointRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($testWebhookEndpointRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($testWebhookEndpointRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $testWebhookEndpointRequest; } @@ -15349,7 +15871,7 @@ public function testWebhookEndpointRequest($testWebhookEndpointRequest = null, s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -15415,14 +15937,15 @@ public function unlinkRichMenuIdFromUserWithHttpInfo($userId, string $contentTyp $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -15484,17 +16007,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -15563,7 +16094,7 @@ public function unlinkRichMenuIdFromUserRequest($userId, string $contentType = s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -15629,14 +16160,15 @@ public function unlinkRichMenuIdFromUsersWithHttpInfo($richMenuBulkUnlinkRequest $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -15698,17 +16230,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -15755,7 +16295,7 @@ public function unlinkRichMenuIdFromUsersRequest($richMenuBulkUnlinkRequest, str if (isset($richMenuBulkUnlinkRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuBulkUnlinkRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuBulkUnlinkRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuBulkUnlinkRequest; } @@ -15776,7 +16316,7 @@ public function unlinkRichMenuIdFromUsersRequest($richMenuBulkUnlinkRequest, str } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -15844,14 +16384,15 @@ public function updateRichMenuAliasWithHttpInfo($richMenuAliasId, $updateRichMen $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -15923,17 +16464,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -15996,7 +16545,7 @@ public function updateRichMenuAliasRequest($richMenuAliasId, $updateRichMenuAlia if (isset($updateRichMenuAliasRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($updateRichMenuAliasRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($updateRichMenuAliasRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $updateRichMenuAliasRequest; } @@ -16017,7 +16566,7 @@ public function updateRichMenuAliasRequest($richMenuAliasId, $updateRichMenuAlia } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -16083,14 +16632,15 @@ public function validateBroadcastWithHttpInfo($validateMessageRequest, string $c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -16152,17 +16702,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -16209,7 +16767,7 @@ public function validateBroadcastRequest($validateMessageRequest, string $conten if (isset($validateMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $validateMessageRequest; } @@ -16230,7 +16788,7 @@ public function validateBroadcastRequest($validateMessageRequest, string $conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -16296,14 +16854,15 @@ public function validateMulticastWithHttpInfo($validateMessageRequest, string $c $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -16365,17 +16924,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -16422,7 +16989,7 @@ public function validateMulticastRequest($validateMessageRequest, string $conten if (isset($validateMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $validateMessageRequest; } @@ -16443,7 +17010,7 @@ public function validateMulticastRequest($validateMessageRequest, string $conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -16509,14 +17076,15 @@ public function validateNarrowcastWithHttpInfo($validateMessageRequest, string $ $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -16578,17 +17146,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -16635,7 +17211,7 @@ public function validateNarrowcastRequest($validateMessageRequest, string $conte if (isset($validateMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $validateMessageRequest; } @@ -16656,7 +17232,7 @@ public function validateNarrowcastRequest($validateMessageRequest, string $conte } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -16722,14 +17298,15 @@ public function validatePushWithHttpInfo($validateMessageRequest, string $conten $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -16791,17 +17368,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -16848,7 +17433,7 @@ public function validatePushRequest($validateMessageRequest, string $contentType if (isset($validateMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $validateMessageRequest; } @@ -16869,7 +17454,7 @@ public function validatePushRequest($validateMessageRequest, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -16935,14 +17520,15 @@ public function validateReplyWithHttpInfo($validateMessageRequest, string $conte $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -17004,17 +17590,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -17061,7 +17655,7 @@ public function validateReplyRequest($validateMessageRequest, string $contentTyp if (isset($validateMessageRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($validateMessageRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $validateMessageRequest; } @@ -17082,7 +17676,7 @@ public function validateReplyRequest($validateMessageRequest, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -17148,14 +17742,15 @@ public function validateRichMenuBatchRequestWithHttpInfo($richMenuBatchRequest, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -17217,17 +17812,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -17274,7 +17877,7 @@ public function validateRichMenuBatchRequestRequest($richMenuBatchRequest, strin if (isset($richMenuBatchRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuBatchRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuBatchRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuBatchRequest; } @@ -17295,7 +17898,7 @@ public function validateRichMenuBatchRequestRequest($richMenuBatchRequest, strin } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -17361,14 +17964,15 @@ public function validateRichMenuObjectWithHttpInfo($richMenuRequest, string $con $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -17430,17 +18034,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -17487,7 +18099,7 @@ public function validateRichMenuObjectRequest($richMenuRequest, string $contentT if (isset($richMenuRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($richMenuRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($richMenuRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $richMenuRequest; } @@ -17508,7 +18120,7 @@ public function validateRichMenuObjectRequest($richMenuRequest, string $contentT } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/clients/messaging-api/lib/Api/MessagingApiBlobApi.php b/src/clients/messaging-api/lib/Api/MessagingApiBlobApi.php index f52ac64e..cd2e9457 100644 --- a/src/clients/messaging-api/lib/Api/MessagingApiBlobApi.php +++ b/src/clients/messaging-api/lib/Api/MessagingApiBlobApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -195,14 +195,15 @@ public function getMessageContentWithHttpInfo($messageId, ?int $hostIndex = null $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -325,17 +326,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -410,7 +419,7 @@ public function getMessageContentRequest($messageId, ?int $hostIndex = null, arr } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -514,14 +523,15 @@ public function getMessageContentPreviewWithHttpInfo($messageId, ?int $hostIndex $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -644,17 +654,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -729,7 +747,7 @@ public function getMessageContentPreviewRequest($messageId, ?int $hostIndex = nu } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -833,14 +851,15 @@ public function getMessageContentTranscodingByMessageIdWithHttpInfo($messageId, $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -963,17 +982,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1048,7 +1075,7 @@ public function getMessageContentTranscodingByMessageIdRequest($messageId, ?int } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1152,14 +1179,15 @@ public function getRichMenuImageWithHttpInfo($richMenuId, ?int $hostIndex = null $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1282,17 +1310,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1367,7 +1403,7 @@ public function getRichMenuImageRequest($richMenuId, ?int $hostIndex = null, arr } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1472,14 +1508,15 @@ public function setRichMenuImageWithHttpInfo($richMenuId, $body, ?int $hostIndex $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1555,17 +1592,25 @@ 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)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -1634,7 +1679,7 @@ public function setRichMenuImageRequest($richMenuId, $body, ?int $hostIndex = nu if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); } else { $httpBody = $body; } @@ -1655,7 +1700,7 @@ public function setRichMenuImageRequest($richMenuId, $body, ?int $hostIndex = nu } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/src/webhook/lib/Api/DummyApi.php b/src/webhook/lib/Api/DummyApi.php index 1f33daf1..0e4062e5 100644 --- a/src/webhook/lib/Api/DummyApi.php +++ b/src/webhook/lib/Api/DummyApi.php @@ -41,8 +41,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -171,14 +171,15 @@ public function callbackWithHttpInfo($callbackRequest, string $contentType = sel $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (BadResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + $response->getHeaders(), + (string) $response->getBody() ); - } catch (ConnectException $e) { + } catch (TransferException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -289,17 +290,25 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof BadResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() + $response->getHeaders(), + (string) $response->getBody() + ); + } + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + (int) $exception->getCode(), + null, + null ); } ); @@ -346,7 +355,7 @@ public function callbackRequest($callbackRequest, string $contentType = self::co if (isset($callbackRequest)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($callbackRequest)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($callbackRequest), JSON_THROW_ON_ERROR); } else { $httpBody = $callbackRequest; } @@ -367,7 +376,7 @@ public function callbackRequest($callbackRequest, string $contentType = self::co } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); From 55acb611b625c30333eba8fde05073edf8e876bc Mon Sep 17 00:00:00 2001 From: Motoi Okuzono Date: Tue, 28 Jul 2026 14:01:53 +0900 Subject: [PATCH 4/4] Update line-openapi submodule and regenerate code The generate-code workflow regenerates against the latest line-openapi (git submodule update --remote), so this PR fails that check while the pinned submodule is behind. Pull in line/line-openapi@de8bd9e (Fix access_token description in revokeChannelToken, line/line-openapi#130), which replaces the closed auto-generated update PR #879. The resulting diff is doc comments only. --- line-openapi | 2 +- .../lib/Api/ChannelAccessTokenApi.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/line-openapi b/line-openapi index 99df56b7..de8bd9e2 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit 99df56b76bf1b8a8268456fa36c2d1538b4c086c +Subproject commit de8bd9e2872ed9d9800e23b86136695fcd370a0c diff --git a/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php b/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php index 9129b39d..e5e5c735 100644 --- a/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php +++ b/src/clients/channel-access-token/lib/Api/ChannelAccessTokenApi.php @@ -1358,7 +1358,7 @@ public function issueStatelessChannelTokenRequest($grantType = null, $clientAsse /** * Operation revokeChannelToken * - * @param string $accessToken Channel access token (required) + * @param string $accessToken A short-lived or long-lived channel access token. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \LINE\Clients\ChannelAccessToken\ApiException on non-2xx response or if the response body is not in the expected format @@ -1373,7 +1373,7 @@ public function revokeChannelToken($accessToken, string $contentType = self::con /** * Operation revokeChannelTokenWithHttpInfo * - * @param string $accessToken Channel access token (required) + * @param string $accessToken A short-lived or long-lived channel access token. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \LINE\Clients\ChannelAccessToken\ApiException on non-2xx response or if the response body is not in the expected format @@ -1421,7 +1421,7 @@ public function revokeChannelTokenWithHttpInfo($accessToken, string $contentType /** * Operation revokeChannelTokenAsync * - * @param string $accessToken Channel access token (required) + * @param string $accessToken A short-lived or long-lived channel access token. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1440,7 +1440,7 @@ function ($response) { /** * Operation revokeChannelTokenAsyncWithHttpInfo * - * @param string $accessToken Channel access token (required) + * @param string $accessToken A short-lived or long-lived channel access token. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1485,7 +1485,7 @@ function ($exception) { /** * Create request for operation 'revokeChannelToken' * - * @param string $accessToken Channel access token (required) + * @param string $accessToken A short-lived or long-lived channel access token. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['revokeChannelToken'] to see the possible values for this operation * * @throws \InvalidArgumentException