<?php
/**
 * User REST API Loader (Standard Plan)
 *
 * @category   WordPress_Plugin
 * @package    Plans
 * @subpackage Standard\Rest_APIs
 * @author     miniOrange <info@miniorange.com>
 * @license    MIT/Expat
 * @link       https://plugins.miniorange.com/woocommerce-api-product-sync-with-woocommerce-rest-apis
 */

namespace MOWCPS\Standard\Rest_APIs;

use WP_REST_Server;
use MOWCPS\Common\Constants\Constants;
use MOWCPS\Standard\Controllers\Rest_API\User_Rest_Controller;

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

/**
 * Class User_APIs
 *
 * Standard plan user API class with registration and feedback functionality
 */
class User_APIs {

	/**
	 * Register standard plan user routes
	 *
	 * @return void
	 */
	public static function register_routes() {
		$controller = new User_Rest_Controller();

		// User registration.
		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/register',
			array(
				'methods'             => WP_REST_Server::CREATABLE,
				'callback'            => array( $controller, 'register_user' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);

		// User feedback.
		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/feedback',
			array(
				'methods'             => WP_REST_Server::CREATABLE,
				'callback'            => array( $controller, 'submit_feedback' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);
	}
}
