<?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 SyncPaymentRequest extends AbstractRequest
{
    public function __construct(
        private readonly int $paymentId
    ) {
    }

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

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

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

    public function getPaymentId(): int
    {
        return $this->paymentId;
    }
}
