<?php

namespace PixelioCartAbandonRecoveryMore\Admin\Services;


use PixelioCartAbandonRecoveryMore\Admin\Wrapper\Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper;
use PixelioCartAbandonRecoveryMore\Frontend\Repositories\Pixelio_Cart_Abandon_Recovery_More_Email_Logs_Repository;

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


/**
 * Class Pixelio_Cart_Abandon_Recovery_More_Email
 *
 * Handles email sending for abandoned carts and order review requests.
 * Core responsibilities:
 *  - Retrieve and validate recipients from POST data or WooCommerce orders
 *  - Generate coupons and prepare email content
 *  - Replace placeholders in email templates
 *  - Log sent emails
 *  - Generate recovery, review, and unsubscribe links
 *  - Process email queues and update status via API or local storage
 *
 * @package PixelioCartAbandonRecoveryMore\Admin\Service
 */
class Pixelio_Cart_Abandon_Recovery_More_Email_Logger_Service
{
	/**
	 * WordPress abstraction layer (POST, sanitize, esc_html, etc).
	 *
	 * @var Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper
	 */
	private Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper $pixelio_wordpress_wrapper;
	private Pixelio_Cart_Abandon_Recovery_More_Email_Logs_Repository $email_Logs_Repository;

	/**
	 * Constructor
	 *
	 * @param Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper $pixelio_wordpress_wrapper WordPress wrapper
	 */
	public function __construct(Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper $pixelio_wordpress_wrapper,
								Pixelio_Cart_Abandon_Recovery_More_Email_Logs_Repository $email_Logs_Repository)
	{
		$this->pixelio_wordpress_wrapper = $pixelio_wordpress_wrapper;
		$this->email_Logs_Repository = $email_Logs_Repository;

	}

	public function pixelio_email_is_already_sent_for_wishlist_email($email, $type): bool
	{
			return $this->email_Logs_Repository->pixelio_email_is_already_sent_for_wishlist_email($email, $type);
	}

	public function pixelio_log_email(array $pixelio_data, array $pixelio_config, string $pixelio_recipient): void
	{
		$this->email_Logs_Repository->pixelio_add_email($pixelio_data['cart_id'] ?? 0, $pixelio_data['subject'] ?? '', $pixelio_recipient, $pixelio_data['template_id'] ?? 0, $pixelio_config['type_of_email']);
	}



}
