/**
 * Maersk API Types
 *
 * Type definitions for Maersk API requests and responses
 */

export interface MaerskRateSearchRequest {
  originPortCode: string;
  destinationPortCode: string;
  containerSize: string; // '20', '40', '45'
  containerType: string; // 'DRY', 'REEFER', etc.
  cargoMode: 'FCL' | 'LCL';
  estimatedDepartureDate: string; // ISO 8601
  numberOfContainers?: number;
  cargoWeight?: number; // kg
  cargoVolume?: number; // CBM
  isDangerousGoods?: boolean;
  imoClass?: string;
}

export interface MaerskRateSearchResponse {
  searchId: string;
  searchDate: string;
  results: MaerskRateResult[];
}

export interface MaerskRateResult {
  quoteId: string;
  routeDetails: {
    origin: MaerskPort;
    destination: MaerskPort;
    transitTime: number; // days
    departureDate: string; // ISO 8601
    arrivalDate: string; // ISO 8601
  };
  pricing: {
    oceanFreight: number;
    currency: string;
    charges: MaerskCharge[];
    totalAmount: number;
  };
  equipment: {
    type: string;
    quantity: number;
  };
  schedule: {
    routeSchedule: MaerskRouteSegment[];
    frequency: string;
    serviceString: string;
  };
  vesselInfo?: {
    name: string;
    type: string;
    operator: string;
  };
  bookingDetails: {
    validUntil: string; // ISO 8601
    equipmentAvailability: number;
  };
  sustainability?: {
    co2Emissions: number; // kg
    co2PerTEU: number;
  };
}

export interface MaerskPort {
  unlocCode: string;
  cityName: string;
  countryName: string;
  countryCode: string;
}

export interface MaerskCharge {
  chargeCode: string;
  chargeName: string;
  amount: number;
  currency: string;
}

export interface MaerskRouteSegment {
  sequenceNumber: number;
  portCode: string;
  portName: string;
  countryCode: string;
  arrivalDate?: string;
  departureDate?: string;
  vesselName?: string;
  voyageNumber?: string;
  transportMode: 'VESSEL' | 'TRUCK' | 'RAIL';
}

export interface MaerskAvailabilityRequest {
  origin: string;
  destination: string;
  containerType: string;
  departureDate: string;
  quantity: number;
}

export interface MaerskAvailabilityResponse {
  availability: number;
  validUntil: string;
}

export interface MaerskErrorResponse {
  errorCode: string;
  errorMessage: string;
  timestamp: string;
  path: string;
}
