<?php

namespace App\Console\Commands;

use App\Models\Verification;
use App\Services\VerificationEmailSender;
use Illuminate\Console\Command;

class TestZeptoMailCommand extends Command
{
    protected $signature = 'mail:test-verification {email} {--code=12345}';

    protected $description = 'Test verification email via ZeptoMail API then SMTP';

    public function handle(VerificationEmailSender $sender): int
    {
        $verification = new Verification([
            'email' => $this->argument('email'),
            'code' => $this->option('code'),
        ]);

        if ($sender->send($verification)) {
            $this->info('Verification email sent OK to ' . $verification->email);

            return 0;
        }

        $this->error('Failed to send. Check storage/logs/laravel.log and ZEPTOMAIL_API_KEY / MAIL_PASSWORD in .env');

        return 1;
    }
}
