<?php

namespace Modules\Integracoes\Correios;

use Gestoreasy\Core\Module\ModuleInterface;
use Gestoreasy\Core\Routing\Router;
use Gestoreasy\Core\Http\AuthMiddleware;
use Gestoreasy\Core\Auth\Rbac;
use Modules\Integracoes\Correios\Controllers\CorreiosController;

class Module implements ModuleInterface {
    public function register(Router $router): void {
        $ctrl = new CorreiosController();

        // API - Cálculo de Frete
        $router->post('/api/correios/calcular-frete', [$ctrl, 'calcularFrete'], [AuthMiddleware::requireAuth()]);
        $router->post('/api/correios/rastrear', [$ctrl, 'rastrear'], [AuthMiddleware::requireAuth()]);
        
        // API - Etiquetas
        $router->get('/api/correios/etiquetas', [$ctrl, 'listEtiquetas'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['correios.read'])]);
        $router->post('/api/correios/gerar-etiqueta', [$ctrl, 'gerarEtiqueta'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['correios.manage'])]);
        $router->get('/api/correios/etiquetas/{id}/pdf', [$ctrl, 'downloadPDF'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['correios.read'])]);
    }
}

