<?php
/**
 * User REST API Loader (Base)
 *
 * @category   WordPress_Plugin
 * @package    Common
 * @subpackage 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\Common\Rest_APIs;

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

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

/**
 * Class User_APIs
 *
 * Base user API class with login functionality (available in all plans)
 */
class User_APIs {

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

		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/login',
			array(
				'methods'             => WP_REST_Server::CREATABLE,
				'callback'            => array( $controller, 'login' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);

		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/contact-us',
			array(
				'methods'             => WP_REST_Server::CREATABLE,
				'callback'            => array( $controller, 'contact_us' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);

		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/trial-request',
			array(
				'methods'             => WP_REST_Server::CREATABLE,
				'callback'            => array( $controller, 'trial_request' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);

		register_rest_route(
			Constants::REST_API_NAMESPACE,
			'/user/details',
			array(
				'methods'             => WP_REST_Server::READABLE,
				'callback'            => array( $controller, 'get_user_details' ),
				'permission_callback' => array( $controller, 'check_permissions' ),
			)
		);
	}
}
