<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\OutboundWebhookSubscription;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
 * @extends Factory<OutboundWebhookSubscription>
 */
class OutboundWebhookSubscriptionFactory extends Factory
{
    protected $model = OutboundWebhookSubscription::class;

    public function definition(): array
    {
        return [
            'tenant_id' => Tenant::factory(),
            'user_id' => User::factory(),
            'name' => 'Webhook',
            'target_url' => 'https://'.fake()->domainName().'/webhook',
            'secret_hash' => Hash::make('whsec_'.Str::random(40)),
            'secret_prefix' => 'whsec_'.Str::lower(Str::random(4)),
            'events' => ['deal.created', 'deal.status_changed'],
            'is_active' => true,
        ];
    }
}
