78 lines
1.3 KiB
TypeScript
78 lines
1.3 KiB
TypeScript
/**
|
|
* Rates API
|
|
*
|
|
* Rate search API calls
|
|
*/
|
|
|
|
import { apiClient } from './client';
|
|
|
|
export interface RateSearchRequest {
|
|
origin: string;
|
|
destination: string;
|
|
containerType: string;
|
|
mode: 'FCL' | 'LCL';
|
|
departureDate: string;
|
|
weight?: number;
|
|
volume?: number;
|
|
hazmat: boolean;
|
|
imoClass?: string;
|
|
}
|
|
|
|
export interface RateQuote {
|
|
id: string;
|
|
carrier: {
|
|
name: string;
|
|
logo?: string;
|
|
};
|
|
origin: {
|
|
code: string;
|
|
name: string;
|
|
};
|
|
destination: {
|
|
code: string;
|
|
name: string;
|
|
};
|
|
price: {
|
|
amount: number;
|
|
currency: string;
|
|
};
|
|
surcharges: Array<{
|
|
type: string;
|
|
amount: number;
|
|
}>;
|
|
transitDays: number;
|
|
etd: string;
|
|
eta: string;
|
|
route: Array<{
|
|
port: string;
|
|
arrival?: string;
|
|
departure?: string;
|
|
}>;
|
|
availability: number;
|
|
frequency: string;
|
|
vesselType?: string;
|
|
co2Kg?: number;
|
|
}
|
|
|
|
export interface Port {
|
|
code: string;
|
|
name: string;
|
|
country: string;
|
|
}
|
|
|
|
export const ratesApi = {
|
|
/**
|
|
* Search shipping rates
|
|
*/
|
|
async search(data: RateSearchRequest): Promise<RateQuote[]> {
|
|
return apiClient.post<RateQuote[]>('/api/v1/rates/search', data);
|
|
},
|
|
|
|
/**
|
|
* Autocomplete ports
|
|
*/
|
|
async searchPorts(query: string): Promise<Port[]> {
|
|
return apiClient.get<Port[]>(`/api/v1/ports/autocomplete?q=${query}`);
|
|
},
|
|
};
|