/**
 * @aurora-catalyst-generated
 * @source cliter/iam/account.aurora.yaml
 */
import { IamAccount, IamCreateAccountInput } from '@api/graphql';
import { IamCreateAccountHandler } from '@app/iam/account';
import { Auth } from '@aurora/decorators';
import { Auditing, AuditingMeta, CurrentAccount, Timezone } from '@aurorajs.dev/core-back';
import { Args, Mutation, Resolver } from '@nestjs/graphql';

@Resolver()
@Auth('iam.account.create')
export class IamCreateAccountResolver {
  constructor(private readonly handler: IamCreateAccountHandler) {}

  @Mutation('iamCreateAccount')
  async main(
    @CurrentAccount() currentAccount: IamAccount,
    @Args('payload') payload: IamCreateAccountInput,
    @Timezone() timezone?: string,
    @Auditing() auditing?: AuditingMeta,
  ): Promise<IamAccount> {
    return await this.handler.main(currentAccount, payload, {
      timezone,
      repositoryOptions: { auditing },
    });
  }
}
