krystal / katapult-whmcs

MIT License
1 stars 1 forks source link

Improve error handling in API interactions #34

Open bencromwell opened 4 months ago

bencromwell commented 4 months ago

Example:

$postOrganizationManagedResponse = katapult()->postOrganizationManaged($managedOrganization);
assert($postOrganizationManagedResponse instanceof OrganizationsOrganizationManagedPostResponse201, new Exception());
$newManagedOrganization = $postOrganizationManagedResponse->getOrganization();

Here we just ensure we got a 201 back of the appropriate type defined by the OpenAPI spec.

We should handle these better to account for, for instance, 503s, which will come through as PSR ResponseInterface instances.

It'd be nice to provide the option for retries in situations such as that.