/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/authorization-code.aurora.yaml
 */
import {
  OAuthAuthorizationCodeDto,
  OAuthCreateAuthorizationCodeDto,
} from '@api/o-auth/authorization-code';
import { OAuthCreateAuthorizationCodeHandler } from '@app/o-auth/authorization-code';
import { Auth } from '@aurora/decorators';
import { Timezone } from '@aurorajs.dev/core-back';
import { Body, Controller, Post } from '@nestjs/common';
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[o-auth] authorization-code')
@Controller('o-auth/authorization-code/create')
@Auth('oAuth.authorizationCode.create')
export class OAuthCreateAuthorizationCodeController {
  constructor(private readonly handler: OAuthCreateAuthorizationCodeHandler) {}

  @Post()
  @ApiOperation({ summary: 'Create authorization-code' })
  @ApiCreatedResponse({
    description: 'The record has been successfully created.',
    type: OAuthAuthorizationCodeDto,
  })
  async main(@Body() payload: OAuthCreateAuthorizationCodeDto, @Timezone() timezone?: string) {
    return await this.handler.main(payload, {
      timezone,
    });
  }
}
