61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
/**
|
|
* Rates API
|
|
*
|
|
* Endpoints for searching shipping rates (both API and CSV-based)
|
|
*/
|
|
|
|
import { post } from './client';
|
|
import type {
|
|
RateSearchRequest,
|
|
RateSearchResponse,
|
|
CsvRateSearchRequest,
|
|
CsvRateSearchResponse,
|
|
AvailableCompaniesResponse,
|
|
FilterOptionsResponse,
|
|
} from '@/types/api';
|
|
|
|
/**
|
|
* Search shipping rates (API-based)
|
|
* POST /api/v1/rates/search
|
|
*/
|
|
export async function searchRates(data: RateSearchRequest): Promise<RateSearchResponse> {
|
|
return post<RateSearchResponse>('/api/v1/rates/search', data);
|
|
}
|
|
|
|
/**
|
|
* Search CSV-based rates with detailed pricing
|
|
* POST /api/v1/rates/search-csv
|
|
*/
|
|
export async function searchCsvRates(data: CsvRateSearchRequest): Promise<CsvRateSearchResponse> {
|
|
return post<CsvRateSearchResponse>('/api/v1/rates/search-csv', data);
|
|
}
|
|
|
|
/**
|
|
* Search CSV-based rates with service level offers (RAPID, STANDARD, ECONOMIC)
|
|
* POST /api/v1/rates/search-csv-offers
|
|
*
|
|
* Generates 3 offers per matching rate:
|
|
* - RAPID: +20% price, -30% transit (most expensive, fastest)
|
|
* - STANDARD: base price and transit
|
|
* - ECONOMIC: -15% price, +50% transit (cheapest, slowest)
|
|
*/
|
|
export async function searchCsvRatesWithOffers(data: CsvRateSearchRequest): Promise<CsvRateSearchResponse> {
|
|
return post<CsvRateSearchResponse>('/api/v1/rates/search-csv-offers', data);
|
|
}
|
|
|
|
/**
|
|
* Get available companies for filtering
|
|
* GET /api/v1/rates/companies
|
|
*/
|
|
export async function getAvailableCompanies(): Promise<AvailableCompaniesResponse> {
|
|
return post<AvailableCompaniesResponse>('/api/v1/rates/companies');
|
|
}
|
|
|
|
/**
|
|
* Get filter options (companies, container types, currencies)
|
|
* GET /api/v1/rates/filters/options
|
|
*/
|
|
export async function getFilterOptions(): Promise<FilterOptionsResponse> {
|
|
return post<FilterOptionsResponse>('/api/v1/rates/filters/options');
|
|
}
|