<?php

namespace Database\Factories;

use App\Models\ExportMap;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class ExportMapFactory extends Factory
{
    protected $model = ExportMap::class;

    public function definition(): array
    {
        return [
            'name' => $this->faker->words(3, true),
            'type' => 'vehicle',
            'active' => true,
            'format' => 'csv',
            'columns' => ['uuid', 'registration_number', 'vin'],
            'headers' => ['UUID', 'Reg', 'VIN'],
            'conditions' => [],
            'mapping_rules' => [],
            'include_header_row' => true,
            'ftp_export_enabled' => false,
            'schedule_enabled' => false,
        ];
    }

    public function forType(string $type): static
    {
        return $this->state(fn () => ['type' => $type]);
    }

    public function offerType(): static
    {
        return $this->forType('offer');
    }

    public function withApiUrl(): static
    {
        return $this->state(fn () => [
            'api_url_enabled' => true,
            'uuid' => Str::uuid()->toString(),
        ]);
    }

    public function inactive(): static
    {
        return $this->state(fn () => ['active' => false]);
    }
}
