UNPKG

postnl-sdk

Version:

Unofficial PostNL SDK for Node.js inspired by Resend

402 lines (388 loc) 11.1 kB
declare enum Type { '2S' = "2S", '3S' = "3S", 'CC' = "CC", 'CP' = "CP", 'CD' = "CD", 'CF' = "CF", 'LA' = "LA", 'RI' = "RI", 'UE' = "UE" } declare enum ShipmentType { Gift = "Gift", Documents = "Documents", CommercialGoods = "Commercial Goods", CommercialSample = "Commercial Sample", ReturnedGoods = "Returned Goods" } declare enum CurrencyLabellingApi { EUR = "EUR", USS = "USS" } interface GenerateBarcodeOptions { CustomerCode: string; CustomerNumber: string; Type: Type; serie?: string; range?: string; } interface BarcodeResponse { Barcode: string; } interface BarcodeResponseInvalid { errors: { errorMsg: string; errorNumber: string; }; } declare abstract class Endpoint { protected constructor(); abstract registerDiscriminator(): void; } /** * @link https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/barcode/overview * @deprecated Prefer using the `Shipment` class instead. */ declare class Barcode extends Endpoint { private readonly postnl; readonly path = "/shipment/v1_1/barcode"; constructor(postnl: PostNL); generate(payload: GenerateBarcodeOptions): Promise<BarcodeResponse>; registerDiscriminator(): void; } interface LabellingRequest { Customer: LabellingCustomer; LabelSignature?: string; Message: LabellingCustomerMessage; Shipments: LabellingCustomerShipment[]; } interface LabellingCustomer { Address?: CustomerAddress; CollectionLocation?: string; ContactPerson?: string; CustomerCode: string; CustomerNumber: string; Email?: string; Name?: string; } interface LabellingCustomerMessage { MessageID: string; MessageTimeStamp: string; Printertype: string; } interface LabellingCustomerShipment { Addresses: Address[]; Amounts?: Amount[]; Barcode?: string; CodingText?: string; CollectionTimeStampStart?: string; CollectionTimeStampEnd?: string; Contacts?: Contact[]; Content?: string; CostCenter?: string; CustomerOrderNumber?: string; Customs?: Customs; DeliveryAddress?: string; DeliveryDate?: string; Dimension: Dimension; DownPartnerBarcode?: string; DownPartnerID?: string; DownPartnerLocation?: string; Groups?: Group[]; HazardousMaterial?: HazardousMaterial[]; ProductCodeCollect?: string; ProductCodeDelivery: string; ProductOptions?: ProductOption[]; ReceiverDateOfBirth?: string; Reference?: string; ReferenceCollect?: string; Remark?: string; ReturnBarcode?: string; ReturnReference?: string; TimeslotID?: string; ExtraFields?: ExtraField[]; } interface LabellingCustomsContent { Description: string; Quantity: number; Weight: number; Value: number; HSTariffNr?: string; CountryOfOrigin?: string; } interface LabellingResponse { MergedLabels: LabellingMergedLabel[]; ResponseShipments: LabellingResponseShipment[]; } interface LabellingMergedLabel { Barcodes: string[]; Labels: LabellingLabel[]; } interface LabellingLabel { Content: string; OutputType: string; Labeltype: string; } interface LabellingResponseShipment { ProductCodeDelivery?: string; Labels?: LabellingLabel[]; Barcode?: string; Errors?: Object[]; Warnings?: Warning[]; } interface LabellingResponseInvalid { Errors: { Error: string; Code: string; Description: string; }[]; } interface Address { AddressType: string; Area?: string; Buildingname?: string; City: string; CompanyName?: string; Countrycode: string; Department?: string; Doorcode?: string; FirstName?: string; Floor?: string; HouseNr?: string; HouseNrExt?: string; Name?: string; Street?: string; StreetHouseNrExt?: string; Zipcode?: string; } interface CustomerAddress extends Address { } interface Customer { Address?: CustomerAddress; CollectionLocation?: string; ContactPerson?: string; CustomerCode: string; CustomerNumber: string; Email?: string; Name?: string; } interface Amount { AmountType: string; AccountName?: string; BIC?: string; Currency?: string; IBAN?: string; Reference?: string; TransactionNumber?: string; Value: number; } interface Contact { ContactType: string; Email?: string; SMSNr?: string; TelNr?: string; } interface Dimension { Height?: number; Length?: number; Volume?: number; Weight: number; Width?: number; } interface Group { GroupType: string; GroupSequence?: number; GroupCount?: number; MainBarcode: string; } interface HazardousMaterial { ToxicSubstanceCode: string; AdditionalToxicSubstanceCode?: string[]; ADRPoints?: string; TunnelCode?: string; PackagingGroupCode?: string; PackagingGroupDescription?: string; GrossWeight?: string; UNDGNumber?: string; TransportCategoryCode?: string; ChemicalTechnicalDescription?: string; } interface ProductOption { Characteristic: string; Option: string; } interface Warning { Code?: string; Description?: string; } interface ExtraField { Key?: string; Value?: string; } interface Customs { Certificate?: boolean; CertificateNr?: string; License?: boolean; LicenseNr?: string; Invoice?: boolean; InvoiceNr?: string; HandleAsNonDeliverable?: boolean; Currency: CurrencyLabellingApi; ShipmentType: ShipmentType; TrustedShipperID?: string; ImporterReferenceCode?: string; TransactionCode?: string; TransactionDescription?: string; Content: LabellingCustomsContent[]; } interface ConfirmingRequest { Customer: Customer; Message: ConfirmingMessage; Shipments: ConfirmingShipment[]; } interface ConfirmingMessage { MessageID: string; MessageTimeStamp: string; } interface ConfirmingShipment { Addresses: Address[]; Amounts?: Amount[]; Barcode: string; CodingText?: string; CollectionTimeStampStart?: string; CollectionTimeStampEnd?: string; Contacts?: Contact[]; Content?: string; CostCenter?: string; CustomerOrderNumber?: string; Customs?: ConfirmingCustom[]; DeliveryAddress?: string; Dimension?: Dimension; DownPartnerBarcode?: string; DownPartnerID?: string; DownPartnerLocation?: string; Groups?: Group[]; HazardousMaterial?: HazardousMaterial[]; ProductCodeCollect?: string; ProductCodeDelivery: string; ProductOptions?: ProductOption[]; ReceiverDateOfBirth?: string; Reference?: string; ReferenceCollect?: string; Remark?: string; ReturnBarcode?: string; ReturnReference?: string; TimeslotID?: string; } interface ConfirmingCustom { Certificate?: boolean; CertificateNr?: string; License?: boolean; LicenseNr?: string; Invoice?: boolean; InvoiceNr?: string; HandleAsNonDeliverable?: boolean; Currency: string; ShipmentType: string; TrustedShipperID?: string; ImporterReferenceCode?: string; TransactionCode?: string; TransactionDescription?: string; Content: ConfirmingCustomContent[]; } interface ConfirmingCustomContent { Description: string; Quantity: number; Weight: number; Value: number; HSTariffNr?: string; CountryOfOrigin?: string; } interface ConfirmingResponse { ResponseShipments: ConfirmingResponseShipment[]; } interface ConfirmingResponseShipment { Errors?: ConfirmingError[]; Warnings?: Warning[]; Barcode: string; } interface ConfirmingError { Code: string; Description: string; } /** * @link https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/shipment/confirm * @deprecated Prefer using the `Shipment` class instead. */ declare class Confirm extends Endpoint { private readonly postnl; readonly path = "/shipment/v2/confirm"; constructor(postnl: PostNL); confirmShipment(payload: ConfirmingRequest): Promise<ConfirmingResponse>; registerDiscriminator(): void; } /** * @link https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/labelling/overview * @deprecated Prefer using the `Shipment` class instead. */ declare class Label extends Endpoint { private readonly postnl; readonly path = "/shipment/v2_2/label"; constructor(postnl: PostNL); /** * * @link https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/labelling/generate-label * @see https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/shipment/generate-shipment-label */ generate(payload: LabellingRequest, confirm?: boolean): Promise<LabellingResponse>; registerDiscriminator(): void; } declare class Shipment extends Endpoint { private readonly postnl; readonly path = "/shipment/v2_2/label"; constructor(postnl: PostNL); /** * @link https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/shipment/generate-shipment-label */ generateLabel(payload: LabellingRequest, confirm?: boolean): Promise<LabellingResponse>; registerDiscriminator(): void; } interface PostalcodeCheckAddress { city?: string; postalCode?: string; streetName?: string; houseNumber?: number; houseNumberAddition?: string; formattedAddress?: string[]; } declare class Postalcode extends Endpoint { private readonly postnl; readonly path = "/shipment/checkout/v1/postalcodecheck"; constructor(postnl: PostNL); /** * @warning This endpoint doesn't work on the sandbox environment. * @link https://developer.postnl.nl/docs/#/http/api-endpoints/checkout-delivery-options/postalcode-check/checkout-postalcode-check */ check(postalcode: string, housenumber: string, housenumberaddition?: string): Promise<PostalcodeCheckAddress[] | PostalcodeCheckAddress>; registerDiscriminator(): void; } declare class PostNL { readonly key?: string | undefined; private readonly headers; readonly barcode: Barcode; readonly confirm: Confirm; readonly label: Label; readonly shipment: Shipment; readonly postalcode: Postalcode; lastRequest?: { url: string; options?: {}; response: Response; }; constructor(key?: string | undefined); fetchRequest<T>(path: string, options?: {}): Promise<T>; post<T>(path: string, entity?: unknown, options?: {}): Promise<T>; get<T>(path: string, options?: {}): Promise<T>; } export { Barcode, BarcodeResponse, BarcodeResponseInvalid, Confirm, ConfirmingCustom, ConfirmingCustomContent, ConfirmingError, ConfirmingMessage, ConfirmingRequest, ConfirmingResponse, ConfirmingResponseShipment, ConfirmingShipment, GenerateBarcodeOptions, Label, LabellingCustomer, LabellingCustomerMessage, LabellingCustomerShipment, LabellingCustomsContent, LabellingLabel, LabellingMergedLabel, LabellingRequest, LabellingResponse, LabellingResponseInvalid, LabellingResponseShipment, PostNL, Shipment };