/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role-account.aurora.yaml
 */
import { IamCreateRoleAccountInput } from '@api/graphql';
import { IamCreateRolesAccountsService } from '@app/iam/role-account';
import { IamRoleAccountFieldSchema } from '@app/iam/role-account/domain';
import { ApplySchema, EmitEvent, HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';

@Injectable()
export class IamCreateRolesAccountsHandler {
  constructor(
    private readonly eventEmitter: EventEmitter2,
    private readonly createService: IamCreateRolesAccountsService,
  ) {}

  @EmitEvent('iam.roleAccount.created', { returnInputPayload: true })
  @ApplySchema(IamRoleAccountFieldSchema)
  async main(payload: IamCreateRoleAccountInput[], handlerMeta?: HandlerMeta): Promise<boolean> {
    await this.createService.main(payload, handlerMeta);

    return true;
  }
}
