<?php

namespace PixelioCartAbandonRecoveryMore\Admin\Validator;

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

/**
 * Service responsible for validating email and UUID
 * from AJAX requests for temporary coupons.
 *
 * Dependencies are injected to allow unit testing without
 * loading WordPress.
 */
class Pixelio_Cart_Abandon_Recovery_More_Template_Validator
{
	private $wordpress_wrapper;
	private $pixelio_util;

	public function __construct($wordpress_wrapper, $pixelio_util)
	{
		$this->wordpress_wrapper = $wordpress_wrapper;
		$this->pixelio_util = $pixelio_util;
	}


	/**
	 * @param array $data
	 * @return array
	 */
	public function pixelio_validate_template_data(array $data): array
	{
		if (empty($data['template_name']) || empty($data['subject']) || empty($data['body_html'])) {
			$this->wordpress_wrapper->pixelio_wp_send_json_error([
				'message' => 'Missing required fields'
			]);
			$this->wordpress_wrapper->pixelio_wp_die();
		}
		return $data;
	}

}
