<?php

declare(strict_types=1);

namespace App\SignDocument\Controller;

use App\DigitalSignature\Controller\SignService;
use App\SignDocument\Api\Request\DigitalSignatureRequest;
use App\SignDocument\Api\Request\SignRequest;
use App\SignDocument\Services\DigitalSignatureService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DigitalSignatureController extends AbstractController
{
    public function __construct(
        private readonly DigitalSignatureService $digitalSignatureService
    ){
    }

    #[Route(path: '/digital/sign', name: 'app.digital.sign',  methods: ['POST'])]
    public function __invoke(Request $request, DigitalSignatureRequest $digitalSignatureRequest): Response
    {
        $token = $request->server->get('HTTP_AUTHORIZATION');

        return new JsonResponse($this->digitalSignatureService->getSignature($digitalSignatureRequest, $token));
    }

}