<?php

declare(strict_types=1);

namespace ImovelZapAi\AiGateway\Infrastructure\Persistence\Eloquent;

use Illuminate\Database\Eloquent\Model;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;

class AiRequestLogModel extends Model
{
    use BelongsToTenant;
    use HasUuidPrimaryKey;

    protected $table = 'ai_request_logs';

    public $incrementing = false;

    protected $keyType = 'string';

    protected $fillable = [
        'id',
        'tenant_id',
        'user_id',
        'task_type',
        'provider',
        'model',
        'input_tokens',
        'output_tokens',
        'total_tokens',
        'estimated_cost_usd',
        'latency_ms',
        'status',
        'error_message',
        'metadata',
    ];

    protected function casts(): array
    {
        return [
            'input_tokens' => 'integer',
            'output_tokens' => 'integer',
            'total_tokens' => 'integer',
            'estimated_cost_usd' => 'float',
            'latency_ms' => 'integer',
            'metadata' => 'array',
        ];
    }
}
