bpost
JavaScript API wrapper for bpost track & trace
Installation
Install via yarn
yarn add bpost (--dev)
or npm
npm install bpost (--save-dev)
If you don't use a package manager, you can access bpost
via unpkg (CDN), download the source, or point your package manager to the url.
bpost
is compiled as a collection of CommonJS modules & ES2015 modules for bundlers that support the jsnext:main
or module
field in package.json (Rollup, Webpack 2)
The bpost
package includes precompiled production and development UMD builds in the dist
folder. They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. You can drop a UMD build as a <script>
tag on your page. The UMD builds make bpost
available as a window.bpost
global variable.1
This module was created using the magnificent generator-module-boilerplate.
Usage
setup
import bpost from 'bpost';
const pkg = bpost(`SOMEIDHERE`);
methods
bpost(id: String, ?lang: String = en
)
Object: returns all the available methods on bpost package. You should only need this to instantiate your package. Takes an optional second parameter lang
which is used to return localized values from the API response (this parameter defaults to en
)
events.js
bpost#droppedOffBySender()
Object: returns information when package has been received at source postal point
bpost#availableForPickup()
Boolean: returns true when package is available for pickup
getStatus.js
bpost#getStatus()
Object: returns the currently active step
homeDeliveryOptions.js
bpost#availableFrom()
Object: returns the earliest time and day that a package can be picked up after absence
bpost#availableTo()
Object: returns the latest time and day that a package can be picked up after absence
bpost#availableFromTo()
String: returns a formatted string stating the period (in days) a package can be picked up after absence
(e.g "Available from 2016-11-23 to 2016-12-07"
)
bpost#attemptedDelivery()
Object: returns the time and day that delivery was attempted but receiver was absent
bpost#actualDelivery()
Object: returns the time and day when a package was picked up from the postal point, receiving the absently delivered package
packageInfo.js
bpost#getPackageWeight()
Number: returns the package weight in grams
bpost#deliveryMethod()
String: returns the requested delivery method
(e.g "POSTAL_POINT"
)
bpost#identifier()
Number: returns the internal id for package
❗ this is different from the itemIdentifier param passed to the methods as first argument
bpost#hasRetourOptions()
Boolean: returns true when package is eligible for retour
bpost#receiver(formatted: Boolean)
Object: returns data for the receiver
String: returns a formatted string with receiver data
(eg. "THIBAULT MAEKELBERGH, 8000 BRUGGE, BE"
)
postalPointOptions.js
bpost#sourcePostalPoint()
String: returns the English name for the postal point where your package is delivered by the sender
bpost#destinationPostalPoint()
String: returns the English name for the postal point where your package is delivered for the recipient
bpost#destinationAsAddress()
String: returns a formatted string with the complete destination address
(eg. "Pathoekeweg 73, 8000 Brugge"
)
bpost#openingHours(day: String)
Object: returns opening and closing times on the given day
(eg. { open: "07:00", close: "19:00" }
)
bpost#destinationCoordinate()
Object: returns a 2D lat long coordinate of the destination
(eg. { "longitude": 3.21387, "latitude": 51.23154, }
)
Examples
see the examples
folder. A working example is available on cloud9.
Contributing
We are open to contributions, see CONTRIBUTING.md for more info.
License
The code is available under the MIT license.
1: UMD builds are currently broken due to changes needed in either Rollup or Axios. There is an issue for this here.