<?php
namespace Easy_MCP_AI\Tools\WooCommerce;

use Easy_MCP_AI\Tools\Base_Tool;

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

class List_Shipping_Zones extends Base_Tool {

    public function get_name() {
        return 'wp_wc_list_shipping_zones';
    }

    public function get_description() {
        return 'Lists all WooCommerce shipping zones. No parameters. Returns the raw array of zones from the WooCommerce API, each including id, name, order (display sort order). Zone id=0 is the special "Rest of the World" fallback zone. Use the `id` with `wp_wc_list_shipping_methods` to see what shipping options are configured per zone. Requires WooCommerce active.';
    }

    public function get_category() {
        return 'woocommerce';
    }

    public function get_required_capability() {
        return 'manage_woocommerce';
    }

    public function get_annotations() {
        return array(
            'title'           => $this->get_title(),
            'readOnlyHint'    => true,
            'destructiveHint' => false,
            'openWorldHint'   => false,
        );
    }

    public function get_input_schema() {
        return array(
            'type'       => 'object',
            'properties' => new \stdClass(),
            'required'   => array(),
        );
    }

    public function execute( array $arguments ) {
        if ( ! class_exists( 'WooCommerce' ) ) {
            throw new \RuntimeException( 'WooCommerce is not active.' );
        }

        $data = $this->rest_request( 'GET', '/wc/v3/shipping/zones' );

        return $data;
    }
}
