import { Body, Controller, Get, Param, Post } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Public } from 'src/core/guards'; import { MODULE_NAME } from 'src/core/strings/constants/module.constants'; import { OtpVerificationService } from '../data/services/otp-verification.service'; import { OtpRequestDto, OtpVerifyDto } from './dto/otp-verification.dto'; //TODO implementation auth @ApiTags(`${MODULE_NAME.OTP_VERIFICATIONS.split('-').join(' ')} - data`) @Controller(`v1/${MODULE_NAME.OTP_VERIFICATIONS}`) @Public() export class OtpVerificationController { constructor( private readonly otpVerificationService: OtpVerificationService, ) {} @Post('request') async request(@Body() body: OtpRequestDto) { return await this.otpVerificationService.requestOTP(body); } @Post('verify') async verify(@Body() body: OtpVerifyDto) { return await this.otpVerificationService.verifyOTP(body); } @Get(':ref_or_target_id') async getByPhoneNumber(@Param('ref_or_target_id') ref_or_target_id: string) { return this.otpVerificationService.getActiveOtp(ref_or_target_id); } }