<?php

namespace Fotogenic_AI;

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

final class Rest_Library {
    private Service_Library $service;

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

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

        $router->register_route(
            'fotogenic-ai/v1',
            '/studio/library/add',
            [
                'methods'             => 'POST',
                'callback'            => [ $this, 'handle_library_add' ],
                'permission_callback' => [ $router, 'permissions_generate_upload' ],
            ]
        );

    }

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

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