<?php

namespace Fotogenic_AI;

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

final class Rest_Experiences {
	private Service_Experiences $service;

	public function __construct( Service_Experiences $service ) {
		$this->service = $service;
	}

	public function register_routes( Rest_Router $router ): void {
		$router->register_route(
			'fotogenic-ai/v1',
			'/experiences/claim',
			[
				'methods'             => 'POST',
				'callback'            => [ $this, 'handle_claim' ],
				'permission_callback' => [ $router, 'permissions_admin' ],
			]
		);

		$router->register_route(
			'fotogenic-ai/v1',
			'/experiences/dismiss',
			[
				'methods'             => 'POST',
				'callback'            => [ $this, 'handle_dismiss' ],
				'permission_callback' => [ $router, 'permissions_admin' ],
			]
		);
	}

	public function handle_claim( \WP_REST_Request $request ) {
		return $this->service->handle_claim( $request );
	}

	public function handle_dismiss( \WP_REST_Request $request ) {
		return $this->service->handle_dismiss( $request );
	}
}
