/**
 * @aurora-catalyst-generated
 * @source cliter/iam/account.aurora.yaml
 */
import { IamUpdateAccountByIdDto } from '@api/iam/account';
import { IamUpdateMeAccountHandler } from '@app/iam/account';
import { Auth } from '@aurora/decorators';
import { Auditing, AuditingMeta, Timezone } from '@aurorajs.dev/core-back';
import { QueryStatement } from '@aurorajs.dev/core-common';
import { Body, Controller, Post } from '@nestjs/common';
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[iam] account')
@Controller('iam/account/update-me')
@Auth('iam.account.update')
export class IamUpdateMeAccountController {
  constructor(private readonly handler: IamUpdateMeAccountHandler) {}

  @Post()
  @ApiOperation({ summary: 'update-me account' })
  @ApiCreatedResponse({
    description: 'The operation has been successfully executed.',
    type: Boolean,
  })
  async main(
    @Body() payload: IamUpdateAccountByIdDto,
    @Body('constraint') constraint?: QueryStatement,
    @Timezone() timezone?: string,
    @Auditing() auditing?: AuditingMeta,
  ) {
    return await this.handler.main(payload, constraint, {
      timezone,
      repositoryOptions: { auditing },
    });
  }
}
