/**
 * @aurora-catalyst-generated
 * @source cliter/iam/tenant-account.aurora.yaml
 */
import { IamTenantAccount } from '@api/graphql';
import { IamSequelizeTenantAccountRepository } from '@app/iam/tenant-account';
import { HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';

@Injectable()
export class IamCreateTenantAccountService {
  constructor(private readonly repository: IamSequelizeTenantAccountRepository) {}

  async main(payload: any, handlerMeta?: HandlerMeta): Promise<void> {
    await this.repository.create(payload, {
      createOptions: handlerMeta?.repositoryOptions,
      finderQueryStatement: (aggregate: IamTenantAccount) => ({
        where: {
          tenantId: aggregate.tenantId,
          accountId: aggregate.accountId,
        },
      }),
    });
  }
}
