<?php

namespace App\Enum\Esign;

/**
 * Canonical kinds of Fintrixor webhook event. The mapper translates the API's
 * dotted names (document.created, …, certificate.generated) onto these.
 */
enum EsignEventType: string
{
    case CREATED = 'created';
    case SENT = 'sent';
    case VIEWED = 'viewed';
    case SIGNED = 'signed';
    case COMPLETED = 'completed';
    case CERTIFICATE_GENERATED = 'certificate_generated';
    case UNKNOWN = 'unknown';

    public function label(): string
    {
        return ucwords(str_replace('_', ' ', $this->value));
    }

    public function color(): string
    {
        return match ($this) {
            self::CREATED, self::SENT => 'info',
            self::VIEWED => 'primary',
            self::SIGNED => 'warning',
            self::COMPLETED, self::CERTIFICATE_GENERATED => 'success',
            self::UNKNOWN => 'secondary',
        };
    }
}
