<?php
/**
/**
 * Api route to ping local api.
 *
 * @package AMVE\Admin\Classes\Api
 */

namespace Amve\Api;

use WP_REST_Request;
use WP_REST_Response;

/**
 * Api route to ping local api.
 */
class Route_Ping_Local_Api {
	/**
	 * Register the route.
	 *
	 * @return bool True if the route was registered, false otherwise.
	 */
	public function register_route() {
		return register_rest_route(
			'wps/amve/v1',
			'/ping',
			array(
				'methods'             => 'GET',
				'callback'            => array( $this, 'callback' ),
				'permission_callback' => '__return_true',
			)
		);
	}

	/**
	 * Callback function for the route.
	 *
	 * @param WP_REST_Request $request The request made to the api endpoint.
	 * @return WP_REST_Response The response to send to the API call.
	 */
	public function callback( $request ) {
		unset( $request );
		return new WP_REST_Response(
			array(
				'code' => 'success',
				'data' => array(
					'status' => 200,
				),
			),
			200
		);
	}
}
