<?php
declare(strict_types=1);

namespace Simplyin\Simplyin_W_Plugin\Controller\Ajax\Widget;

use Simplyin\Simplyin_W_Plugin\Controller\Ajax\Abstract_Response;

/**
 * Response for the shop-login email-OTP challenge verify.
 *
 * Serializes the fields the shared pin handler (validatePinCode) inspects so the challenge reuses
 * the same UI branch as the checkout code: `isCodeValid=false` → show the error; `code`
 * "TOO_MANY_REQUESTS" + `message` → the throttling countdown; `success` + `login_result.wp_logged_in`
 * → reload (now logged into the shop account).
 */
class Verify_Shop_Login_Email_Otp_Response extends Abstract_Response {

	protected ?bool $is_code_valid = null;
	protected ?string $code = null;
	protected ?string $message = null;
	protected array $login_result = [];

	public function get_array(): array {
		return [
			'isCodeValid'  => $this->is_code_valid,
			'code'         => $this->code,
			'message'      => $this->message,
			'login_result' => $this->login_result,
		];
	}

	public function set_is_code_valid( ?bool $is_code_valid ): void {
		$this->is_code_valid = $is_code_valid;
	}

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

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

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