2.0.0 • Published 9 months ago

errandlr-commerce-node v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

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

  1. Get estimate - using the instantiated object(errandlr), you can use the get estimate feature by calling getEstimate method(sample code below):

    PropertyTypeDescription
    pickuprequiredPickup object can have id, label or both
    dropoffrequiredDropoff is an array of objects containing id, label or both
    optimizeoptionalDefaults 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);
  2. Create Delivery Request - using the instantiated object(errandlr), you can use the create delivery request feature by calling createRequest method(sample code below):

    PropertyTypeDescription
    geoIdrequiredUnique id returned from getEstimate
    namerequiredSender's name
    emailrequiredSender's email
    phonerequiredSender's phone
    deliverToInformationrequiredArray of objects, each containing information on package and receiver
    staterequiredState where package is being delivered
    countryrequiredCountry where package is being delivered
    cityoptionalCity where package is being delivered
    localGovtoptionalLocal Govermment where package is being delivered
    latitudeoptionalLatitude of pickup location
    longitudeoptionalLongitude of pickup location
    pickupNotesoptionalPickup note for request
    const param = {
       geoId: 'GEO ID' // unique id returned from getEstimate response,
       name: 'SENDER NAME' // name of sender,
       email: 'sender@mail.com' // 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);
  3. Get Delivery Request Status - using the instantiated object(errandlr), you can use the get estimate feature by calling getStatus method(sample code below):

    PropertyTypeDescription
    idrequiredTracking ID of request
    const param = {
      id: 'TRACKING ID', //e.g. GNEFHZBLT3MSWMR
    };
    const response = await errandlr.getStatus(param);