/**
 * Carrier Connector Port
 *
 * Defines the interface for carrier API integrations.
 * This is a secondary port (output port) in hexagonal architecture.
 */

import { RateQuote } from '../../entities/rate-quote.entity';

export const CARRIER_CONNECTOR_PORT = 'CarrierConnectorPort';

export interface CarrierRateSearchInput {
  origin: string;
  destination: string;
  containerType: string;
  departureDate: Date;
  quantity?: number;
  mode?: string; // 'FCL' or 'LCL'
  weight?: number; // Weight in kg
  volume?: number; // Volume in CBM
  isHazmat?: boolean; // Hazardous materials flag
  imoClass?: string; // IMO class for hazmat
  hazardous?: boolean;
  reefer?: boolean;
  commodityType?: string;
}

export interface CarrierAvailabilityInput {
  origin: string;
  destination: string;
  containerType: string;
  startDate: Date;
  endDate: Date;
  departureDate?: Date; // Specific departure date
  quantity?: number; // Number of containers
}

export interface CarrierConnectorPort {
  /**
   * Get the carrier name
   */
  getCarrierName(): string;

  /**
   * Get the carrier code
   */
  getCarrierCode(): string;

  /**
   * Search for shipping rates
   */
  searchRates(input: CarrierRateSearchInput): Promise<RateQuote[]>;

  /**
   * Check container availability
   * Returns the number of available containers
   */
  checkAvailability(input: CarrierAvailabilityInput): Promise<number>;

  /**
   * Health check to verify carrier API is accessible
   */
  healthCheck(): Promise<boolean>;
}
