/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/application.aurora.yaml
 */
import { OAuthApplicationDto, OAuthUpdateApplicationByIdDto } from '@api/o-auth/application';
import { OAuthUpdateApplicationByIdHandler } from '@app/o-auth/application';
import { Auth } from '@aurora/decorators';
import { Auditing, AuditingMeta, Timezone } from '@aurorajs.dev/core-back';
import { QueryStatement } from '@aurorajs.dev/core-common';
import { Body, Controller, Put } from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[o-auth] application')
@Controller('o-auth/application/update')
@Auth('oAuth.application.update')
export class OAuthUpdateApplicationByIdController {
  constructor(private readonly handler: OAuthUpdateApplicationByIdHandler) {}

  @Put()
  @ApiOperation({ summary: 'Update application by id' })
  @ApiOkResponse({
    description: 'The record has been successfully updated.',
    type: OAuthApplicationDto,
  })
  async main(
    @Body() payload: OAuthUpdateApplicationByIdDto,
    @Body('constraint') constraint?: QueryStatement,
    @Timezone() timezone?: string,
    @Auditing() auditing?: AuditingMeta,
  ) {
    return await this.handler.main(payload, constraint, {
      timezone,
      repositoryOptions: { auditing },
    });
  }
}
