Giter VIP home page Giter VIP logo

bosta-php's Introduction

Bosta PHP SDK

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

Table of Contents

APIs Documentation

Installation

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

$ composer require bosta/bosta-sdk

Usages

  • Environment Variable Config

    $stgBaseUrl = 'https://stg-app.bosta.co';
    $prodBaseUrl = 'https://app.bosta.co';
    
    putenv("API_KEY=$your api key");
    putenv("BASE_URL=$your base url");
  • Bosta Client

    require __DIR__ . '/vendor/autoload.php';
    use Bosta\Bosta;
    $bosta = new Bosta(getenv("API_KEY"), getenv("BASE_URL"));
  • Pickup Client

    use Bosta\Utils\ContactPerson;
    
    /**
    * List Pickup Request
    *
    * @param int $pageNumber = 0
    * @return \stdClass
    */
    try {
        $list = $bosta->pickup->list(0);
        echo "list: \n";
        var_dump($list);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Get Pickup Request
    *
    * @param string $pickupRequestId = 070000000386
    * @return \stdClass
    */
    try {
        $get = $bosta->pickup->get('070000000386');
        echo "get: \n";
        var_dump($get);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Delete Pickup Request
    *
    * @param string $pickupRequestId = 070000000386
    * @return string
    */
    try {
        $delete = $bosta->pickup->delete('070000000386');
        echo "delete: \n";
        var_dump($delete);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Create ContactPerson Instance
    *
    * @param string $name = aliaa123
    * @param string $phone = 01209847552
    * @param string $email = [email protected]
    */
    $contactPerson = new ContactPerson("aliaa123", "01209847552", '[email protected]');
    
    /**
    * Get Pickup Locations to use its id in create pickup Request
    */
    try {
        $listPickupLocations = $bosta->pickupLocation->list();
        echo "listPickupLocations: \n";
        var_dump($listPickupLocations);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Create Pickup Request
    *
    * @param string $scheduledDate = 2020-09-30 (YYYY-MM-DD)
    * @param string $scheduledTimeSlot = 10:00 to 13:00 || 13:00 to 16:00
    * @param \Bosta\Utils\ContactPerson $contactPerson
    * @param string $businessLocationId = SkIvXQn_a
    * @param string $notes = ''
    * @param int $noOfPackages = 0
    * @return \stdClass
    */
    try {
        $create = $bosta->pickup->create('2020-09-30', '10:00 to 13:00', $contactPerson, 'SkIvXQn_a', '', 0);
        echo "create: \n";
        var_dump($create);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    
    /**
    * Update Pickup Request
    *
    * @param string $pickupRequestId = 070000000386
    * @param string $scheduledDate = 2020-09-29 (YYYY-MM-DD)
    * @param string $scheduledTimeSlot = 10:00 to 13:00 || 13:00 to 16:00
    * @param \Bosta\Utils\ContactPerson $contactPerson
    * @param string $businessLocationId = SkIvXQn_a
    * @param string $notes = ''
    * @param int $noOfPackages = 0
    * @return string
    */
    try {
        $update = $bosta->pickup->update('070000000386', '2020-09-29', '10:00 to 13:00', $contactPerson, 'SkIvXQn_a', '', 0);
        echo "update: \n";
        var_dump($update);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
  • Delivery Client

    use Bosta\Utils\Receiver;
    use Bosta\Utils\DropOffAddress;
    
    /**
    * List Deliveries
    *
    * @param int $pageNumber = 0
    * @param int $pageLimit = 50
    * @return \stdClass
    */
    try {
        $list = $bosta->delivery->list(0, 50);
        echo "list: \n";
        var_dump($list);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * get Delivery
    *
    * @param string $trackingNumber = 3082253
    * @return \stdClass
    */
    try {
        $get = $bosta->delivery->get('3082253');
        echo "get: \n";
        var_dump($get);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Delete Delivery
    *
    * @param string $deliveryId = cZTghcUW6E
    * @return void
    */
    try {
        $delete = $bosta->delivery->delete('cZTghcUW6E');
        echo "delete: \n";
        var_dump($delete);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Create Receiver Instance
    *
    * @param string $firstName = BostaDevTeam
    * @param string $lastName = lastname
    * @param string $phone = 01025810012
    */
    $receiver = new Receiver("BostaDevTeam", "lastname", '01025810012');
    
    /**
    * Create DropOffAddress Instance
    *
    * @param int $buildingNumber = 1
    * @param string $firstLine = firstLine
    * @param string $city = EG-05
    * @param string $zone = Dakahlia
    */
    $dropOffAddress = new DropOffAddress(1, "firstLine", "EG-05", 'Dakahlia');
    
    /**
    * Create Delivery
    *
    * @param int $type = 10
    * @param \Bosta\Utils\DropOffAddress $dropOffAddress
    * @param \Bosta\Utils\Receiver $receiver
    * @param string $notes = ''
    * @param int $cod = 0
    * @return \stdClass
    */
    try {
        $create = $bosta->delivery->create(10, $dropOffAddress, $receiver, '', 0);
        echo "create: \n";
        var_dump($create);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    
    /**
    * Create Receiver Instance
    *
    * @param string $firstName = BostaDevTeam
    * @param string $lastName = lastname
    * @param string $phone = 01025810012
    */
    $receiver = new Receiver("BostaDevTeam", "lastname", '01025810012');
    
    /**
    * Create DropOffAddress Instance
    *
    * @param int $buildingNumber = 1
    * @param string $firstLine = firstLine
    * @param string $city = EG-05
    * @param string $zone = Dakahlia
    */
    $dropOffAddress = new DropOffAddress(1, "firstLine", "EG-05", 'Dakahlia');
    
    /**
    * Update Delivery
    *
    * @param string $deliveryId = Dsu5bShCHK
    * @param \Bosta\Utils\DropOffAddress $dropOffAddress
    * @param \Bosta\Utils\Receiver $receiver
    * @param string $notes = ''
    * @param int $cod = 10
    * @return string
    */
    try {
        $update = $bosta->delivery->update('Dsu5bShCHK', $dropOffAddress, $receiver, '', 10);
        echo "update: \n";
        var_dump($update);
        echo "------------------------------------------ \n";
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }

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.

bosta-php's People

Contributors

aliaasayed avatar mohllal avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.