<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ -- NUCLEAR+++
// File: /home/ploi/automarketer-ai.com/public/wp-content/plugins/automarketer-ai/includes/class-abstract-email-provider.php
// Description: Abstract base class for all email provider modules - NUCLEAR+++
// Last Edited: 2026-04-27
// ==================================================

namespace AutoMarketerAI;

if (!defined('ABSPATH')) {
    exit('No direct script access allowed.');
}

abstract class AbstractEmailProvider implements ModuleInterface
{
    public function get_category(): string { return 'Email'; }
    public function get_model_count(): int { return 0; }
    public function get_available_models(): array { return []; }
    public function get_single_model_notice(): string { return ''; }
    public function get_api_key_prefix(): string { return ''; }

    public function register(): void
    {
        // No admin_footer hook needed -- email providers use the shared #amai-act-modal
    }

    public static function get_sender_name(): string
    {
        $override = (string) get_option('amai_email_sender_name', '');
        if ($override !== '') { return $override; }
        $user = get_userdata(1);
        return $user ? (string) $user->display_name : get_bloginfo('name');
    }

    public static function get_sender_email(): string
    {
        $override = (string) get_option('amai_email_sender_email', '');
        if ($override !== '') { return $override; }
        $user = get_userdata(1);
        return $user ? (string) $user->user_email : (string) get_option('admin_email', '');
    }

    public static function save_sender_name(string $name): void
    {
        update_option('amai_email_sender_name', sanitize_text_field($name));
    }

    public static function save_sender_email(string $email): void
    {
        update_option('amai_email_sender_email', sanitize_email($email));
    }


    public function generate_raw(string $prompt, string $api_key, string $model): string { return ''; }

    abstract public function get_id(): string;
    abstract public function get_name(): string;
    abstract public function get_description(): string;
    abstract public function get_logo_url(): string;
    abstract public function validate_api_key(string $key): bool;
    abstract protected function get_pricing_note(): string;
    abstract protected function get_signup_url(): string;
    abstract protected function get_signup_label(): string;
    abstract public function send(string $to_email, string $to_name, string $subject, string $html_body, string $api_key): bool;
}
