<?php
/**
 * BookiFlex Payment Extension
 *
 * @package    BookiFlex
 * @subpackage Payment
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Extensions\Payment\Api\Request;

use BookiFlex\Core\Api\Request\AbstractRequest;
use WP_REST_Request;

defined( 'ABSPATH' ) || exit;

class GetPaymentRequest extends AbstractRequest
{
    public function __construct(
        private readonly int $id
    ) {
    }

    public static function fromWpRestRequest(WP_REST_Request $request): self
    {
        return new self(
            id: (int) $request->get_param('id')
        );
    }

    public static function getValidationRules(): array
    {
        return [
            'id' => self::positiveIntRule(),
        ];
    }

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

    public function getId(): int
    {
        return $this->id;
    }
}
