feat: phase 0 foundation — InsForge REST client, config, env wiring, dev account
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\InsForge;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InsForgeException extends RuntimeException
|
||||
{
|
||||
public function __construct(
|
||||
public readonly ?string $errorCode,
|
||||
public readonly int $statusCode,
|
||||
string $message,
|
||||
) {
|
||||
parent::__construct($message, $statusCode);
|
||||
}
|
||||
|
||||
public static function fromResponse(int $statusCode, array|string $body): self
|
||||
{
|
||||
if (is_array($body)) {
|
||||
return new self(
|
||||
$body['error'] ?? null,
|
||||
$body['statusCode'] ?? $statusCode,
|
||||
$body['message'] ?? 'InsForge request failed',
|
||||
);
|
||||
}
|
||||
|
||||
return new self(null, $statusCode, $body !== '' ? $body : "InsForge request failed with status {$statusCode}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user