<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace QuadLayers\IGG\Api\Rest\Endpoints;

use QuadLayers\IGG\Api\Rest\Routes_Library;
use QuadLayers\IGG\Api\Rest\Endpoints\Route as Route_Interface;

/**
 * Base Class
 */
abstract class Base implements Route_Interface {

	protected static $route_path = null;

	public function __construct() {

		register_rest_route(
			Routes_Library::get_namespace(),
			static::get_rest_route(),
			array(
				'args'                => static::get_rest_args(),
				'methods'             => static::get_rest_method(),
				'callback'            => array( $this, 'callback' ),
				'permission_callback' => array( $this, 'get_rest_permission' ),
			)
		);

		Routes_Library::instance()->register( $this );
	}

	public static function get_rest_route() {
		return static::$route_path;
	}

	public static function get_name() {
		$path   = static::get_rest_path();
		$method = strtolower( static::get_rest_method() );
		return "$path/$method";
	}

	public static function get_rest_path() {
		$rest_namespace = Routes_Library::get_namespace();
		$rest_route     = self::get_rest_route();

		return "{$rest_namespace}/{$rest_route}";
	}

	public static function get_rest_args() {
		return array();
	}

	private static function get_error( $code, $message ) {
		return array(
			'code'    => $code,
			'message' => $message,
		);
	}

	public function handle_resp