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

declare(strict_types=1);

namespace BookiFlex\Core\Admin\CPT\Event;

defined( 'ABSPATH' ) || exit;

/**
 * Event: AccommodationType was created
 *
 * Dispatched when a new AccommodationType CPT is created
 *
 * This is an immediate event (not deferred) dispatched via EventDispatcher
 * after Carbon Fields has saved all post metadata.
 */
class AccommodationTypeWasCreated
{
    /**
     * @param int $postId WordPress post ID (same as accommodationTypeId)
     * @param array $data Post data snapshot
     */
    public function __construct(
        private readonly int $postId,
        private readonly array $data
    ) {
    }

    /**
     * Get WordPress post ID
     */
    public function getPostId(): int
    {
        return $this->postId;
    }

    /**
     * Get AccommodationType ID (same as post ID)
     */
    public function getAccommodationTypeId(): int
    {
        return $this->postId;
    }

    /**
     * Get all post data
     */
    public function getData(): array
    {
        return $this->data;
    }

    /**
     * Get accommodation type name
     */
    public function getName(): string
    {
        return $this->data['name'] ?? '';
    }

    /**
     * Get post status (publish, draft, etc.)
     */
    public function getStatus(): string
    {
        return $this->data['status'] ?? '';
    }

    /**
     * Get available units
     *
     * This is the total number of individual units of this accommodation type
     * that can be booked (e.g., 10 identical Double Rooms)
     */
    public function getAvailableUnits(): int
    {
        return $this->data['available_units'] ?? 0;
    }

    /**
     * Get short code
     */
    public function getShortCode(): string
    {
        return $this->data['short_code'] ?? '';
    }

    /**
     * Get accommodation category
     */
    public function getAccommodationCategory(): string
    {
        return $this->data['accommodation_category'] ?? '';
    }
}
