<?php

namespace App\Data\Pagarme\Order\Parts\Response;

use App\Data\Pagarme\PagarmeResponseData;

final readonly class CheckoutData extends PagarmeResponseData
{
    public function __construct(
        public ?string $id,
        public ?string $status,
        public ?string $url,
    ) {}

    public static function fromArray(array $payload): static
    {
        return new self(
            id:     static::arrString($payload, 'id'),
            status: static::arrString($payload, 'status'),
            url:    static::arrString($payload, 'url'),
        );
    }

    public function toArray(): array
    {
        return [
            'id'     => $this->id,
            'status' => $this->status,
            'url'    => $this->url,
        ];
    }
}
