@buun_group/interparcel-api-sdk
Version:
Interparcel API SDK for Node.js
186 lines (177 loc) • 5.63 kB
TypeScript
interface AddressDetails {
city: string;
state?: string;
postcode: string;
country: string;
}
interface ParcelDetails {
weight: number;
length: number;
width: number;
height: number;
}
interface FilterOptions {
serviceLevel?: Array<'standard' | 'express' | 'timed' | 'sameday' | 'pallet'>;
carriers?: string[];
services?: string[];
pickupType?: Array<'collection' | 'dropoff'>;
}
interface QuoteRequest {
collection: AddressDetails;
delivery: AddressDetails;
filter?: FilterOptions;
parcels: ParcelDetails[];
}
interface ServicePrice {
total: number;
currency: string;
tax: number;
}
interface ServiceRestrictions {
maximumWeight?: number;
maximumLength?: number;
}
interface ServiceDelivery {
daysFrom: number;
daysTo: number;
}
interface QuoteResponseItem {
id: string;
carrier: string;
name: string;
service: string;
serviceLevel: string;
price: ServicePrice;
currency: string;
taxable: boolean;
includedCover: number;
maxCover: number;
printerNeeded: boolean;
restrictions: ServiceRestrictions;
pickupType: 'collection' | 'dropoff';
delivery: ServiceDelivery;
}
interface QuoteSuccessResponse {
status: 0;
services: QuoteResponseItem[];
}
interface QuoteErrorResponse {
status: 1;
errorMessage: string;
errorCode: string;
}
type QuoteResponse = QuoteSuccessResponse | QuoteErrorResponse;
declare function getQuote(apiKey: string, data: QuoteRequest): Promise<QuoteResponse>;
interface ShipmentAddress {
name: string;
company?: string;
add1: string;
add2?: string;
city: string;
state?: string;
postcode: string;
country: string;
telephone: string;
email: string;
}
interface ShipmentParcel {
weight: number;
length: number;
width: number;
height: number;
}
interface CustomsItem {
parcel: number;
description: string;
hsCode: string;
quantity: number;
value: string;
currency: string;
country: string;
}
interface CustomsInfo {
taxStatus: number;
reasonForExport: number;
senderEoriNumber?: string;
receiverEoriNumber?: string;
iossNumber?: string;
items: CustomsItem[];
}
interface PickupDetails {
date: string;
earliest: string;
latest: string;
}
interface ShipmentRequest {
validate: boolean;
reference: string;
collection: ShipmentAddress;
delivery: ShipmentAddress;
parcels: ShipmentParcel[];
contents?: string;
value?: number;
service?: string;
pickup?: PickupDetails;
transitCover?: boolean;
customs?: CustomsInfo;
}
interface ShipmentSuccessResponse {
status: 0;
shipmentId: string;
trackingNumber: string;
labelUrl: string;
}
interface ShipmentErrorResponse {
status: 1;
errorMessage: string;
errorCode: string;
}
type ShipmentResponse = ShipmentSuccessResponse | ShipmentErrorResponse;
declare function addShipment(apiKey: string, data: ShipmentRequest): Promise<ShipmentResponse>;
interface TrackShipmentRequest {
tracking_number: string;
}
interface TrackingEvent {
date: string;
time: string;
event: string;
location: string;
status: 'B' | 'T' | 'O' | 'D';
}
interface TrackingResponse {
status: number;
service: string;
currentStatus: 'B' | 'T' | 'O' | 'D';
dateSent: string;
dateDelivered?: string;
timeDelivered?: string;
signedForName?: string;
events: TrackingEvent[];
}
interface TrackingErrorResponse {
status: 1;
errorMessage: string;
errorCode: string;
}
type TrackingResult = TrackingResponse | TrackingErrorResponse;
declare function trackParcel(apiKey: string, trackingNumber: string): Promise<TrackingResult>;
interface InterparcelService {
readonly name: string;
readonly code: string;
readonly type: InterparcelServiceType;
}
interface InterparcelCountry {
readonly name: string;
readonly code: string;
}
type InterparcelServiceType = 'Pallet' | 'Standard' | 'Express' | 'Same Day' | 'Timed';
type InterparcelServiceLevel = 'standard' | 'express' | 'timed' | 'sameday' | 'pallet';
type InterparcelPickupType = 'collection' | 'dropoff';
declare const DOMESTIC_SERVICE_TYPES: ReadonlyArray<InterparcelServiceType>;
declare const INTERNATIONAL_SERVICE_TYPES: ReadonlyArray<InterparcelServiceType>;
declare const SERVICE_LEVELS: ReadonlyArray<InterparcelServiceLevel>;
declare const PICKUP_TYPES: ReadonlyArray<InterparcelPickupType>;
declare const AUSTRALIA_DOMESTIC_SERVICES: ReadonlyArray<InterparcelService>;
declare const INTERNATIONAL_SERVICES: ReadonlyArray<InterparcelService>;
declare const COUNTRIES: ReadonlyArray<InterparcelCountry>;
export { AUSTRALIA_DOMESTIC_SERVICES, type AddressDetails, COUNTRIES, type CustomsInfo, type CustomsItem, DOMESTIC_SERVICE_TYPES, type FilterOptions, INTERNATIONAL_SERVICES, INTERNATIONAL_SERVICE_TYPES, type InterparcelCountry, type InterparcelPickupType, type InterparcelService, type InterparcelServiceLevel, type InterparcelServiceType, PICKUP_TYPES, type ParcelDetails, type PickupDetails, type QuoteErrorResponse, type QuoteRequest, type QuoteResponse, type QuoteResponseItem, type QuoteSuccessResponse, SERVICE_LEVELS, type ServiceDelivery, type ServicePrice, type ServiceRestrictions, type ShipmentAddress, type ShipmentErrorResponse, type ShipmentParcel, type ShipmentRequest, type ShipmentResponse, type ShipmentSuccessResponse, type TrackShipmentRequest, type TrackingErrorResponse, type TrackingEvent, type TrackingResponse, type TrackingResult, addShipment, getQuote, trackParcel };