/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/application-client.aurora.yaml
 */
import { OAuthApplicationClient } from '@api/graphql';
import { OAuthSequelizeApplicationClientRepository } from '@app/o-auth/application-client';
import { HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';

@Injectable()
export class OAuthCreateApplicationClientService {
  constructor(private readonly repository: OAuthSequelizeApplicationClientRepository) {}

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