<?php
/**
 * YATOON_Square_API - FREE stub
 *
 * All methods return WP_Error / safe empty results so the free version
 * never crashes when admin code paths reach Square. The real
 * implementation lives in the Pro package (includes/pro/class-yatoon-square-api.php).
 *
 * [FREE]
 */
if ( ! defined( 'ABSPATH' ) ) exit;

class YATOON_Square_API {

    public function __construct() {}

    /**
     * Pro upgrade message helper.
     */
    private function _pro_required( $method ) {
        $upgrade_url = class_exists( 'YATOON_License' ) && method_exists( 'YATOON_License', 'get_upgrade_url' )
            ? YATOON_License::get_upgrade_url()
            : '';
        return new WP_Error(
            'yatoon_pro_required',
            /* translators: %s: name of the Square API method that was called. */
            sprintf( __( 'Square integration (%s) requires Yatoon Pro.', 'yatoon-booking-system' ), $method ),
            array( 'is_pro_gate' => true, 'upgrade_url' => $upgrade_url )
        );
    }

    /**
     * Catch-all for any Square API method the core code may call. Always
     * returns a WP_Error so callers that already check is_wp_error() will
     * degrade safely.
     */
    public function __call( $name, $args ) {
        return $this->_pro_required( $name );
    }

    public static function __callStatic( $name, $args ) {
        $upgrade_url = class_exists( 'YATOON_License' ) && method_exists( 'YATOON_License', 'get_upgrade_url' )
            ? YATOON_License::get_upgrade_url()
            : '';
        return new WP_Error(
            'yatoon_pro_required',
            /* translators: %s: name of the Square API method that was called. */
            sprintf( __( 'Square integration (%s) requires Yatoon Pro.', 'yatoon-booking-system' ), $name ),
            array( 'is_pro_gate' => true, 'upgrade_url' => $upgrade_url )
        );
    }

    /**
     * Admin "Test Connection" UI checks a specific array shape, not WP_Error.
     */
    public function test_connection() {
        return array(
            'success'     => false,
            'error'       => __( 'Square sync is a Pro feature. Upgrade to enable it.', 'yatoon-booking-system' ),
            'is_pro_gate' => true,
        );
    }

    public function is_configured()   { return false; }
    public static function is_enabled() { return false; }
    public function is_location_closed_on( $date, $timezone = '' ) { return null; }
}
