errandlr-commerce-node
v2.0.0
Published
A package for Errandlr services
Downloads
4
Readme
errandlr-commerce node
The errandlr-commerce-node package is an npm package developed by errandlr.
What is this?
This package allows developers integrate with errandlr services.
Installation
Using npm:
$ npm i errandlr-commerce-node
Initialization
After installation, import the ErrandlrService class from the package:
import { ErrandlrService } from 'errandlr-commerce-node';
OR
const { ErrandlrService } = require('errandlr-commerce-node');
When instantiating the class, pass your server key as an argument:
const errandlr = new ErrandlrService(serverKey);
Note: you export the instantiated object so you can import to any file in your codebase.
Usage
Get estimate - using the instantiated object(errandlr), you can use the get estimate feature by calling
getEstimate
method(sample code below):| Property | Type | Description | | -------- | :------: | :---------------------------------------------------------: | | pickup | required | Pickup object can have id, label or both | | dropoff | required | Dropoff is an array of objects containing id, label or both | | optimize | optional | Defaults to false, useful when you have multiple dropoffs |
// NOTE: pickup and dropoff can have id, label or both. const param = { pickup: { id: 'PLACE ID', // FULL ADDRESS OR GOOGLE PlACE ID label: 'ADDRESS', // FULL ADDRESS e.g. (SPAR Lekki, Palm Springs Road, Lekki, Nigeria }, optimize: true, // useful when you have multiple dropoffs dropoff: [ { id: 'GOOGLE PLACE ID', // e.g. place_id:ChIJpwtSAfr1OxARpPUPvljsXm0 label: 'ADDRESS', // e.g. Ikoyi Bridge, Lekki - Ikoyi Link Bridge, Lagos, Nigeria }, ], }; const response = await errandlr.getEstimate(param);
Create Delivery Request - using the instantiated object(errandlr), you can use the create delivery request feature by calling
createRequest
method(sample code below):| Property | Type | Description | | :------------------: | :------: | :-------------------------------------------------------------------: | | geoId | required | Unique id returned from getEstimate | | name | required | Sender's name | | email | required | Sender's email | | phone | required | Sender's phone | | deliverToInformation | required | Array of objects, each containing information on package and receiver | | state | required | State where package is being delivered | | country | required | Country where package is being delivered | | city | optional | City where package is being delivered | | localGovt | optional | Local Govermment where package is being delivered | | latitude | optional | Latitude of pickup location | | longitude | optional | Longitude of pickup location | | pickupNotes | optional | Pickup note for request |
const param = { geoId: 'GEO ID' // unique id returned from getEstimate response, name: 'SENDER NAME' // name of sender, email: '[email protected]' // email of sender, phone: '+234XXXXXXXXXX' // sender's phone number, deliverToInformation: [ { order: 1, // required e.g. 1 name: 'RECEIVER NAME', // required phone: '+234XXXXXXXXXX', // required packageValue: 1000, // optional e.g. 1000 packageType: 'PACKAGE TYPE', // optional packageDetail: 'PACKAGE DETAIL', // optional deliveryNotes: 'DELIVERY NOTES', // optional } ], state: 'LAGOS', country: 'NIGERIA', city: 'CITY', // e.g. Lekki localGovt: 'LOCAL GOVERNMENT', latitude: 6.5244, // e.g. 6.5244 longitude: 3.3792, // e.g. 3.3792 pickupNotes: 'PICKUP NOTES' // e.g. Pickup at 12pm., } const response = await errandlr.createRequest(param);
Get Delivery Request Status - using the instantiated object(errandlr), you can use the get estimate feature by calling
getStatus
method(sample code below):| Property | Type | Description | | -------- | :------: | :--------------------: | | id | required | Tracking ID of request |
const param = { id: 'TRACKING ID', //e.g. GNEFHZBLT3MSWMR }; const response = await errandlr.getStatus(param);