connectors.service.ts 903 Bytes
Newer Older
Hidde-Jan Jongsma's avatar
Hidde-Jan Jongsma committed
1 2 3 4
import { Injectable } from '@nestjs/common';
import { JolocomService } from './jolocom/jolocom.service';
import { IrmaService } from './irma/irma.service';
import { ConnectorService } from './connector-service.interface';
5
import { Organization } from '../organizations/organization.entity';
Hidde-Jan Jongsma's avatar
Hidde-Jan Jongsma committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

@Injectable()
export class ConnectorsService {
  private connectors: ConnectorService[] = [];

  constructor(
    private jolocomService: JolocomService,
    private irmaService: IrmaService,
  ) {
    this.connectors.push(this.jolocomService);
    this.connectors.push(this.irmaService);
  }

  getConnector(type: string) {
    return this.connectors.find(connector => connector.type === type);
  }
22 23 24 25 26 27 28 29

  async registerOrganization(organization: Organization) {
    await Promise.all(
      this.connectors.map(
        async connector => await connector.registerOrganization(organization),
      ),
    );
  }
Hidde-Jan Jongsma's avatar
Hidde-Jan Jongsma committed
30
}