<?php

namespace Database\Factories;

use App\Models\AllowedAdAccount;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<AllowedAdAccount>
 */
class AllowedAdAccountFactory extends Factory
{
    protected $model = AllowedAdAccount::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'platform' => 'meta',
            'account_id' => 'act_'.$this->faker->numerify('################'),
            'name' => $this->faker->company().' Ads',
            'is_active' => true,
            'notes' => null,
        ];
    }

    /**
     * State for a Meta ad account.
     */
    public function meta(?string $accountId = null): static
    {
        return $this->state(fn (array $attributes): array => [
            'platform' => 'meta',
            'account_id' => $accountId ?? 'act_'.$this->faker->numerify('################'),
        ]);
    }

    /**
     * State for a Google Ads customer account.
     */
    public function google(?string $customerId = null): static
    {
        return $this->state(fn (array $attributes): array => [
            'platform' => 'google',
            'account_id' => $customerId ?? $this->faker->numerify('##########'),
        ]);
    }

    /**
     * State for a LinkedIn ad account.
     */
    public function linkedin(?string $accountId = null): static
    {
        return $this->state(fn (array $attributes): array => [
            'platform' => 'linkedin',
            'account_id' => $accountId ?? $this->faker->numerify('#########'),
        ]);
    }

    /**
     * State for an inactive account.
     */
    public function inactive(): static
    {
        return $this->state(fn (array $attributes): array => [
            'is_active' => false,
        ]);
    }
}
