<?php

namespace SWPanel;

defined('ABSPATH') || die('No direct access.');

use SWPanel\APIClient;

class Auth {
    public static function validate() {
        $license_data = get_transient('swpanel_ai_license_status');

		if ($license_data !== false) {
			return (bool) $license_data;
		}

        try {
            $response = APIClient::get("/validation");
            $is_valid = !empty($response);
        } catch (\Exception) {
            $is_valid = false;
        }
    
		set_transient('swpanel_ai_license_status', $is_valid ? 1 : 0, 3600);
		return $is_valid;
    }
}
