<?php

if (!defined('ABSPATH')) {
    exit;
}

abstract class AIEO_Newsletter_Adapter_Base {

    
    protected $settings;

    public function __construct(array $settings) {
        $this->settings = $settings;
    }

    
    abstract public function get_id(): string;

    
    abstract public function get_label(): string;

    
    abstract public function get_settings_fields(): array;

    
    abstract public function test_connection(): array;

    
    abstract public function sync_contacts(array $contacts, string $cohort): array;

    
    protected static function md5_email(string $email): string {
        return md5(strtolower(trim($email)));
    }

    protected static function sha256_email(string $email): string {
        return hash('sha256', strtolower(trim($email)));
    }

    
    protected static function cohort_tag(string $cohort): string {
        return 'aieo:cohort:' . sanitize_key($cohort);
    }

    
    protected static function generic_tag(): string {
        return 'aieo:source';
    }

    
    public function subscribe_one(string $email, array $opts = array()): array {
        return array('ok' => false, 'status' => '', 'list_id' => 0, 'error' => 'not_supported');
    }
}
