<?php

namespace App\Handlers;

use App\Services\BlocksService;
use Symfony\Component\HttpFoundation\JsonResponse;
use Openguru\OpenCartFramework\Http\Request;

class BlocksHandler
{
    private BlocksService $blocksService;

    public function __construct(BlocksService $blocksService)
    {
        $this->blocksService = $blocksService;
    }

    public function processBlock(Request $request): JsonResponse
    {
        $block = $request->json();

        $data = $this->blocksService->process($block);

        return new JsonResponse(compact('data'));
    }
}
