ajowi/sendy-fulfilment

This package allows you to connect to the Sendy API to manage shipping fulfilment orders

v1.4.0 2023-01-13 16:23 UTC

This package is auto-updated.

Last update: 2024-04-13 20:08:05 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

This package makes it easy to integrate Sendy Fulfillment Service API Sendy Fulfillment into your php applications.

Contents

Requirements

  • Sign up for a Sendy Fulfillment account
  • Generate your API token in settings

Installation

You can install the package via composer:

composer require ajowi/sendy-fulfilment

Setting up the Sendy Fulfillment service

On Laravel add your Sendy API Token and Endpoint URL to your config/services.php:

// config/services.php
...
'sendy' => [
    'token' => env('SENDY_TOKEN'),
    'endpoint_url' => env('SENDY_ENDPOINT_URL'),
],
...

Usage

Example request for an order's price quotations that return available pricing tiers given pickup and delivery coordinates

    use Ajowi\SendyFulfillment\PriceRequest;

    $data = new array(
        'ecommerce_order' => 'ODR-0000',
        'recepient' => [
                'name' => 'David Ajowi',
                'email' => 'ajowi@daniche.co.ke',
                'phone' => '+254 712345678'
        ],
        'locations' => [
            [
                'type' => 'PICKUP',
                'waypoint_id' => 'd67dbff1-4d57-4266-9c39-481c2d9c76eq',
                'lat' => -1.597429319708498,
                'long' => -1.597429319708498,
                'name' => 'Destination'
            ],
            [
                'type' => 'DELIVERY',
                'waypoint_id' => 'd67dbff1-4d57-4266-9c39-481c2d9c76eq',
                'lat' => -1.597429319708498,
                'long' => -1.597429319708498,
                'name' => 'Destination'
            ]
        ]
    );
    
    /**
     * -----------
     * IMPORTANT
     * -----------
     * If you are not using Laravel, pass the API token/key and Endpoint URL to the constructor like so
     * 
     *  $priceRequest = new PriceRequest('SENDY_API_TOKEN', 'ENDPOINT_URL');
     * 
     */
    $priceRequest = new PriceRequest();
    $priceRequest->initialize($data);

    // Do a price request
    try {
        $response = $priceRequest->send();
        $data = $response->getData();
        echo "Response data : " . print_r($data, true) . "\n";

        if ($response->isSuccessful()) {
            echo "Request was successful!\n";
        }
    } catch (\Exception $e) {
        echo "Message : " . $e->getMessage() . "\n";
    }

Available Operations

  • Price request: Requests for an order's price quotations and returns available pricing tiers given pickup and delivery coordinates
  • Confirm an order: Facilitates confirmation of an order after getting a quotation from the price request endpoint, using the pricing UUIDs
  • Fetch an order: View the items in an order waypoint(s) or path of a given order
  • Cancel an order: Facilitates cancellation of orders.
  • Track an order: Get details about an order which include tracking details, status, rider details et al.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.