diff --git a/fern/pages/changelogs/php-sdk/2025-02-07.mdx b/fern/pages/changelogs/php-sdk/2025-02-07.mdx new file mode 100644 index 00000000000..3e06a3da027 --- /dev/null +++ b/fern/pages/changelogs/php-sdk/2025-02-07.mdx @@ -0,0 +1,3 @@ +## 0.5.0 +**`(feat):`** Add the `__toString()` magic method to all generated class types. + diff --git a/fern/pages/changelogs/ts-express/2025-02-06.mdx b/fern/pages/changelogs/ts-express/2025-02-07.mdx similarity index 100% rename from fern/pages/changelogs/ts-express/2025-02-06.mdx rename to fern/pages/changelogs/ts-express/2025-02-07.mdx diff --git a/generators/browser-compatible-base/src/ast/Argument.ts b/generators/browser-compatible-base/src/ast/Argument.ts index a1a88cb4fe0..26ec76aed21 100644 --- a/generators/browser-compatible-base/src/ast/Argument.ts +++ b/generators/browser-compatible-base/src/ast/Argument.ts @@ -6,7 +6,7 @@ export type Arguments = NamedArgument[] | UnnamedArgument[]; export interface NamedArgument { name: string; - assignment: AbstractAstNode; + assignment: AbstractAstNode | string; } export type UnnamedArgument = AbstractAstNode; diff --git a/generators/csharp/codegen/src/ast/ClassInstantiation.ts b/generators/csharp/codegen/src/ast/ClassInstantiation.ts index 3fcf4dd30ac..595e0535600 100644 --- a/generators/csharp/codegen/src/ast/ClassInstantiation.ts +++ b/generators/csharp/codegen/src/ast/ClassInstantiation.ts @@ -46,7 +46,7 @@ export class ClassInstantiation extends AstNode { this.arguments_.forEach((argument, idx) => { if (isNamedArgument(argument)) { writer.write(`${argument.name} = `); - argument.assignment.write(writer); + writer.writeNodeOrString(argument.assignment); } else { argument.write(writer); } diff --git a/generators/go-v2/ast/src/ast/utils/writeArguments.ts b/generators/go-v2/ast/src/ast/utils/writeArguments.ts index ab1061779f4..a7e1211a64c 100644 --- a/generators/go-v2/ast/src/ast/utils/writeArguments.ts +++ b/generators/go-v2/ast/src/ast/utils/writeArguments.ts @@ -22,7 +22,7 @@ export function writeArguments({ writer, arguments_ }: { writer: Writer; argumen function writeArgument({ writer, argument }: { writer: Writer; argument: Argument }): void { if (isNamedArgument(argument)) { - argument.assignment.write(writer); + writer.writeNodeOrString(argument.assignment); } else { argument.write(writer); } diff --git a/generators/php/codegen/src/ast/utils/writeArguments.ts b/generators/php/codegen/src/ast/utils/writeArguments.ts index 09a41b9ee2f..3ac564159ac 100644 --- a/generators/php/codegen/src/ast/utils/writeArguments.ts +++ b/generators/php/codegen/src/ast/utils/writeArguments.ts @@ -47,7 +47,7 @@ function writeCompact({ writer, arguments_ }: { writer: Writer; arguments_: Argu function writeArgument({ writer, argument }: { writer: Writer; argument: Argument }): void { if (isNamedArgument(argument)) { writer.write(`${argument.name}: `); - argument.assignment.write(writer); + writer.writeNodeOrString(argument.assignment); } else { argument.write(writer); } diff --git a/generators/php/codegen/src/php.ts b/generators/php/codegen/src/php.ts index c692df7f580..ece38d4f58e 100644 --- a/generators/php/codegen/src/php.ts +++ b/generators/php/codegen/src/php.ts @@ -64,6 +64,13 @@ export function invokeMethod(args: MethodInvocation.Args): MethodInvocation { return new MethodInvocation(args); } +export function throwException(args: ClassInstantiation.Args): AstNode { + return codeblock((writer) => { + writer.write("throw "); + writer.writeNode(instantiateClass(args)); + }); +} + export function map(args: Map.Args): Map { return new Map(args); } @@ -92,6 +99,10 @@ export function variable(name: string): AstNode { return codeblock(convertToPhpVariableName(name)); } +export function string(stringValue: string): AstNode { + return codeblock(`"${stringValue}"`); +} + export function mergeArrays(...args: MergeArrays.Args): MergeArrays { return new MergeArrays(args); } diff --git a/generators/php/sdk/src/endpoint/http/HttpEndpointGenerator.ts b/generators/php/sdk/src/endpoint/http/HttpEndpointGenerator.ts index f6cedb49b62..2163c5f931f 100644 --- a/generators/php/sdk/src/endpoint/http/HttpEndpointGenerator.ts +++ b/generators/php/sdk/src/endpoint/http/HttpEndpointGenerator.ts @@ -99,6 +99,49 @@ export class HttpEndpointGenerator extends AbstractEndpointGenerator { } writer.dedent(); writer.write("} catch ("); + writer.writeNode(this.context.guzzleClient.getRequestExceptionClassReference()); + writer.writeLine(" $e) {"); + writer.indent(); + writer.writeNodeStatement(php.assignVariable(php.variable("response"), "$e->getResponse()")); + writer.controlFlow("if", php.codeblock("$response === null")); + writer.writeNodeStatement( + php.throwException({ + classReference: this.context.getBaseExceptionClassReference(), + arguments_: [ + { + name: "message", + assignment: "$e->getMessage()" + }, + { + name: "previous", + assignment: php.variable("e") + } + ] + }) + ); + writer.endControlFlow(); + writer.writeNodeStatement( + php.throwException({ + classReference: this.context.getBaseApiExceptionClassReference(), + arguments_: [ + { + name: "message", + assignment: php.string("API request failed") + }, + { + name: "statusCode", + assignment: "$response->getStatusCode()" + }, + { + name: "body", + assignment: "$response->getBody()->getContents()" + } + ], + multiline: true + }) + ); + writer.dedent(); + writer.write("} catch ("); writer.writeNode(this.context.getClientExceptionInterfaceClassReference()); writer.writeLine(" $e) {"); writer.indent(); diff --git a/generators/php/sdk/src/external/GuzzleClient.ts b/generators/php/sdk/src/external/GuzzleClient.ts index 1892b4142a3..4a388180e5a 100644 --- a/generators/php/sdk/src/external/GuzzleClient.ts +++ b/generators/php/sdk/src/external/GuzzleClient.ts @@ -6,9 +6,11 @@ import { SdkGeneratorContext } from "../SdkGeneratorContext"; * The Guzzle HTTP client. */ export class GuzzleClient { - public static NAMESPACE = "GuzzleHttp"; - public static CLIENT_CLASS_NAME = "Client"; - public static CLIENT_INTERFACE_CLASS_NAME = "ClientInterface"; + public static readonly NAMESPACE = "GuzzleHttp"; + public static readonly EXCEPTION_NAMESPACE = "GuzzleHttp\\Exception"; + public static readonly CLIENT_CLASS_NAME = "Client"; + public static readonly CLIENT_INTERFACE_CLASS_NAME = "ClientInterface"; + public static readonly REQUEST_EXCEPTION_CLASS_NAME = "RequestException"; private context: SdkGeneratorContext; @@ -30,6 +32,13 @@ export class GuzzleClient { }); } + public getRequestExceptionClassReference(): php.ClassReference { + return php.classReference({ + name: GuzzleClient.REQUEST_EXCEPTION_CLASS_NAME, + namespace: GuzzleClient.EXCEPTION_NAMESPACE + }); + } + public instantiate(): php.ClassInstantiation { return php.instantiateClass({ classReference: this.getClientClassReference(), diff --git a/generators/php/sdk/versions.yml b/generators/php/sdk/versions.yml index f5ddc1450b9..055e594558d 100644 --- a/generators/php/sdk/versions.yml +++ b/generators/php/sdk/versions.yml @@ -1,8 +1,16 @@ +- version: 0.5.1 + changelogEntry: + - type: fix + summary: >- + Catch HTTP request exceptions and rethrow it as a FooApiException. + irVersion: 55 + - version: 0.5.0 changelogEntry: - type: feat summary: >- Add the `__toString()` magic method to all generated class types. + irVersion: 55 - version: 0.4.0 changelogEntry: @@ -28,8 +36,8 @@ $httpClient = new Client(['handler' => $handlerStack]); $client = new FooClient(['client' => $client]); ``` - irVersion: 55 + - version: 0.3.2 changelogEntry: - type: internal diff --git a/seed/php-sdk/accept-header/src/Service/ServiceClient.php b/seed/php-sdk/accept-header/src/Service/ServiceClient.php index 97a233503a8..3c424ba0ea0 100644 --- a/seed/php-sdk/accept-header/src/Service/ServiceClient.php +++ b/seed/php-sdk/accept-header/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -68,6 +69,16 @@ public function endpoint(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/alias-extends/src/SeedClient.php b/seed/php-sdk/alias-extends/src/SeedClient.php index 9ca45feac7c..949ce2b17f1 100644 --- a/seed/php-sdk/alias-extends/src/SeedClient.php +++ b/seed/php-sdk/alias-extends/src/SeedClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -83,6 +84,16 @@ public function extendedInlineRequestBody(InlinedChildRequest $request, ?array $ if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/alias/src/SeedClient.php b/seed/php-sdk/alias/src/SeedClient.php index 92c46abe114..de997a75fbf 100644 --- a/seed/php-sdk/alias/src/SeedClient.php +++ b/seed/php-sdk/alias/src/SeedClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -81,6 +82,16 @@ public function get(string $typeId, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/any-auth/src/Auth/AuthClient.php b/seed/php-sdk/any-auth/src/Auth/AuthClient.php index efce4e31b87..47dea73530c 100644 --- a/seed/php-sdk/any-auth/src/Auth/AuthClient.php +++ b/seed/php-sdk/any-auth/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class AuthClient @@ -77,6 +78,16 @@ public function getToken(GetTokenRequest $request, ?array $options = null): Toke } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/any-auth/src/User/UserClient.php b/seed/php-sdk/any-auth/src/User/UserClient.php index 78c468c9283..e9609740718 100644 --- a/seed/php-sdk/any-auth/src/User/UserClient.php +++ b/seed/php-sdk/any-auth/src/User/UserClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -75,6 +76,16 @@ public function get(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/api-wide-base-path/src/Service/ServiceClient.php b/seed/php-sdk/api-wide-base-path/src/Service/ServiceClient.php index bc30cef61f0..c25a8cdc38d 100644 --- a/seed/php-sdk/api-wide-base-path/src/Service/ServiceClient.php +++ b/seed/php-sdk/api-wide-base-path/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -72,6 +73,16 @@ public function post(string $pathParam, string $serviceParam, string $resourcePa if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/audiences/src/FolderA/Service/ServiceClient.php b/seed/php-sdk/audiences/src/FolderA/Service/ServiceClient.php index 032655d4c31..d100e5e5661 100644 --- a/seed/php-sdk/audiences/src/FolderA/Service/ServiceClient.php +++ b/seed/php-sdk/audiences/src/FolderA/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -74,6 +75,16 @@ public function getDirectThread(?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/audiences/src/FolderD/Service/ServiceClient.php b/seed/php-sdk/audiences/src/FolderD/Service/ServiceClient.php index df160553721..4c93f4cc501 100644 --- a/seed/php-sdk/audiences/src/FolderD/Service/ServiceClient.php +++ b/seed/php-sdk/audiences/src/FolderD/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -74,6 +75,16 @@ public function getDirectThread(?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/audiences/src/Foo/FooClient.php b/seed/php-sdk/audiences/src/Foo/FooClient.php index 5999952c5c5..6b8bf771167 100644 --- a/seed/php-sdk/audiences/src/Foo/FooClient.php +++ b/seed/php-sdk/audiences/src/Foo/FooClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class FooClient @@ -82,6 +83,16 @@ public function find(FindRequest $request, ?array $options = null): ImportingTyp } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/auth-environment-variables/src/Service/ServiceClient.php b/seed/php-sdk/auth-environment-variables/src/Service/ServiceClient.php index 134601b2355..3ba43f2a85d 100644 --- a/seed/php-sdk/auth-environment-variables/src/Service/ServiceClient.php +++ b/seed/php-sdk/auth-environment-variables/src/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Service\Requests\HeaderAuthRequest; @@ -77,6 +78,16 @@ public function getWithApiKey(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -121,6 +132,16 @@ public function getWithHeader(HeaderAuthRequest $request, ?array $options = null } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/basic-auth-environment-variables/src/BasicAuth/BasicAuthClient.php b/seed/php-sdk/basic-auth-environment-variables/src/BasicAuth/BasicAuthClient.php index d9f0adb69a0..6f196de429c 100644 --- a/seed/php-sdk/basic-auth-environment-variables/src/BasicAuth/BasicAuthClient.php +++ b/seed/php-sdk/basic-auth-environment-variables/src/BasicAuth/BasicAuthClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class BasicAuthClient @@ -76,6 +77,16 @@ public function getWithBasicAuth(?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function postWithBasicAuth(mixed $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/basic-auth/src/BasicAuth/BasicAuthClient.php b/seed/php-sdk/basic-auth/src/BasicAuth/BasicAuthClient.php index d9f0adb69a0..6f196de429c 100644 --- a/seed/php-sdk/basic-auth/src/BasicAuth/BasicAuthClient.php +++ b/seed/php-sdk/basic-auth/src/BasicAuth/BasicAuthClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class BasicAuthClient @@ -76,6 +77,16 @@ public function getWithBasicAuth(?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function postWithBasicAuth(mixed $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/bearer-token-environment-variable/src/Service/ServiceClient.php b/seed/php-sdk/bearer-token-environment-variable/src/Service/ServiceClient.php index 707b8d0e9cc..1ca8bdd8be8 100644 --- a/seed/php-sdk/bearer-token-environment-variable/src/Service/ServiceClient.php +++ b/seed/php-sdk/bearer-token-environment-variable/src/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -76,6 +77,16 @@ public function getWithBearerToken(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/bytes/src/Service/ServiceClient.php b/seed/php-sdk/bytes/src/Service/ServiceClient.php index 2f991d00746..0f0b7fcc149 100644 --- a/seed/php-sdk/bytes/src/Service/ServiceClient.php +++ b/seed/php-sdk/bytes/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -68,6 +69,16 @@ public function upload(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/cross-package-type-names/src/FolderA/Service/ServiceClient.php b/seed/php-sdk/cross-package-type-names/src/FolderA/Service/ServiceClient.php index 032655d4c31..d100e5e5661 100644 --- a/seed/php-sdk/cross-package-type-names/src/FolderA/Service/ServiceClient.php +++ b/seed/php-sdk/cross-package-type-names/src/FolderA/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -74,6 +75,16 @@ public function getDirectThread(?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/cross-package-type-names/src/FolderD/Service/ServiceClient.php b/seed/php-sdk/cross-package-type-names/src/FolderD/Service/ServiceClient.php index 649f31236e4..1ab55ee7b2a 100644 --- a/seed/php-sdk/cross-package-type-names/src/FolderD/Service/ServiceClient.php +++ b/seed/php-sdk/cross-package-type-names/src/FolderD/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -74,6 +75,16 @@ public function getDirectThread(?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/cross-package-type-names/src/Foo/FooClient.php b/seed/php-sdk/cross-package-type-names/src/Foo/FooClient.php index 5999952c5c5..6b8bf771167 100644 --- a/seed/php-sdk/cross-package-type-names/src/Foo/FooClient.php +++ b/seed/php-sdk/cross-package-type-names/src/Foo/FooClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class FooClient @@ -82,6 +83,16 @@ public function find(FindRequest $request, ?array $options = null): ImportingTyp } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/custom-auth/src/CustomAuth/CustomAuthClient.php b/seed/php-sdk/custom-auth/src/CustomAuth/CustomAuthClient.php index 949d04b1c0d..62ce43ce270 100644 --- a/seed/php-sdk/custom-auth/src/CustomAuth/CustomAuthClient.php +++ b/seed/php-sdk/custom-auth/src/CustomAuth/CustomAuthClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class CustomAuthClient @@ -76,6 +77,16 @@ public function getWithCustomAuth(?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function postWithCustomAuth(mixed $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/enum/src/InlinedRequest/InlinedRequestClient.php b/seed/php-sdk/enum/src/InlinedRequest/InlinedRequestClient.php index 0282a0dbeba..abf01a1f80b 100644 --- a/seed/php-sdk/enum/src/InlinedRequest/InlinedRequestClient.php +++ b/seed/php-sdk/enum/src/InlinedRequest/InlinedRequestClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class InlinedRequestClient @@ -71,6 +72,16 @@ public function send(SendEnumInlinedRequest $request, ?array $options = null): v if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/enum/src/PathParam/PathParamClient.php b/seed/php-sdk/enum/src/PathParam/PathParamClient.php index 5b7384975a2..7e47a32f165 100644 --- a/seed/php-sdk/enum/src/PathParam/PathParamClient.php +++ b/seed/php-sdk/enum/src/PathParam/PathParamClient.php @@ -10,6 +10,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PathParamClient @@ -72,6 +73,16 @@ public function send(string $operand, string $operandOrColor, ?array $options = if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/enum/src/QueryParam/QueryParamClient.php b/seed/php-sdk/enum/src/QueryParam/QueryParamClient.php index 9500b8ea2d4..0b6cf10d5f3 100644 --- a/seed/php-sdk/enum/src/QueryParam/QueryParamClient.php +++ b/seed/php-sdk/enum/src/QueryParam/QueryParamClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\QueryParam\Requests\SendEnumListAsQueryParamRequest; @@ -81,6 +82,16 @@ public function send(SendEnumAsQueryParamRequest $request, ?array $options = nul if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -126,6 +137,16 @@ public function sendList(SendEnumListAsQueryParamRequest $request, ?array $optio if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/error-property/src/PropertyBasedError/PropertyBasedErrorClient.php b/seed/php-sdk/error-property/src/PropertyBasedError/PropertyBasedErrorClient.php index bbc7137191e..f68434e4b30 100644 --- a/seed/php-sdk/error-property/src/PropertyBasedError/PropertyBasedErrorClient.php +++ b/seed/php-sdk/error-property/src/PropertyBasedError/PropertyBasedErrorClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PropertyBasedErrorClient @@ -76,6 +77,16 @@ public function throwError(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/examples/src/File/Notification/Service/ServiceClient.php b/seed/php-sdk/examples/src/File/Notification/Service/ServiceClient.php index e6ab32158ac..2f97fc97850 100644 --- a/seed/php-sdk/examples/src/File/Notification/Service/ServiceClient.php +++ b/seed/php-sdk/examples/src/File/Notification/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -75,6 +76,16 @@ public function getException(string $notificationId, ?array $options = null): mi } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/examples/src/File/Service/ServiceClient.php b/seed/php-sdk/examples/src/File/Service/ServiceClient.php index 9389a54d589..a8dab139a61 100644 --- a/seed/php-sdk/examples/src/File/Service/ServiceClient.php +++ b/seed/php-sdk/examples/src/File/Service/ServiceClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -82,6 +83,16 @@ public function getFile(string $filename, GetFileRequest $request, ?array $optio } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/examples/src/Health/Service/ServiceClient.php b/seed/php-sdk/examples/src/Health/Service/ServiceClient.php index 54611940e27..9022eb5d88f 100644 --- a/seed/php-sdk/examples/src/Health/Service/ServiceClient.php +++ b/seed/php-sdk/examples/src/Health/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Core\Json\JsonDecoder; use JsonException; @@ -73,6 +74,16 @@ public function check(string $id, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -113,6 +124,16 @@ public function ping(?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/examples/src/SeedClient.php b/seed/php-sdk/examples/src/SeedClient.php index 73cccbb2939..24f57339d21 100644 --- a/seed/php-sdk/examples/src/SeedClient.php +++ b/seed/php-sdk/examples/src/SeedClient.php @@ -13,6 +13,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Types\BasicType; use Seed\Types\ComplexType; @@ -118,6 +119,16 @@ public function echo_(string $request, ?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -158,6 +169,16 @@ public function createType(string $request, ?array $options = null): Identifier } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/examples/src/Service/ServiceClient.php b/seed/php-sdk/examples/src/Service/ServiceClient.php index 0fad92ae5bf..fdf6899c47f 100644 --- a/seed/php-sdk/examples/src/Service/ServiceClient.php +++ b/seed/php-sdk/examples/src/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Core\Json\JsonDecoder; use Seed\Service\Requests\GetMetadataRequest; @@ -79,6 +80,16 @@ public function getMovie(string $movieId, ?array $options = null): Movie } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function createMovie(Movie $request, ?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -169,6 +190,16 @@ public function getMetadata(GetMetadataRequest $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -209,6 +240,16 @@ public function createBigEntity(BigEntity $request, ?array $options = null): Res } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Container/ContainerClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Container/ContainerClient.php index 3f1ede42929..e4c4adb417c 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Container/ContainerClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Container/ContainerClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonSerializer; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Types\Object\Types\ObjectWithRequiredField; @@ -78,6 +79,16 @@ public function getAndReturnListOfPrimitives(array $request, ?array $options = n } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function getAndReturnListOfObjects(array $request, ?array $options = null } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -158,6 +179,16 @@ public function getAndReturnSetOfPrimitives(array $request, ?array $options = nu } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -198,6 +229,16 @@ public function getAndReturnSetOfObjects(array $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -238,6 +279,16 @@ public function getAndReturnMapPrimToPrim(array $request, ?array $options = null } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -278,6 +329,16 @@ public function getAndReturnMapOfPrimToObject(array $request, ?array $options = } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -321,6 +382,16 @@ public function getAndReturnOptional(?ObjectWithRequiredField $request = null, ? } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/ContentType/ContentTypeClient.php b/seed/php-sdk/exhaustive/src/Endpoints/ContentType/ContentTypeClient.php index 3d7b7ed4819..1a4f7b3b511 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/ContentType/ContentTypeClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/ContentType/ContentTypeClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ContentTypeClient @@ -71,6 +72,16 @@ public function postJsonPatchContentType(ObjectWithOptionalField $request, ?arra if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -107,6 +118,16 @@ public function postJsonPatchContentWithCharsetType(ObjectWithOptionalField $req if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Enum/EnumClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Enum/EnumClient.php index 7f224572e7a..bf795599b05 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Enum/EnumClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Enum/EnumClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class EnumClient @@ -77,6 +78,16 @@ public function getAndReturnEnum(string $request, ?array $options = null): strin } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/HttpMethods/HttpMethodsClient.php b/seed/php-sdk/exhaustive/src/Endpoints/HttpMethods/HttpMethodsClient.php index 332ce039e64..c5449714254 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/HttpMethods/HttpMethodsClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/HttpMethods/HttpMethodsClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Types\Object\Types\ObjectWithRequiredField; use Seed\Types\Object\Types\ObjectWithOptionalField; @@ -77,6 +78,16 @@ public function testGet(string $id, ?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -117,6 +128,16 @@ public function testPost(ObjectWithRequiredField $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -158,6 +179,16 @@ public function testPut(string $id, ObjectWithRequiredField $request, ?array $op } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -199,6 +230,16 @@ public function testPatch(string $id, ObjectWithOptionalField $request, ?array $ } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -238,6 +279,16 @@ public function testDelete(string $id, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Object/ObjectClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Object/ObjectClient.php index 2469f71bed5..7a07ec74543 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Object/ObjectClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Object/ObjectClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Types\Object\Types\ObjectWithRequiredField; use Seed\Types\Object\Types\ObjectWithMapOfMap; @@ -81,6 +82,16 @@ public function getAndReturnWithOptionalField(ObjectWithOptionalField $request, } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -121,6 +132,16 @@ public function getAndReturnWithRequiredField(ObjectWithRequiredField $request, } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -161,6 +182,16 @@ public function getAndReturnWithMapOfMap(ObjectWithMapOfMap $request, ?array $op } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -201,6 +232,16 @@ public function getAndReturnNestedWithOptionalField(NestedObjectWithOptionalFiel } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -242,6 +283,16 @@ public function getAndReturnNestedWithRequiredField(string $string, NestedObject } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -282,6 +333,16 @@ public function getAndReturnNestedWithRequiredFieldAsList(array $request, ?array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Params/ParamsClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Params/ParamsClient.php index d54c7dc47f9..e5034754235 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Params/ParamsClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Params/ParamsClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Endpoints\Params\Requests\GetWithInlinePath; use Seed\Endpoints\Params\Requests\GetWithQuery; @@ -83,6 +84,16 @@ public function getWithPath(string $param, ?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -125,6 +136,16 @@ public function getWithInlinePath(string $param, GetWithInlinePath $request, ?ar } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -166,6 +187,16 @@ public function getWithQuery(GetWithQuery $request, ?array $options = null): voi if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -207,6 +238,16 @@ public function getWithAllowMultipleQuery(GetWithMultipleQuery $request, ?array if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -248,6 +289,16 @@ public function getWithPathAndQuery(string $param, GetWithPathAndQuery $request, if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -289,6 +340,16 @@ public function getWithInlinePathAndQuery(string $param, GetWithInlinePathAndQue if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -332,6 +393,16 @@ public function modifyWithPath(string $param, string $request, ?array $options = } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -375,6 +446,16 @@ public function modifyWithInlinePath(string $param, ModifyResourceAtInlinedPath } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Primitive/PrimitiveClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Primitive/PrimitiveClient.php index 0163a50fa88..d5aa3a5f90c 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Primitive/PrimitiveClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Primitive/PrimitiveClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use DateTime; use Seed\Core\Json\JsonSerializer; @@ -78,6 +79,16 @@ public function getAndReturnString(string $request, ?array $options = null): str } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function getAndReturnInt(int $request, ?array $options = null): int } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -158,6 +179,16 @@ public function getAndReturnLong(int $request, ?array $options = null): int } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -198,6 +229,16 @@ public function getAndReturnDouble(float $request, ?array $options = null): floa } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -238,6 +279,16 @@ public function getAndReturnBool(bool $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -278,6 +329,16 @@ public function getAndReturnDatetime(DateTime $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -318,6 +379,16 @@ public function getAndReturnDate(DateTime $request, ?array $options = null): Dat } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -358,6 +429,16 @@ public function getAndReturnUuid(string $request, ?array $options = null): strin } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -398,6 +479,16 @@ public function getAndReturnBase64(string $request, ?array $options = null): str } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/Endpoints/Union/UnionClient.php b/seed/php-sdk/exhaustive/src/Endpoints/Union/UnionClient.php index 3bafa75da04..39447b10df5 100644 --- a/seed/php-sdk/exhaustive/src/Endpoints/Union/UnionClient.php +++ b/seed/php-sdk/exhaustive/src/Endpoints/Union/UnionClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UnionClient @@ -76,6 +77,16 @@ public function getAndReturnUnion(mixed $request, ?array $options = null): mixed } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/InlinedRequests/InlinedRequestsClient.php b/seed/php-sdk/exhaustive/src/InlinedRequests/InlinedRequestsClient.php index 644460019a8..2b314111f97 100644 --- a/seed/php-sdk/exhaustive/src/InlinedRequests/InlinedRequestsClient.php +++ b/seed/php-sdk/exhaustive/src/InlinedRequests/InlinedRequestsClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class InlinedRequestsClient @@ -79,6 +80,16 @@ public function postWithObjectBodyandResponse(PostWithObjectBody $request, ?arra } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/NoAuth/NoAuthClient.php b/seed/php-sdk/exhaustive/src/NoAuth/NoAuthClient.php index cf644822efc..d4a172492f7 100644 --- a/seed/php-sdk/exhaustive/src/NoAuth/NoAuthClient.php +++ b/seed/php-sdk/exhaustive/src/NoAuth/NoAuthClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class NoAuthClient @@ -78,6 +79,16 @@ public function postWithNoAuth(mixed $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/NoReqBody/NoReqBodyClient.php b/seed/php-sdk/exhaustive/src/NoReqBody/NoReqBodyClient.php index e9d45610094..9e3729fb50b 100644 --- a/seed/php-sdk/exhaustive/src/NoReqBody/NoReqBodyClient.php +++ b/seed/php-sdk/exhaustive/src/NoReqBody/NoReqBodyClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Core\Json\JsonDecoder; @@ -75,6 +76,16 @@ public function getWithNoRequestBody(?array $options = null): ObjectWithOptional } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -113,6 +124,16 @@ public function postWithNoRequestBody(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/exhaustive/src/ReqWithHeaders/ReqWithHeadersClient.php b/seed/php-sdk/exhaustive/src/ReqWithHeaders/ReqWithHeadersClient.php index 6c0ec0bb661..53727729eb3 100644 --- a/seed/php-sdk/exhaustive/src/ReqWithHeaders/ReqWithHeadersClient.php +++ b/seed/php-sdk/exhaustive/src/ReqWithHeaders/ReqWithHeadersClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ReqWithHeadersClient @@ -75,6 +76,16 @@ public function getWithCustomHeader(ReqWithHeaders $request, ?array $options = n if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/extends/src/SeedClient.php b/seed/php-sdk/extends/src/SeedClient.php index af27a5570b5..cb637603841 100644 --- a/seed/php-sdk/extends/src/SeedClient.php +++ b/seed/php-sdk/extends/src/SeedClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -83,6 +84,16 @@ public function extendedInlineRequestBody(Inlined $request, ?array $options = nu if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/extra-properties/src/User/UserClient.php b/seed/php-sdk/extra-properties/src/User/UserClient.php index 8878542e341..3fe627e11ef 100644 --- a/seed/php-sdk/extra-properties/src/User/UserClient.php +++ b/seed/php-sdk/extra-properties/src/User/UserClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -77,6 +78,16 @@ public function createUser(CreateUserRequest $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/file-download/src/Service/ServiceClient.php b/seed/php-sdk/file-download/src/Service/ServiceClient.php index e6c1d9efee3..c9f675e5e2c 100644 --- a/seed/php-sdk/file-download/src/Service/ServiceClient.php +++ b/seed/php-sdk/file-download/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -65,6 +66,16 @@ public function downloadFile(?array $options = null): void $options, ); $statusCode = $response->getStatusCode(); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/file-upload/src/Service/ServiceClient.php b/seed/php-sdk/file-upload/src/Service/ServiceClient.php index 2e5b5ad9d14..a10e34f84fb 100644 --- a/seed/php-sdk/file-upload/src/Service/ServiceClient.php +++ b/seed/php-sdk/file-upload/src/Service/ServiceClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonEncoder; use Seed\Core\Multipart\MultipartApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Service\Requests\JustFileRequest; use Seed\Service\Requests\JustFileWithQueryParamsRequest; @@ -113,6 +114,16 @@ public function post(MyRequest $request, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -151,6 +162,16 @@ public function justFile(JustFileRequest $request, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -202,6 +223,16 @@ public function justFileWithQueryParams(JustFileWithQueryParamsRequest $request, if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -258,6 +289,16 @@ public function withContentType(WithContentTypeRequest $request, ?array $options if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/folders/src/A/B/BClient.php b/seed/php-sdk/folders/src/A/B/BClient.php index 1978e69a140..3a3c7d17482 100644 --- a/seed/php-sdk/folders/src/A/B/BClient.php +++ b/seed/php-sdk/folders/src/A/B/BClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class BClient @@ -68,6 +69,16 @@ public function foo(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/folders/src/A/C/CClient.php b/seed/php-sdk/folders/src/A/C/CClient.php index 5f8ea6f80f2..56f4630bdd9 100644 --- a/seed/php-sdk/folders/src/A/C/CClient.php +++ b/seed/php-sdk/folders/src/A/C/CClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class CClient @@ -68,6 +69,16 @@ public function foo(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/folders/src/Folder/FolderClient.php b/seed/php-sdk/folders/src/Folder/FolderClient.php index 7e769bed8d0..aa1da21ef9e 100644 --- a/seed/php-sdk/folders/src/Folder/FolderClient.php +++ b/seed/php-sdk/folders/src/Folder/FolderClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class FolderClient @@ -75,6 +76,16 @@ public function foo(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/folders/src/Folder/Service/ServiceClient.php b/seed/php-sdk/folders/src/Folder/Service/ServiceClient.php index aff9e93a721..ea7c83d3a3f 100644 --- a/seed/php-sdk/folders/src/Folder/Service/ServiceClient.php +++ b/seed/php-sdk/folders/src/Folder/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -68,6 +69,16 @@ public function endpoint(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -104,6 +115,16 @@ public function unknownRequest(mixed $request, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/folders/src/SeedClient.php b/seed/php-sdk/folders/src/SeedClient.php index 6065c53a952..8c4b45145aa 100644 --- a/seed/php-sdk/folders/src/SeedClient.php +++ b/seed/php-sdk/folders/src/SeedClient.php @@ -10,6 +10,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -95,6 +96,16 @@ public function foo(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/idempotency-headers/src/Payment/PaymentClient.php b/seed/php-sdk/idempotency-headers/src/Payment/PaymentClient.php index ed60eb3e1d4..8d3b23cc7bb 100644 --- a/seed/php-sdk/idempotency-headers/src/Payment/PaymentClient.php +++ b/seed/php-sdk/idempotency-headers/src/Payment/PaymentClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PaymentClient @@ -77,6 +78,16 @@ public function create(CreatePaymentRequest $request, ?array $options = null): s } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -112,6 +123,16 @@ public function delete(string $paymentId, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/imdb/clientName/src/Imdb/ImdbClient.php b/seed/php-sdk/imdb/clientName/src/Imdb/ImdbClient.php index 839b99d348d..b6d0e5efe62 100644 --- a/seed/php-sdk/imdb/clientName/src/Imdb/ImdbClient.php +++ b/seed/php-sdk/imdb/clientName/src/Imdb/ImdbClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Imdb\Types\Movie; @@ -80,6 +81,16 @@ public function createMovie(CreateMovieRequest $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getMovie(string $movieId, ?array $options = null): Movie } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/imdb/namespace/src/Imdb/ImdbClient.php b/seed/php-sdk/imdb/namespace/src/Imdb/ImdbClient.php index 96b4334cee6..5f2c9e7ac56 100644 --- a/seed/php-sdk/imdb/namespace/src/Imdb/ImdbClient.php +++ b/seed/php-sdk/imdb/namespace/src/Imdb/ImdbClient.php @@ -11,6 +11,7 @@ use Fern\Core\Client\HttpMethod; use Fern\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Fern\Imdb\Types\Movie; @@ -80,6 +81,16 @@ public function createMovie(CreateMovieRequest $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getMovie(string $movieId, ?array $options = null): Movie } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/imdb/no-custom-config/src/Imdb/ImdbClient.php b/seed/php-sdk/imdb/no-custom-config/src/Imdb/ImdbClient.php index 839b99d348d..b6d0e5efe62 100644 --- a/seed/php-sdk/imdb/no-custom-config/src/Imdb/ImdbClient.php +++ b/seed/php-sdk/imdb/no-custom-config/src/Imdb/ImdbClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Imdb\Types\Movie; @@ -80,6 +81,16 @@ public function createMovie(CreateMovieRequest $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getMovie(string $movieId, ?array $options = null): Movie } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/imdb/packageName/src/Imdb/ImdbClient.php b/seed/php-sdk/imdb/packageName/src/Imdb/ImdbClient.php index 839b99d348d..b6d0e5efe62 100644 --- a/seed/php-sdk/imdb/packageName/src/Imdb/ImdbClient.php +++ b/seed/php-sdk/imdb/packageName/src/Imdb/ImdbClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Imdb\Types\Movie; @@ -80,6 +81,16 @@ public function createMovie(CreateMovieRequest $request, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getMovie(string $movieId, ?array $options = null): Movie } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/license/src/SeedClient.php b/seed/php-sdk/license/src/SeedClient.php index becf0fd9c5b..914541a7c92 100644 --- a/seed/php-sdk/license/src/SeedClient.php +++ b/seed/php-sdk/license/src/SeedClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -80,6 +81,16 @@ public function get(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/literal/src/Headers/HeadersClient.php b/seed/php-sdk/literal/src/Headers/HeadersClient.php index 457c627b86c..7eba1167aca 100644 --- a/seed/php-sdk/literal/src/Headers/HeadersClient.php +++ b/seed/php-sdk/literal/src/Headers/HeadersClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class HeadersClient @@ -81,6 +82,16 @@ public function send(SendLiteralsInHeadersRequest $request, ?array $options = nu } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/literal/src/Inlined/InlinedClient.php b/seed/php-sdk/literal/src/Inlined/InlinedClient.php index ef2a7b2944a..c279291afea 100644 --- a/seed/php-sdk/literal/src/Inlined/InlinedClient.php +++ b/seed/php-sdk/literal/src/Inlined/InlinedClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class InlinedClient @@ -77,6 +78,16 @@ public function send(SendLiteralsInlinedRequest $request, ?array $options = null } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/literal/src/Path/PathClient.php b/seed/php-sdk/literal/src/Path/PathClient.php index 930e822a754..da9bdb8b2fa 100644 --- a/seed/php-sdk/literal/src/Path/PathClient.php +++ b/seed/php-sdk/literal/src/Path/PathClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PathClient @@ -75,6 +76,16 @@ public function send(string $id, ?array $options = null): SendResponse } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/literal/src/Query/QueryClient.php b/seed/php-sdk/literal/src/Query/QueryClient.php index 721647a77ab..0d8eef385fe 100644 --- a/seed/php-sdk/literal/src/Query/QueryClient.php +++ b/seed/php-sdk/literal/src/Query/QueryClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class QueryClient @@ -95,6 +96,16 @@ public function send(SendLiteralsInQueryRequest $request, ?array $options = null } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/literal/src/Reference/ReferenceClient.php b/seed/php-sdk/literal/src/Reference/ReferenceClient.php index b41083a1c5f..d33e812c0c4 100644 --- a/seed/php-sdk/literal/src/Reference/ReferenceClient.php +++ b/seed/php-sdk/literal/src/Reference/ReferenceClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ReferenceClient @@ -77,6 +78,16 @@ public function send(SendRequest $request, ?array $options = null): SendResponse } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/mixed-case/src/Service/ServiceClient.php b/seed/php-sdk/mixed-case/src/Service/ServiceClient.php index 8f21a1011d1..b2f660b2e4c 100644 --- a/seed/php-sdk/mixed-case/src/Service/ServiceClient.php +++ b/seed/php-sdk/mixed-case/src/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Service\Requests\ListResourcesRequest; use Seed\Core\Types\Constant; @@ -77,6 +78,16 @@ public function getResource(string $resourceId, ?array $options = null): mixed } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -120,6 +131,16 @@ public function listResources(ListResourcesRequest $request, ?array $options = n } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/mixed-file-directory/src/Organization/OrganizationClient.php b/seed/php-sdk/mixed-file-directory/src/Organization/OrganizationClient.php index b85e03ce421..1662e36c70e 100644 --- a/seed/php-sdk/mixed-file-directory/src/Organization/OrganizationClient.php +++ b/seed/php-sdk/mixed-file-directory/src/Organization/OrganizationClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class OrganizationClient @@ -79,6 +80,16 @@ public function create(CreateOrganizationRequest $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/mixed-file-directory/src/User/Events/EventsClient.php b/seed/php-sdk/mixed-file-directory/src/User/Events/EventsClient.php index e59f908c24e..3863c55065c 100644 --- a/seed/php-sdk/mixed-file-directory/src/User/Events/EventsClient.php +++ b/seed/php-sdk/mixed-file-directory/src/User/Events/EventsClient.php @@ -13,6 +13,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class EventsClient @@ -91,6 +92,16 @@ public function listEvents(ListUserEventsRequest $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/mixed-file-directory/src/User/Events/Metadata/MetadataClient.php b/seed/php-sdk/mixed-file-directory/src/User/Events/Metadata/MetadataClient.php index d4acd6879ad..5e4a69343ee 100644 --- a/seed/php-sdk/mixed-file-directory/src/User/Events/Metadata/MetadataClient.php +++ b/seed/php-sdk/mixed-file-directory/src/User/Events/Metadata/MetadataClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class MetadataClient @@ -81,6 +82,16 @@ public function getMetadata(GetEventMetadataRequest $request, ?array $options = } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/mixed-file-directory/src/User/UserClient.php b/seed/php-sdk/mixed-file-directory/src/User/UserClient.php index b3a21472d58..cacd0ca8759 100644 --- a/seed/php-sdk/mixed-file-directory/src/User/UserClient.php +++ b/seed/php-sdk/mixed-file-directory/src/User/UserClient.php @@ -13,6 +13,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -91,6 +92,16 @@ public function list(ListUsersRequest $request, ?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/multi-line-docs/src/User/UserClient.php b/seed/php-sdk/multi-line-docs/src/User/UserClient.php index 99205a134f5..efa1e07f8a4 100644 --- a/seed/php-sdk/multi-line-docs/src/User/UserClient.php +++ b/seed/php-sdk/multi-line-docs/src/User/UserClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\User\Requests\CreateUserRequest; use Seed\User\Types\User; @@ -78,6 +79,16 @@ public function getUser(string $userId, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -121,6 +132,16 @@ public function createUser(CreateUserRequest $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/no-environment/src/Dummy/DummyClient.php b/seed/php-sdk/no-environment/src/Dummy/DummyClient.php index be226731045..aa4ac93b8e5 100644 --- a/seed/php-sdk/no-environment/src/Dummy/DummyClient.php +++ b/seed/php-sdk/no-environment/src/Dummy/DummyClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class DummyClient @@ -74,6 +75,16 @@ public function getDummy(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/nullable/src/Nullable/NullableClient.php b/seed/php-sdk/nullable/src/Nullable/NullableClient.php index 2dfa3af95ad..92ade48bf57 100644 --- a/seed/php-sdk/nullable/src/Nullable/NullableClient.php +++ b/seed/php-sdk/nullable/src/Nullable/NullableClient.php @@ -12,6 +12,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Nullable\Requests\CreateUserRequest; use Seed\Nullable\Requests\DeleteUserRequest; @@ -96,6 +97,16 @@ public function getUsers(GetUsersRequest $request, ?array $options = null): arra } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -136,6 +147,16 @@ public function createUser(CreateUserRequest $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -176,6 +197,16 @@ public function deleteUser(DeleteUserRequest $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/oauth-client-credentials-custom/src/Auth/AuthClient.php b/seed/php-sdk/oauth-client-credentials-custom/src/Auth/AuthClient.php index 8a99244a611..2ba3a13236b 100644 --- a/seed/php-sdk/oauth-client-credentials-custom/src/Auth/AuthClient.php +++ b/seed/php-sdk/oauth-client-credentials-custom/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Auth\Requests\RefreshTokenRequest; @@ -78,6 +79,16 @@ public function getTokenWithClientCredentials(GetTokenRequest $request, ?array $ } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function refreshToken(RefreshTokenRequest $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/oauth-client-credentials-default/src/Auth/AuthClient.php b/seed/php-sdk/oauth-client-credentials-default/src/Auth/AuthClient.php index efce4e31b87..47dea73530c 100644 --- a/seed/php-sdk/oauth-client-credentials-default/src/Auth/AuthClient.php +++ b/seed/php-sdk/oauth-client-credentials-default/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class AuthClient @@ -77,6 +78,16 @@ public function getToken(GetTokenRequest $request, ?array $options = null): Toke } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/oauth-client-credentials-environment-variables/src/Auth/AuthClient.php b/seed/php-sdk/oauth-client-credentials-environment-variables/src/Auth/AuthClient.php index 8a99244a611..2ba3a13236b 100644 --- a/seed/php-sdk/oauth-client-credentials-environment-variables/src/Auth/AuthClient.php +++ b/seed/php-sdk/oauth-client-credentials-environment-variables/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Auth\Requests\RefreshTokenRequest; @@ -78,6 +79,16 @@ public function getTokenWithClientCredentials(GetTokenRequest $request, ?array $ } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function refreshToken(RefreshTokenRequest $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/oauth-client-credentials-nested-root/src/Auth/AuthClient.php b/seed/php-sdk/oauth-client-credentials-nested-root/src/Auth/AuthClient.php index efce4e31b87..47dea73530c 100644 --- a/seed/php-sdk/oauth-client-credentials-nested-root/src/Auth/AuthClient.php +++ b/seed/php-sdk/oauth-client-credentials-nested-root/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class AuthClient @@ -77,6 +78,16 @@ public function getToken(GetTokenRequest $request, ?array $options = null): Toke } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/oauth-client-credentials/src/Auth/AuthClient.php b/seed/php-sdk/oauth-client-credentials/src/Auth/AuthClient.php index 8a99244a611..2ba3a13236b 100644 --- a/seed/php-sdk/oauth-client-credentials/src/Auth/AuthClient.php +++ b/seed/php-sdk/oauth-client-credentials/src/Auth/AuthClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Auth\Requests\RefreshTokenRequest; @@ -78,6 +79,16 @@ public function getTokenWithClientCredentials(GetTokenRequest $request, ?array $ } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function refreshToken(RefreshTokenRequest $request, ?array $options = nul } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/optional/src/Optional/OptionalClient.php b/seed/php-sdk/optional/src/Optional/OptionalClient.php index a0f64ff700a..c254efc1802 100644 --- a/seed/php-sdk/optional/src/Optional/OptionalClient.php +++ b/seed/php-sdk/optional/src/Optional/OptionalClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonSerializer; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class OptionalClient @@ -77,6 +78,16 @@ public function sendOptionalBody(?array $request = null, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/package-yml/src/SeedClient.php b/seed/php-sdk/package-yml/src/SeedClient.php index ccd11f3f715..2c0d4625d04 100644 --- a/seed/php-sdk/package-yml/src/SeedClient.php +++ b/seed/php-sdk/package-yml/src/SeedClient.php @@ -12,6 +12,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -98,6 +99,16 @@ public function echo_(string $id, EchoRequest $request, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/package-yml/src/Service/ServiceClient.php b/seed/php-sdk/package-yml/src/Service/ServiceClient.php index edfe582c8c9..2ce16ff32a9 100644 --- a/seed/php-sdk/package-yml/src/Service/ServiceClient.php +++ b/seed/php-sdk/package-yml/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -70,6 +71,16 @@ public function nop(string $id, string $nestedId, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/pagination/src/Complex/ComplexClient.php b/seed/php-sdk/pagination/src/Complex/ComplexClient.php index a3db10dedc0..d8c5377c0d4 100644 --- a/seed/php-sdk/pagination/src/Complex/ComplexClient.php +++ b/seed/php-sdk/pagination/src/Complex/ComplexClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ComplexClient @@ -77,6 +78,16 @@ public function search(SearchRequest $request, ?array $options = null): Paginate } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/pagination/src/Users/UsersClient.php b/seed/php-sdk/pagination/src/Users/UsersClient.php index 8e26f0fb7fe..65b3b0c10d6 100644 --- a/seed/php-sdk/pagination/src/Users/UsersClient.php +++ b/seed/php-sdk/pagination/src/Users/UsersClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Users\Requests\ListUsersMixedTypeCursorPaginationRequest; use Seed\Users\Types\ListUsersMixedTypePaginationResponse; @@ -106,6 +107,16 @@ public function listWithCursorPagination(ListUsersCursorPaginationRequest $reque } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -150,6 +161,16 @@ public function listWithMixedTypeCursorPagination(ListUsersMixedTypeCursorPagina } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -190,6 +211,16 @@ public function listWithBodyCursorPagination(ListUsersBodyCursorPaginationReques } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -243,6 +274,16 @@ public function listWithOffsetPagination(ListUsersOffsetPaginationRequest $reque } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -296,6 +337,16 @@ public function listWithDoubleOffsetPagination(ListUsersDoubleOffsetPaginationRe } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -336,6 +387,16 @@ public function listWithBodyOffsetPagination(ListUsersBodyOffsetPaginationReques } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -386,6 +447,16 @@ public function listWithOffsetStepPagination(ListUsersOffsetStepPaginationReques } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -436,6 +507,16 @@ public function listWithOffsetPaginationHasNextPage(ListWithOffsetPaginationHasN } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -480,6 +561,16 @@ public function listWithExtendedResults(ListUsersExtendedRequest $request, ?arra } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -524,6 +615,16 @@ public function listWithExtendedResultsAndOptionalData(ListUsersExtendedRequestF } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -568,6 +669,16 @@ public function listUsernames(ListUsernamesRequest $request, ?array $options = n } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -612,6 +723,16 @@ public function listWithGlobalConfig(ListWithGlobalConfigRequest $request, ?arra } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/path-parameters/src/Organizations/OrganizationsClient.php b/seed/php-sdk/path-parameters/src/Organizations/OrganizationsClient.php index dccf8a700d5..fd442fa19c4 100644 --- a/seed/php-sdk/path-parameters/src/Organizations/OrganizationsClient.php +++ b/seed/php-sdk/path-parameters/src/Organizations/OrganizationsClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Organizations\Requests\GetOrganizationUserRequest; use Seed\User\Types\User; @@ -80,6 +81,16 @@ public function getOrganization(string $tenantId, string $organizationId, ?array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -122,6 +133,16 @@ public function getOrganizationUser(string $tenantId, string $organizationId, st } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -168,6 +189,16 @@ public function searchOrganizations(string $tenantId, string $organizationId, Se } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/path-parameters/src/User/UserClient.php b/seed/php-sdk/path-parameters/src/User/UserClient.php index a99d1779144..e4adb6e85af 100644 --- a/seed/php-sdk/path-parameters/src/User/UserClient.php +++ b/seed/php-sdk/path-parameters/src/User/UserClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\User\Requests\UpdateUserRequest; use Seed\User\Requests\SearchUsersRequest; @@ -81,6 +82,16 @@ public function getUser(string $tenantId, string $userId, GetUsersRequest $reque } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -122,6 +133,16 @@ public function createUser(string $tenantId, User $request, ?array $options = nu } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -164,6 +185,16 @@ public function updateUser(string $tenantId, string $userId, UpdateUserRequest $ } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -210,6 +241,16 @@ public function searchUsers(string $tenantId, string $userId, SearchUsersRequest } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/plain-text/src/Service/ServiceClient.php b/seed/php-sdk/plain-text/src/Service/ServiceClient.php index f820403b9fb..4ebd22bf17b 100644 --- a/seed/php-sdk/plain-text/src/Service/ServiceClient.php +++ b/seed/php-sdk/plain-text/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -69,6 +70,16 @@ public function getText(?array $options = null): string if ($statusCode >= 200 && $statusCode < 400) { return $response->getBody()->getContents(); } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/query-parameters/src/User/UserClient.php b/seed/php-sdk/query-parameters/src/User/UserClient.php index 384485f9b4b..9cbce03d0ab 100644 --- a/seed/php-sdk/query-parameters/src/User/UserClient.php +++ b/seed/php-sdk/query-parameters/src/User/UserClient.php @@ -12,6 +12,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -99,6 +100,16 @@ public function getUsername(GetUsersRequest $request, ?array $options = null): U } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/reserved-keywords/src/Package/PackageClient.php b/seed/php-sdk/reserved-keywords/src/Package/PackageClient.php index cab6d0d774a..402a84e3f84 100644 --- a/seed/php-sdk/reserved-keywords/src/Package/PackageClient.php +++ b/seed/php-sdk/reserved-keywords/src/Package/PackageClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PackageClient @@ -73,6 +74,16 @@ public function test(TestRequest $request, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/response-property/src/Service/ServiceClient.php b/seed/php-sdk/response-property/src/Service/ServiceClient.php index 5d7319720f9..38638d6bae8 100644 --- a/seed/php-sdk/response-property/src/Service/ServiceClient.php +++ b/seed/php-sdk/response-property/src/Service/ServiceClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Types\StringResponse; use Seed\Service\Types\WithDocs; @@ -78,6 +79,16 @@ public function getMovie(string $request, ?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -118,6 +129,16 @@ public function getMovieDocs(string $request, ?array $options = null): Response } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -158,6 +179,16 @@ public function getMovieName(string $request, ?array $options = null): StringRes } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -198,6 +229,16 @@ public function getMovieMetadata(string $request, ?array $options = null): Respo } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -241,6 +282,16 @@ public function getOptionalMovie(string $request, ?array $options = null): ?Resp } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -284,6 +335,16 @@ public function getOptionalMovieDocs(string $request, ?array $options = null): ? } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -327,6 +388,16 @@ public function getOptionalMovieName(string $request, ?array $options = null): ? } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/server-sent-event-examples/src/Completions/CompletionsClient.php b/seed/php-sdk/server-sent-event-examples/src/Completions/CompletionsClient.php index 95e0e68bf42..83132b494c2 100644 --- a/seed/php-sdk/server-sent-event-examples/src/Completions/CompletionsClient.php +++ b/seed/php-sdk/server-sent-event-examples/src/Completions/CompletionsClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class CompletionsClient @@ -68,6 +69,16 @@ public function stream(StreamCompletionRequest $request, ?array $options = null) $options, ); $statusCode = $response->getStatusCode(); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/server-sent-events/src/Completions/CompletionsClient.php b/seed/php-sdk/server-sent-events/src/Completions/CompletionsClient.php index 95e0e68bf42..83132b494c2 100644 --- a/seed/php-sdk/server-sent-events/src/Completions/CompletionsClient.php +++ b/seed/php-sdk/server-sent-events/src/Completions/CompletionsClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class CompletionsClient @@ -68,6 +69,16 @@ public function stream(StreamCompletionRequest $request, ?array $options = null) $options, ); $statusCode = $response->getStatusCode(); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/simple-fhir/src/SeedClient.php b/seed/php-sdk/simple-fhir/src/SeedClient.php index 11f1fff5b6c..73b6f56aa49 100644 --- a/seed/php-sdk/simple-fhir/src/SeedClient.php +++ b/seed/php-sdk/simple-fhir/src/SeedClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SeedClient @@ -87,6 +88,16 @@ public function getAccount(string $accountId, ?array $options = null): Account } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/single-url-environment-default/src/Dummy/DummyClient.php b/seed/php-sdk/single-url-environment-default/src/Dummy/DummyClient.php index e325aa5dc48..89c1e91907f 100644 --- a/seed/php-sdk/single-url-environment-default/src/Dummy/DummyClient.php +++ b/seed/php-sdk/single-url-environment-default/src/Dummy/DummyClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class DummyClient @@ -75,6 +76,16 @@ public function getDummy(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/single-url-environment-no-default/src/Dummy/DummyClient.php b/seed/php-sdk/single-url-environment-no-default/src/Dummy/DummyClient.php index be226731045..aa4ac93b8e5 100644 --- a/seed/php-sdk/single-url-environment-no-default/src/Dummy/DummyClient.php +++ b/seed/php-sdk/single-url-environment-no-default/src/Dummy/DummyClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class DummyClient @@ -74,6 +75,16 @@ public function getDummy(?array $options = null): string } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/streaming-parameter/src/Dummy/DummyClient.php b/seed/php-sdk/streaming-parameter/src/Dummy/DummyClient.php index 2dd35ee5f85..d0c3a224623 100644 --- a/seed/php-sdk/streaming-parameter/src/Dummy/DummyClient.php +++ b/seed/php-sdk/streaming-parameter/src/Dummy/DummyClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class DummyClient @@ -68,6 +69,16 @@ public function generate(GenerateRequest $request, ?array $options = null): void $options, ); $statusCode = $response->getStatusCode(); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/streaming/src/Dummy/DummyClient.php b/seed/php-sdk/streaming/src/Dummy/DummyClient.php index c5870933499..e19e69cf855 100644 --- a/seed/php-sdk/streaming/src/Dummy/DummyClient.php +++ b/seed/php-sdk/streaming/src/Dummy/DummyClient.php @@ -9,6 +9,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Dummy\Requests\Generateequest; use Seed\Dummy\Types\StreamResponse; @@ -71,6 +72,16 @@ public function generateStream(GenerateStreamRequest $request, ?array $options = $options, ); $statusCode = $response->getStatusCode(); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -111,6 +122,16 @@ public function generate(Generateequest $request, ?array $options = null): Strea } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Admin/AdminClient.php b/seed/php-sdk/trace/src/Admin/AdminClient.php index 6dc2f3bb24b..ef9d48e371d 100644 --- a/seed/php-sdk/trace/src/Admin/AdminClient.php +++ b/seed/php-sdk/trace/src/Admin/AdminClient.php @@ -9,6 +9,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Environments; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Submission\Types\TestSubmissionUpdate; use Seed\Submission\Types\WorkspaceSubmissionUpdate; @@ -78,6 +79,16 @@ public function updateTestSubmissionStatus(string $submissionId, mixed $request, if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -115,6 +126,16 @@ public function sendTestSubmissionUpdate(string $submissionId, TestSubmissionUpd if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -152,6 +173,16 @@ public function updateWorkspaceSubmissionStatus(string $submissionId, mixed $req if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -189,6 +220,16 @@ public function sendWorkspaceSubmissionUpdate(string $submissionId, WorkspaceSub if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -227,6 +268,16 @@ public function storeTracedTestCase(string $submissionId, string $testCaseId, St if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -265,6 +316,16 @@ public function storeTracedTestCaseV2(string $submissionId, string $testCaseId, if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -302,6 +363,16 @@ public function storeTracedWorkspace(string $submissionId, StoreTracedWorkspaceR if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -339,6 +410,16 @@ public function storeTracedWorkspaceV2(string $submissionId, array $request, ?ar if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Homepage/HomepageClient.php b/seed/php-sdk/trace/src/Homepage/HomepageClient.php index f7bd7c6a676..6e463931571 100644 --- a/seed/php-sdk/trace/src/Homepage/HomepageClient.php +++ b/seed/php-sdk/trace/src/Homepage/HomepageClient.php @@ -11,6 +11,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Core\Json\JsonSerializer; @@ -76,6 +77,16 @@ public function getHomepageProblems(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -112,6 +123,16 @@ public function setHomepageProblems(array $request, ?array $options = null): voi if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Migration/MigrationClient.php b/seed/php-sdk/trace/src/Migration/MigrationClient.php index 7ebb16c8fb1..21e2dcd191e 100644 --- a/seed/php-sdk/trace/src/Migration/MigrationClient.php +++ b/seed/php-sdk/trace/src/Migration/MigrationClient.php @@ -13,6 +13,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class MigrationClient @@ -81,6 +82,16 @@ public function getAttemptedMigrations(GetAttemptedMigrationsRequest $request, ? } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Playlist/PlaylistClient.php b/seed/php-sdk/trace/src/Playlist/PlaylistClient.php index 4a9cc3ae633..46891d30b7d 100644 --- a/seed/php-sdk/trace/src/Playlist/PlaylistClient.php +++ b/seed/php-sdk/trace/src/Playlist/PlaylistClient.php @@ -13,6 +13,7 @@ use Seed\Environments; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Playlist\Requests\GetPlaylistsRequest; use Seed\Core\Json\JsonDecoder; @@ -91,6 +92,16 @@ public function createPlaylist(int $serviceParam, CreatePlaylistRequest $request } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -144,6 +155,16 @@ public function getPlaylists(int $serviceParam, GetPlaylistsRequest $request, ?a } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -186,6 +207,16 @@ public function getPlaylist(int $serviceParam, string $playlistId, ?array $optio } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -233,6 +264,16 @@ public function updatePlaylist(int $serviceParam, string $playlistId, ?UpdatePla } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -271,6 +312,16 @@ public function deletePlaylist(int $serviceParam, string $playlistId, ?array $op if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Problem/ProblemClient.php b/seed/php-sdk/trace/src/Problem/ProblemClient.php index d50af167984..0697572c447 100644 --- a/seed/php-sdk/trace/src/Problem/ProblemClient.php +++ b/seed/php-sdk/trace/src/Problem/ProblemClient.php @@ -12,6 +12,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Problem\Types\UpdateProblemResponse; use Seed\Problem\Requests\GetDefaultStarterFilesRequest; @@ -83,6 +84,16 @@ public function createProblem(CreateProblemRequest $request, ?array $options = n } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -126,6 +137,16 @@ public function updateProblem(string $problemId, CreateProblemRequest $request, } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -163,6 +184,16 @@ public function deleteProblem(string $problemId, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -205,6 +236,16 @@ public function getDefaultStarterFiles(GetDefaultStarterFilesRequest $request, ? } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Submission/SubmissionClient.php b/seed/php-sdk/trace/src/Submission/SubmissionClient.php index d83759fa875..d9fbfc96560 100644 --- a/seed/php-sdk/trace/src/Submission/SubmissionClient.php +++ b/seed/php-sdk/trace/src/Submission/SubmissionClient.php @@ -12,6 +12,7 @@ use Seed\Environments; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Submission\Types\GetExecutionSessionStateResponse; @@ -80,6 +81,16 @@ public function createExecutionSession(string $language, ?array $options = null) } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -124,6 +135,16 @@ public function getExecutionSession(string $sessionId, ?array $options = null): } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -161,6 +182,16 @@ public function stopExecutionSession(string $sessionId, ?array $options = null): if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -199,6 +230,16 @@ public function getExecutionSessionsState(?array $options = null): GetExecutionS } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/Sysprop/SyspropClient.php b/seed/php-sdk/trace/src/Sysprop/SyspropClient.php index bd66460c6db..ee484757d03 100644 --- a/seed/php-sdk/trace/src/Sysprop/SyspropClient.php +++ b/seed/php-sdk/trace/src/Sysprop/SyspropClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Environments; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Core\Json\JsonDecoder; use JsonException; @@ -74,6 +75,16 @@ public function setNumWarmInstances(string $language, int $numWarmInstances, ?ar if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -112,6 +123,16 @@ public function getNumWarmInstances(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/V2/Problem/ProblemClient.php b/seed/php-sdk/trace/src/V2/Problem/ProblemClient.php index 7fe2e74a078..3aaaca3bf3b 100644 --- a/seed/php-sdk/trace/src/V2/Problem/ProblemClient.php +++ b/seed/php-sdk/trace/src/V2/Problem/ProblemClient.php @@ -12,6 +12,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\V2\Problem\Types\ProblemInfoV2; @@ -79,6 +80,16 @@ public function getLightweightProblems(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getProblems(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -160,6 +181,16 @@ public function getLatestProblem(string $problemId, ?array $options = null): Pro } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -202,6 +233,16 @@ public function getProblemVersion(string $problemId, int $problemVersion, ?array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/V2/V2Client.php b/seed/php-sdk/trace/src/V2/V2Client.php index 3c798507e0f..d09c0fe3d7e 100644 --- a/seed/php-sdk/trace/src/V2/V2Client.php +++ b/seed/php-sdk/trace/src/V2/V2Client.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Environments; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class V2Client @@ -83,6 +84,16 @@ public function test(?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/trace/src/V2/V3/Problem/ProblemClient.php b/seed/php-sdk/trace/src/V2/V3/Problem/ProblemClient.php index 661627d2676..67769989702 100644 --- a/seed/php-sdk/trace/src/V2/V3/Problem/ProblemClient.php +++ b/seed/php-sdk/trace/src/V2/V3/Problem/ProblemClient.php @@ -12,6 +12,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\V2\V3\Problem\Types\ProblemInfoV2; @@ -79,6 +80,16 @@ public function getLightweightProblems(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -119,6 +130,16 @@ public function getProblems(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -160,6 +181,16 @@ public function getLatestProblem(string $problemId, ?array $options = null): Pro } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -202,6 +233,16 @@ public function getProblemVersion(string $problemId, int $problemVersion, ?array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/undiscriminated-unions/src/Union/UnionClient.php b/seed/php-sdk/undiscriminated-unions/src/Union/UnionClient.php index 4a1d8c011f7..fb5a763c133 100644 --- a/seed/php-sdk/undiscriminated-unions/src/Union/UnionClient.php +++ b/seed/php-sdk/undiscriminated-unions/src/Union/UnionClient.php @@ -12,6 +12,7 @@ use Seed\Core\Types\Union; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Union\Types\KeyType; @@ -79,6 +80,16 @@ public function get(string|array|int $request, ?array $options = null): string|a } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -117,6 +128,16 @@ public function getMetadata(?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/unions/src/Union/UnionClient.php b/seed/php-sdk/unions/src/Union/UnionClient.php index 5b2ab08e25f..7ec7bf1eca1 100644 --- a/seed/php-sdk/unions/src/Union/UnionClient.php +++ b/seed/php-sdk/unions/src/Union/UnionClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UnionClient @@ -75,6 +76,16 @@ public function get(string $id, ?array $options = null): mixed } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -115,6 +126,16 @@ public function update(mixed $request, ?array $options = null): bool } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/unknown/src/Unknown/UnknownClient.php b/seed/php-sdk/unknown/src/Unknown/UnknownClient.php index ab324a5a52f..ae556f33e01 100644 --- a/seed/php-sdk/unknown/src/Unknown/UnknownClient.php +++ b/seed/php-sdk/unknown/src/Unknown/UnknownClient.php @@ -10,6 +10,7 @@ use Seed\Core\Client\HttpMethod; use Seed\Core\Json\JsonDecoder; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Unknown\Types\MyObject; @@ -77,6 +78,16 @@ public function post(mixed $request, ?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -117,6 +128,16 @@ public function postObject(MyObject $request, ?array $options = null): array } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/validation/src/SeedClient.php b/seed/php-sdk/validation/src/SeedClient.php index aa4b42994c8..72a3c01685f 100644 --- a/seed/php-sdk/validation/src/SeedClient.php +++ b/seed/php-sdk/validation/src/SeedClient.php @@ -11,6 +11,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Seed\Requests\GetRequest; @@ -90,6 +91,16 @@ public function create(CreateRequest $request, ?array $options = null): Type } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } @@ -134,6 +145,16 @@ public function get(GetRequest $request, ?array $options = null): Type } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/variables/src/Service/ServiceClient.php b/seed/php-sdk/variables/src/Service/ServiceClient.php index ce432114198..b47e1618bb1 100644 --- a/seed/php-sdk/variables/src/Service/ServiceClient.php +++ b/seed/php-sdk/variables/src/Service/ServiceClient.php @@ -8,6 +8,7 @@ use Seed\Exceptions\SeedApiException; use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class ServiceClient @@ -69,6 +70,16 @@ public function post(string $endpointParam, ?array $options = null): void if ($statusCode >= 200 && $statusCode < 400) { return; } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/version-no-default/src/User/UserClient.php b/seed/php-sdk/version-no-default/src/User/UserClient.php index 2b88fedd84b..6b9ca69d7fb 100644 --- a/seed/php-sdk/version-no-default/src/User/UserClient.php +++ b/seed/php-sdk/version-no-default/src/User/UserClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -75,6 +76,16 @@ public function getUser(string $userId, ?array $options = null): User } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); } diff --git a/seed/php-sdk/version/src/User/UserClient.php b/seed/php-sdk/version/src/User/UserClient.php index 2b88fedd84b..6b9ca69d7fb 100644 --- a/seed/php-sdk/version/src/User/UserClient.php +++ b/seed/php-sdk/version/src/User/UserClient.php @@ -10,6 +10,7 @@ use Seed\Core\Json\JsonApiRequest; use Seed\Core\Client\HttpMethod; use JsonException; +use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class UserClient @@ -75,6 +76,16 @@ public function getUser(string $userId, ?array $options = null): User } } catch (JsonException $e) { throw new SeedException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new SeedException(message: $e->getMessage(), previous: $e); + } + throw new SeedApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); } catch (ClientExceptionInterface $e) { throw new SeedException(message: $e->getMessage(), previous: $e); }