message: fix: register multiroles
diff: @@ -92,25 +92,25 @@ export class CreateConnectionHandler implements ICommandHandler<CreateConnection
  tokens
  );
  - const isIssuer = irecOrganization.roles.includes(OrganisationRole.Issuer);
  - const isRegistrant = irecOrganization.roles.includes(OrganisationRole.Registrant);
  - const isParticipant = irecOrganization.roles.includes(OrganisationRole.Participant);
  + const accountTypesToRegister = this.getAccountTypesForOrganizationRoles(
  + irecOrganization.roles
  + );
  - if (isIssuer) {
  - await this.createAccounts(clientId, clientSecret, tokens, organization, [
  - AccountType.Issue
  - ]);
  - } else if (isParticipant) {
  - await this.createAccounts(clientId, clientSecret, tokens, organization, [
  - AccountType.Trade,
  - AccountType.Redemption
  - ]);
  - } else {
  + if (!accountTypesToRegister.length) {
  + const isRegistrant = irecOrganization.roles.includes(OrganisationRole.Registrant);
  if (!isRegistrant) {
  throw new BadRequestException(
  'IREC account organization has to have issuer or registrant or participant role'
  );
  }
  + } else {
  + await this.createAccounts(
  + clientId,
  + clientSecret,
  + tokens,
  + organization,
  + accountTypesToRegister
  + );
  }
  }
  @@ -142,4 +142,21 @@ export class CreateConnectionHandler implements ICommandHandler<CreateConnection
  }
  }
  }
  +
  + private getAccountTypesForOrganizationRoles(roles: OrganisationRole[]): AccountType[] {
  + const isIssuer = roles.includes(OrganisationRole.Issuer);
  + const isParticipant = roles.includes(OrganisationRole.Participant);
  +
  + const accountTypes: AccountType[] = [];
  +
  + if (isIssuer) {
  + accountTypes.push(AccountType.Issue);
  + }
  + if (isParticipant) {
  + accountTypes.push(AccountType.Redemption);
  + accountTypes.push(AccountType.Trade);
  + }
  +
  + return accountTypes;
  + }
  }
  