<?php

namespace App\Services\Communications\Routing;

class RoutingDecision {
    public function __construct(
        public readonly string  $action,
        public readonly ?int    $agentId = null,
        public readonly array   $agentIds = [],
        public readonly ?int    $queueId = null,
        public readonly ?string $reason = null,
        public readonly array   $meta = [],
    ) {
    }

    public static function dialAgent(int $agentId, string $reason, array $meta = []): self {
        return new self(
            action: 'dial_agent',
            agentId: $agentId,
            reason: $reason,
            meta: $meta,
        );
    }

    public static function dialAgents(array $agentIds, string $reason, array $meta = []): self {
        return new self(
            action: 'dial_agents',
            agentIds: $agentIds,
            reason: $reason,
            meta: $meta,
        );
    }

    public static function enqueue(int $queueId, string $reason, array $meta = []): self {
        return new self(
            action: 'enqueue',
            queueId: $queueId,
            reason: $reason,
            meta: $meta,
        );
    }

    public static function voicemail(string $reason, array $meta = []): self {
        return new self(
            action: 'voicemail',
            reason: $reason,
            meta: $meta,
        );
    }

    public static function reject(string $reason, array $meta = []): self {
        return new self(
            action: 'reject',
            reason: $reason,
            meta: $meta,
        );
    }
}