Spaces:
Sleeping
Sleeping
File size: 1,712 Bytes
097eaf0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | <?php
declare(strict_types=1);
namespace Firecrawl\Models;
final class AgentStatusResponse
{
public function __construct(
private readonly bool $success = false,
private readonly ?string $status = null,
private readonly ?string $error = null,
private readonly mixed $data = null,
private readonly ?string $model = null,
private readonly ?string $expiresAt = null,
private readonly ?int $creditsUsed = null,
) {}
/** @param array<string, mixed> $raw */
public static function fromArray(array $raw): self
{
return new self(
success: (bool) ($raw['success'] ?? false),
status: $raw['status'] ?? null,
error: $raw['error'] ?? null,
data: $raw['data'] ?? null,
model: $raw['model'] ?? null,
expiresAt: $raw['expiresAt'] ?? null,
creditsUsed: isset($raw['creditsUsed']) ? (int) $raw['creditsUsed'] : null,
);
}
public function isDone(): bool
{
return in_array($this->status, ['completed', 'failed', 'cancelled'], true);
}
public function isSuccess(): bool
{
return $this->success;
}
public function getStatus(): ?string
{
return $this->status;
}
public function getError(): ?string
{
return $this->error;
}
public function getData(): mixed
{
return $this->data;
}
public function getModel(): ?string
{
return $this->model;
}
public function getExpiresAt(): ?string
{
return $this->expiresAt;
}
public function getCreditsUsed(): ?int
{
return $this->creditsUsed;
}
}
|