<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Backend;

use JTL\Alert\Alert;

/**
 * One backend alert, flattened for transport.
 *
 * Backend controllers do not return values — they talk through {@see
 * \JTL\Services\JTL\AlertServiceInterface} (see `ShippingMethodsController::actionSave()` and
 * `PaymentMethodsController.php:458`, which adds `'successSave'`). The alert list is therefore the
 * only *narrative* an invocation produces, and this is its wire shape: the three fields an LLM can
 * act on, with the Smarty-facing extras (icon, css type, link href, fade-out) deliberately dropped.
 */
final readonly class AlertView
{
    public function __construct(
        public string $type,
        public string $key,
        public string $message,
    ) {
    }

    public static function fromAlert(Alert $alert): self
    {
        return new self($alert->getType(), $alert->getKey(), $alert->getMessage());
    }
}
