<?php

namespace Waypoint\Agent\Rest\Handler;

use Waypoint\Agent\Monitor\Status_Data;

class Monitor {

	private Status_Data $data;

	public function __construct( Status_Data $data ) {
		$this->data = $data;
	}

	public function handle_status( \WP_REST_Request $request ): \WP_REST_Response {
		return rest_ensure_response( $this->data->payload() );
	}

	public function handle_ping( \WP_REST_Request $request ): \WP_REST_Response {
		return rest_ensure_response( [
			'ok'             => true,
			'plugin_version' => WAYPOINT_AGENT_VERSION,
			'wp_version'     => get_bloginfo( 'version' ),
			'now'            => gmdate( 'c' ),
		] );
	}
}
