<?php
declare(strict_types=1);

namespace Simplyin\Simplyin_W_Plugin\Controller\Ajax\Widget;

use Simplyin\Simplyin_W_Plugin\Controller\Ajax\Abstract_Response;

class Check_Push_Notification_Response extends Abstract_Response {

	protected string $html = '';
	protected array $invoice_address = [];
	protected array $login_result = [];
	protected ?string $phone_number = null;

	/**
	 * @var array<string, mixed>
	 */
	private array $checkout_sync_payload = [];

	/**
	 * @param array<string, mixed> $payload Checkout restore fields for the widget script.
	 */
	public function set_checkout_sync_payload( array $payload ): void {
		$this->checkout_sync_payload = $payload;
	}

	protected function get_array(): array {
		$base = [
			'html'            => $this->html,
			'login_result'    => $this->login_result,
			'invoice_address' => $this->invoice_address,
			'phone_number'    => $this->phone_number,
		];

		if ( [] === $this->checkout_sync_payload ) {
			return $base;
		}

		return array_merge(
			$base,
			$this->checkout_sync_payload,
			[ 'simplyin_checkout_sync' => true ]
		);
	}

	public function set_html( string $html ): void {
		$this->html = $html;
	}

	public function set_login_result( array $login_result ): void {
		$this->login_result = $login_result;
	}

	public function set_phone_number( ?string $phone_number ): void {
		$this->phone_number = $phone_number;
	}

	public function get_invoice_address(): array {
		return $this->invoice_address;
	}

	public function set_invoice_address( array $invoice_address ): void {
		$this->invoice_address = $invoice_address;
	}
}
