<?php

/**
 * Tutorial API Routes
 */

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

require_once dirname(__FILE__) . '/tutorial-status.php';

/**
 * Register tutorial API routes
 */
function content_craft_ai_register_tutorial_routes()
{
  // Check tutorial status
  register_rest_route('content-craft-ai/v1', '/tutorial/status', array(
    'methods'  => 'GET',
    'callback' => 'content_craft_ai_get_tutorial_status',
    'permission_callback' => function () {
      return current_user_can('manage_options');
    },
  ));

  // Mark tutorial as shown
  register_rest_route('content-craft-ai/v1', '/tutorial/mark-shown', array(
    'methods'  => 'POST',
    'callback' => 'content_craft_ai_mark_tutorial_shown',
    'permission_callback' => function () {
      return current_user_can('manage_options');
    },
  ));
}

add_action('rest_api_init', 'content_craft_ai_register_tutorial_routes');
