<?php

namespace App\Enum\Contact;

enum TemplateTriggerType: string
{
    case MANUAL = 'manual';
    case STATUS_CHANGED = 'status_changed';
    case TAG_ADDED = 'tag_added';
    case TAG_REMOVED = 'tag_removed';
    case MODEL_CREATED = 'model_created';
    case MODEL_UPDATED = 'model_updated';
    case SCHEDULED = 'scheduled';

    public function label(): string
    {
        return match ($this) {
            self::MANUAL => 'Manual only',
            self::STATUS_CHANGED => 'Status changed',
            self::TAG_ADDED => 'Tag added',
            self::TAG_REMOVED => 'Tag removed',
            self::MODEL_CREATED => 'Record created',
            self::MODEL_UPDATED => 'Record updated',
            self::SCHEDULED => 'Scheduled',
        };
    }

    public function toOrigin(): MessageOrigin
    {
        return match ($this) {
            self::MANUAL => MessageOrigin::MANUAL,
            self::STATUS_CHANGED => MessageOrigin::STATUS_CHANGED,
            self::TAG_ADDED => MessageOrigin::TAG_ADDED,
            self::TAG_REMOVED => MessageOrigin::TAG_REMOVED,
            self::MODEL_CREATED => MessageOrigin::MODEL_CREATED,
            self::MODEL_UPDATED => MessageOrigin::MODEL_UPDATED,
            self::SCHEDULED => MessageOrigin::SCHEDULED,
        };
    }
}
