/**
 * 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);
}

/**
 * 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');
}
