Skip to main content

Bosta Python SDK

Project description

Bosta Python SDK

This repository contains the open source Python SDK for integrating Bosta's APIs into your Python application.

Table of Contents

APIs Documentation

Installation

You can install the package via pip. Run the following command:

pip install bostaSDK

Usage

``` python
import os

from bostaSDK.apiClient import ApiClient
from bostaSDK.delivery import list, create, update, track, printAWB, get, terminate
from bostaSDK.pickup import create, list, get, update, delete
from bostaSDK.utils import Receiver, Address, ContactPerson


apiKey=os.environ["BOSTA-API-KEY"]="your api key"
baseUrl=os.environ["BOSTA-BASE-URL"]="bosta base url"

apiClient=ApiClient(apiKey, baseUrl)

# List Deliveries
apiClient.delivery.listAll(list.ListAllDeliveriesRequest(3, 10))

# Create new delivery
reciever=Receiver(
"firstName",
"lastName",
"test@example.com",
 "01090055000")
dropOffAddress=Address("EG-01", "Maadi", "Maadi", "104")
createDeliveryReq=create.CreateDeliveryRequest(
    deliveryTypes['SEND']['code'], 100, dropOffAddress, reciever
)
deliveryId=apiClient.delivery.create(createDeliveryReq)

# Print Airway Bill
apiClient.delivery.printAirWayBill(printAWB.PrintAWBRequest([deliveryId]))

# Track Delivery
apiClient.delivery.track(track.TrackDeliveryRequest(deliveryId))

# Get Delivery
apiClient.delivery.get(get.GetDeliveryDetailsRequest(deliveryId))

# Update Delivery
newReciever=Receiver("user", "test", "test@example.com", "01090055000")
apiClient.delivery.update(
update.UpdateDeliveryRequest(
    deliveryId,
    receiver=newReciever,
     cod=120))

# Terminate Delivery
apiClient.delivery.terminate(
terminate.TerminateDeliveryRequest(deliveryId))

# Create New Pickup
newPickupId=apiClient.pickup.create(
    create.CreatePickupRequest(
    "Mon Nov 7 2021 00:00:00 GMT+0200", apiClient.pickupTimeSlots[0],
    ContactPerson("userName", "01090000000", "example@bosta.co")
    )
)

# List Pickups
apiClient.pickup.listAll(list.ListAllPickupsRequest(2))

# Get Pickup
apiClient.pickup.get(
    get.GetPickupDetailsRequest(newPickupId)
)

# Update Pickup
apiClient.pickup.update(update.UpdatePickupRequest(
    newPickupId, contactPerson=ContactPerson(
"newUser", "010193155922", "user2@bosta.co")
))

# Delete Pickup
apiClient.pickup.delete(delete.DeletePickupRequest(newPickupId))

```

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bostaSDK-1.3.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distributions

bostaSDK-1.3.0-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

bostaSDK-1.3.0-py2-none-any.whl (3.1 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page