Spaces:
Sleeping
Sleeping
File size: 1,249 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 | <?php
declare(strict_types=1);
namespace Firecrawl\Models;
final class CreditUsage
{
public function __construct(
private readonly int $remainingCredits = 0,
private readonly ?int $planCredits = null,
private readonly ?string $billingPeriodStart = null,
private readonly ?string $billingPeriodEnd = null,
) {}
/** @param array<string, mixed> $data */
public static function fromArray(array $data): self
{
$inner = $data['data'] ?? $data;
return new self(
remainingCredits: (int) ($inner['remainingCredits'] ?? 0),
planCredits: isset($inner['planCredits']) ? (int) $inner['planCredits'] : null,
billingPeriodStart: $inner['billingPeriodStart'] ?? null,
billingPeriodEnd: $inner['billingPeriodEnd'] ?? null,
);
}
public function getRemainingCredits(): int
{
return $this->remainingCredits;
}
public function getPlanCredits(): ?int
{
return $this->planCredits;
}
public function getBillingPeriodStart(): ?string
{
return $this->billingPeriodStart;
}
public function getBillingPeriodEnd(): ?string
{
return $this->billingPeriodEnd;
}
}
|