import { Injectable } from '@nestjs/common';
import { CommerceConnector } from './interfaces/connector.interface';
import { WooCommerceConnector } from './woocommerce/woocommerce.connector';
import { MetaCatalogConnector } from './meta/meta-catalog.connector';

@Injectable()
export class ConnectorFactory {
  getConnector(integrationType: string, credentials: Record<string, any>): CommerceConnector {
    switch (integrationType.toLowerCase()) {
      case 'woocommerce':
        return new WooCommerceConnector(credentials);
      case 'meta_catalog':
      case 'whatsapp_catalog':
      case 'meta':
      case 'whatsapp':
        return new MetaCatalogConnector(credentials);
      default:
        throw new Error(`Integration type '${integrationType}' is not supported yet.`);
    }
  }
}
