<?php

namespace Fotogenic_AI;

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

final class Rest_Configuration {
    private Service_Configuration $service;

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

    public function register_routes( Rest_Router $router ): void {
        $router->register_route(
            'fotogenic-ai/v1',
			'/studio/configuration',
            [
                'methods'             => 'GET',
				'callback'            => [ $this, 'handle_configuration' ],
                'permission_callback' => [ $router, 'permissions_generate' ],
            ]
        );

        $router->register_route(
            'fotogenic-ai/v1',
			'/settings/configuration/refresh',
            [
                'methods'             => 'POST',
                'callback'            => [ $this, 'handle_configuration_refresh' ],
                'permission_callback' => [ $router, 'permissions_generate' ],
            ]
        );
    }

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

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