export interface Coordinate { latitude: number; longitude: number; } export interface Item { name: string; description?: string; category?: string; value: number; quantity: number; length: number; width: number; height: number; weight: number; } export interface RatesRequest { origin_area_id?: string; destination_area_id?: string; origin_postal_code?: number; destination_postal_code?: number; origin_latitude?: number | string; origin_longitude?: number | string; destination_latitude?: number | string; destination_longitude?: number | string; type?: string; couriers: string; items: Item[]; } export interface Rate { courier: { company: string; name: string; type: string; rate_type: string; amount: number; currency: string; estimated_days?: number; }; origin: { area_id: string; area_name: string; postal_code: number; coordinate?: Coordinate; }; destination: { area_id: string; area_name: string; postal_code: number; coordinate?: Coordinate; }; } export interface RatesResponse { success: boolean; pricing: Rate[]; error?: { message: string; code?: string; }; } export interface Courier { courier_name: string; courier_code: string; courier_service_name: string; courier_service_code: string; description?: string; service_type: string; shipping_type: string; tier?: string; shipment_duration_range?: string; shipment_duration_unit?: string; available_collection_method: string[]; available_for_cash_on_delivery: boolean; available_for_proof_of_delivery: boolean; available_for_instant_waybill_id: boolean; } export interface CouriersResponse { success: boolean; couriers: Courier[]; } export type LocationType = 'origin' | 'destination'; export interface CreateLocationRequest { name: string; contact_name: string; contact_phone: string; address: string; note?: string; postal_code: number; latitude?: number; longitude?: number; type: LocationType; } export interface UpdateLocationRequest { name?: string; contact_name?: string; contact_phone?: string; address?: string; note?: string; postal_code?: number; latitude?: number; longitude?: number; } export interface Location { id: string; name: string; contact_name: string; contact_phone: string; address: string; note?: string; postal_code: number; coordinate?: Coordinate; latitude?: number; longitude?: number; type: LocationType; connected_users?: any[]; owned?: boolean; status?: string; stores?: any[]; created_at: string; updated_at: string; } export interface LocationResponse extends Location { success: boolean; error?: { message: string; code?: string; }; } export interface UpdateLocationResponse { success: boolean; message?: string; location?: Location; error?: { message: string; code?: string; }; } export interface GetAreasRequest { countries: string; input: string; type: 'single' | 'multiple'; } export interface Area { id: string; name: string; postal_code: number; coordinate?: Coordinate; } export interface AreasResponse { success: boolean; areas: Area[]; error?: { message: string; code?: string; }; } export interface CreateDraftOrderRequest { shipper_contact_name?: string; shipper_contact_phone?: string; shipper_contact_email?: string; shipper_organization?: string; origin_contact_name: string; origin_contact_phone: string; origin_address: string; origin_note?: string; origin_postal_code?: number; origin_area_id?: string; origin_coordinate?: Coordinate; destination_contact_name: string; destination_contact_phone: string; destination_contact_email?: string; destination_address: string; destination_note?: string; destination_postal_code?: number; destination_area_id?: string; destination_coordinate?: Coordinate; courier_company?: string; courier_type?: string; courier_insurance?: number; delivery_type?: 'now' | 'schedule'; order_note?: string; metadata?: Record; items: Item[]; } export interface UpdateDraftOrderRequest { courier_company?: string; courier_type?: string; origin_coordinate?: Coordinate; destination_coordinate?: Coordinate; items?: Item[]; [key: string]: any; } export interface DraftOrder { id: string; code?: number; object?: string; shipper?: { contact_name: string; contact_phone: string; contact_email?: string; organization?: string; }; origin: { area_id?: string; address: string; note?: string | null; contact_name: string; contact_phone: string; contact_email?: string | null; coordinate?: Coordinate | { latitude: number | null; longitude: number | null; }; province_name?: string; city_name?: string; district_name?: string; postal_code?: number; collection_method?: string | null; }; destination: { area_id?: string; address: string; note?: string | null; contact_name: string; contact_phone: string; contact_email?: string | null; coordinate?: Coordinate | { latitude: number | null; longitude: number | null; }; province_name?: string; city_name?: string; district_name?: string; postal_code?: number; proof_of_delivery?: { use: boolean; fee: number; note?: string | null; link?: string | null; }; cash_on_delivery?: { payment_method?: string | null; amount?: number | null; amount_currency?: string; note?: string | null; type?: string | null; }; }; courier?: { name?: string | null; phone?: string | null; company?: string | null; type?: string | null; link?: string | null; tracking_id?: string | null; waybill_id?: string | null; insurance?: { amount: number; fee: number; note?: string; amount_currency?: string; fee_currency?: string; }; routing_code?: string | null; }; delivery: { type: string; datetime?: string | null; note?: string | null; distance?: number | null; distance_unit?: string; }; extra?: any[]; tags?: any[]; metadata?: Record | null; items: Array; currency?: string; tax_lines?: any[]; price?: number | null; status?: string; reference_id?: string; invoice_id?: string; user_id?: string; order_id?: string | null; created_at: string; updated_at: string; placed_at?: string | null; ready_at?: string | null; confirmed_at?: string | null; deleted_at?: string | null; } export interface DraftOrderResponse extends DraftOrder { success: boolean; error?: { message: string; code?: string; }; } export interface CreateOrderRequest extends CreateDraftOrderRequest { courier_company: string; courier_type: string; destination_cash_on_delivery?: number; destination_cash_on_delivery_type?: string; } export interface Order extends Omit { message?: string; shipper?: { name: string; email: string; phone: string; organization?: string; }; destination: { area_id?: string; address: string; note?: string | null; contact_name: string; contact_phone: string; contact_email?: string | null; coordinate?: Coordinate | { latitude: number | null; longitude: number | null; }; province_name?: string; city_name?: string; district_name?: string; postal_code?: number; proof_of_delivery?: { use: boolean; fee: number; note?: string | null; link?: string | null; }; cash_on_delivery?: { id?: string | null; amount?: number; fee?: number; amountCurrency?: string; feeCurrency?: string; note?: string | null; type?: string | null; status?: string | null; payment_status?: string; payment_method?: string; }; }; stops?: any[]; courier: { tracking_id?: string; waybill_id?: string; company?: string | null; name?: string | null; phone?: string | null; type?: string | null; link?: string | null; insurance?: { amount: number; fee: number; note?: string; amount_currency?: string; fee_currency?: string; }; routing_code?: string | null; }; items: Array; status: string; tracking_id?: string; waybill_id?: string; draft_order_id?: string | null; return_id?: string | null; } export interface OrderResponse extends Order { success: boolean; error?: { message: string; code?: string; }; } export interface Tracking { id: string; order_id: string; waybill_id?: string; courier: { company: string; name: string; }; status: string; history: TrackingHistory[]; created_at: string; updated_at: string; } export interface TrackingHistory { status: string; note?: string; timestamp: string; location?: string; } export interface TrackingResponse { success: boolean; tracking?: Tracking; error?: { message: string; code?: string; }; } export interface BiteshipConfig { apiKey: string; baseUrl?: string; timeout?: number; }