<?php
namespace ONLINE_ADAv4\Api;

use \ONLINE_ADAv4\Services\License;
use \ONLINE_ADAv4\Services\Options;

class Admin {
    
    use \ONLINE_ADAv4\Traits\Singleton;

    public function __construct(){
        add_action('rest_api_init', [$this, 'routes']);
    }

    public function routes() {
          register_rest_route( 'accessibility-suite/v1', '/update-options', array(
            'methods' => 'POST',
            'callback' => [Options::getInstance(), 'updateOptions'],
            'permission_callback' => function () {
                return current_user_can( 'manage_options' );
            }
          ) );
          register_rest_route( 'accessibility-suite/v1', '/get-options', array(
            'methods' => 'POST',
            'callback' => [Options::getInstance(), 'getOptions'],
            'permission_callback' => function () {
                return current_user_can( 'manage_options' );
            }
          ) );
          register_rest_route( 'accessibility-suite/v1', '/check-license', array(
            'methods' => 'POST',
            'callback' => [License::getInstance(), 'check'],
            'permission_callback' => function () {
                return current_user_can( 'manage_options' );
            }
          ) );
          register_rest_route( 'accessibility-suite/v1', '/activate-license', array(
            'methods' => 'POST',
            'callback' => [License::getInstance(), 'activate'],
            'permission_callback' => function () {
                return current_user_can( 'manage_options' );
            }
          ) );
    }
}