/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/client.aurora.yaml
 */
import { OAuthClientDto, OAuthUpdateClientByIdDto } from '@api/o-auth/client';
import { OAuthUpdateClientByIdHandler } from '@app/o-auth/client';
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] client')
@Controller('o-auth/client/update')
@Auth('oAuth.client.update')
export class OAuthUpdateClientByIdController {
  constructor(private readonly handler: OAuthUpdateClientByIdHandler) {}

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