<?php

namespace App\EventHooks\Service;

use App\EventHooks\HookEvent;
use App\Models\ClientProduct;

/**
 * Fire noktası: Store\ClientAreaController::storeCancellationRequest → CancellationRequest.
 * Context (model TAŞIMAZ — yalnız id'ler): service_id/relid, reason, type (=refund_type),
 * user_id/userid (client), cancellation_request_id.
 */
class CancellationRequested extends HookEvent
{
    public const HOOK = 'CancellationRequest';

    public function service(): ?ClientProduct
    {
        $id = $this->get('service_id') ?? $this->get('relid');

        return $id ? ClientProduct::find($id) : null;
    }

    public function reason(): ?string
    {
        return $this->get('reason');
    }

    /** WHMCS 'type' anahtarı burada refund_type değerini taşır. */
    public function type(): ?string
    {
        return $this->get('type');
    }
}
