- verifik.service.ts: email OTP auth, token storage/refresh, RETHUS query by professional - verifik.controller.ts: send-otp, confirm, refresh, rethus/professional/:id endpoints - settings/page.tsx: Verifik connection section (email→OTP→token) - professionals/[id]/page.tsx: Consultar RETHUS button with inline result display Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Controller, Post, Get, Body, Param, Query, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { VerifikService } from './verifik.service';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
|
|
@ApiTags('Verifik')
|
|
@Controller('verifik')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
export class VerifikController {
|
|
constructor(private verifik: VerifikService) {}
|
|
|
|
@Get('status')
|
|
status() { return this.verifik.getStatus(); }
|
|
|
|
@Post('send-otp')
|
|
sendOtp(@Body() body: { email: string }) {
|
|
return this.verifik.sendOtp(body.email);
|
|
}
|
|
|
|
@Post('confirm')
|
|
confirm(@Body() body: { email: string; otp: string }) {
|
|
return this.verifik.confirmOtp(body.email, body.otp);
|
|
}
|
|
|
|
@Post('refresh')
|
|
refresh() { return this.verifik.refreshToken(); }
|
|
|
|
// Query by professional ID — looks up cedula from DB
|
|
@Get('rethus/professional/:id')
|
|
rethusByProfessional(@Param('id') id: string) {
|
|
return this.verifik.queryRethusByProfessional(id);
|
|
}
|
|
|
|
// Direct query by document
|
|
@Get('rethus')
|
|
rethus(
|
|
@Query('documentType') documentType: string,
|
|
@Query('documentNumber') documentNumber: string,
|
|
) {
|
|
return this.verifik.queryRethus(documentType, documentNumber);
|
|
}
|
|
}
|