<?php
/**
 * Mailer interface.
 */

declare(strict_types=1);
namespace FeData\FastEvents\Mail;

defined( 'ABSPATH' ) || exit;

use Exception;
use stdClass;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;

interface MailerInterface {
	public const FAST_EVENTS_NORMAL_EMAIL  = 0;
	public const FAST_EVENTS_CONFIRM_EMAIL = 1;

	/**
	 * Send order email
	 *
	 * @param stdClass $order        Order information.
	 * @param int      $type         0=Normal mail, 1=Confirmation email.
	 * @param bool     $bypass_queue true = bypass the queue even if email queues are enabled.
	 * @throws Exception      If mail can't be sent.
	 */
	public function send_email( stdClass $order, int $type = self::FAST_EVENTS_NORMAL_EMAIL, bool $bypass_queue = false ): void;

	/**
	 * Send HTML Email
	 *
	 * @since 1.0
	 *
	 * @param string $to          Emailadress.
	 * @param string $subject     Email subject.
	 * @param string $message     HTML formatted message.
	 * @throws Exception          If mail can't be sent.
	 */
	public function send_html_message( string $to, string $subject, string $message ): void;

	/**
	 * Process email provider incoming webhook.
	 *
	 * @since 2.4.0
	 * @since 2.5.0 All events are added to the email log, and error events are added to the errorlog as well.
	 *
	 * @param WP_REST_Request $data Request instance.
	 *
	 * @return WP_REST_Response | WP_Error
	 */
	public function webhook( WP_REST_Request $data ): WP_Error|WP_REST_Response;

	/**
	 * Set retry position.
	 *
	 * @since 3.0.0
	 *
	 * @param int $position Retry position.
	 */
	public function set_retry_position( int $position ): void;

	/**
	 * Set retry scheme.
	 *
	 * @since 3.0.0
	 *
	 * @param array $retry_scheme Retry position.
	 */
	public function set_retry_scheme( array $retry_scheme ): void;
}
