import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
  Req,
  Query,
} from "@nestjs/common";
import { ProfileService } from "./profile.service";
import { ABHAProfile, Patient } from "./entities/profile.entity";

import { SkipThrottle, ThrottlerGuard } from "@nestjs/throttler";
import { AuthApiKeyGuard } from "src/auth/apiKey.guard";

@Controller("profile")
export class ProfileController {
  constructor(private readonly profileService: ProfileService) {}
  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Post()
  create(@Body() PatientEntity: Patient) {
    return this.profileService.create(PatientEntity);
  }
  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Get("/getDetails")
  findOne(@Query("id") id: string) {
    return this.profileService.findOne(id);
  }

  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Get("/qr/:id")
  findqrOne(@Param("id") id: string) {
    return this.profileService.Patientqr(+id);
  }
  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Patch(":id")
  update(@Param("id") id: string, @Body() PatientEntity: Patient) {
    return this.profileService.update(+id, PatientEntity);
  }
  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Patch("/abhaNumber_update/:id")
  updateAbha(@Param("id") id: string, @Body() PatientEntity: ABHAProfile) {
    return this.profileService.updateAbhaNumber(id, PatientEntity);
  }
  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Delete(":id")
  remove(@Param("id") id: string) {
    return this.profileService.remove(+id);
  }

  @UseGuards(AuthApiKeyGuard, ThrottlerGuard)
  @SkipThrottle()
  @Get("/encrypted-qr/:id")
  findencryptedqrOne(@Param("id") id: string) {
    return this.profileService.Encrypted_Patientqr(+id);
  }
}
