@shipengine/connect-carrier-api
Version:
This is the typescript/javascript definitions for carrier api
34 lines (29 loc) • 1.17 kB
text/typescript
import type { GetRatesRequest, Rate } from '@shipengine/connect-carrier-api';
import type { RatingContext } from './rating-context';
/** A rate request shipment with its corresponding id */
export interface ShipmentAndId {
/** rate_request_identifier for the rate request */
id: string;
/** Shipment for the rate request */
shipment: GetRatesRequest;
}
/** Rate results with its corresponding rate request id */
export interface RateResultsAndId {
/** rate_request_identifier for the corresponding rate request */
id: string;
/** Error, if any */
error?: unknown;
/** Rates for a given rate request */
rates: Rate[];
}
/** Implementation of a carrier */
export interface RatingCarrier {
/** Rate shipments
* @param context Native Rating context that can be used by the implementation to interact with the underlying service
* @param shipment Shipments that should be rated
* @returns List of rates for the given shipments
*/
rateShipments: (context: RatingContext, shipment: ShipmentAndId[]) => Promise<RateResultsAndId[]>;
}
/** Signify a validation error from the carrier */
export class CarrierValidationError extends Error {}