bosta

0.2.0 • Public • Published

Bosta Nodejs Package

The Bosta NodeJs SDK provides convenient access to the Bosta API from applications written in the JavaScript language.

Installation

npm install --save bosta

Usage

Init Bosta Client

const Bosta = require('bosta');
 
const bosta = new Bosta(
    process.env.API_KEY,
    process.env.BASE_URL
);

API_KEY is your integartion api key with bosta, to get an api key you must be registered, here is the registration link Bosta. And BASE_URL is the url to bosta Apis wheither it's staging or production. If BASE_URL is not sent in initialization as parameter it's production by default.

Use initiated bosta client to do the functionality of the following

list utilities
delivery state
const deliveryStates = bosta.deliveryStates;
delivery types to use in shipment creation
const deliveryTypes = bosta.deliveryTypes;
pickup states
const pickupStates = bosta.pickupStates;
pickup timeslots to use in pickup creation
const pickupTimeSlots = bosta.pickupTimeSlots;
Shipments
created shipment
const createdDelivery = await bosta.delivery.createDelivery(
    type,
    specs,
    cod,
    dropOffAddress,
    businessReference,
    receiver,
    notes,
);
 
const deliveryId = createdDelivery._id;
const trackingNumber = createdDelivery.trackingNumber;
update shipment by id
const updatedDeliver = await bosta.deliver.updateDelivery(
    deliveryId,
    updatePayload
);
list all created shipments
const deliveries = await bosta.delivery.getAllDeliveries();
get shipment by tracking number
const delivery = await bosta.delivery.getDeliveryByTrakingNumber(trackingNumber);
track shipment
const trackingHistory = await bosta.delivery.trackDelivery(trackingNumber);
print airwayBill
const airwayBill = await bosta.delivery.printDeliveryAWB(deliveryId);
terminate delivery
await bosta.delivery.terminateDelivery(deliveryId);
pickups
get your pickup location
const pickupLocations = await bosta.pickup.getBusinessPickupLocations();
const businessLocationId = pickupLocations[0]._id;
create pickup
const createdPickup = await bosta.pickup.createPickup(
    businessLocationId,
    scheduledDate,
    scheduledTimeSlot,
    contactPerson
);
 
pickupId = createdPickup.message._id;
update pickup
const updatedPickup = await bosta.pickup.updatePickup(
    pickupId,
    updatePayload
);
get all pickups
const pickupRequests = await bosta.pickup.getAllPickups();
get pickup by id
const pikcupRequest = await bosta.pickup.getPickupById(pickupId);
delete pickup
await bosta.pickup.deletePickup(pickupId);
cities
get all cities to select one of them and its code in shipment
const cities = await bosta.city.getAllCities();
const cityId = cities.find(city => city.name === 'Gharbia')._id;
zones
get zones of the city by city id to use one of them in the shipment
const zones = await bosta.zone.getCityZones(cityId);

Contribution

We are open to, and grateful for, any contributions made by the community. By contributing to Bosta, you agree to abide by the code of conduct.

License

The MIT License (MIT) License.

Package Sidebar

Install

npm i bosta

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

43.3 kB

Total Files

16

Last publish

Collaborators

  • bosta