md-adil/shyplite

SDK for Shyplite shipment service

dev-master 2018-11-05 09:34 UTC

This package is not auto-updated.

Last update: 2024-09-03 13:22:52 UTC


README

shyplite.com

Installing

Composer is the best friend to install any php libraries / dependancies with their dependancies. If you haven't already installed then follow the link Composer

Then run following command in your terminal/command prompt where your application is installed.

composer require md-adil/shyplite dev-master

Login

Before making any request you need to set token first.

Getting token

use Adil\Shyplite\Shyplite;

$congis = [
    'username'=> '<email-id>',
    'password' => '<password>',
    'app_id' => '<app-id>', // Your app's ID
    'seller_id' => '<seller-id>',   // Your seller ID
    'key' => '<key>'
];

$shyplite = new Shyplite($configs); // Constructor takes config array as argument
$response = $shyplite->login();
$shyplite->setToken($response->userToken);

Order

To create order

$orders = $shyplite->order()->add([/*order array provided in official doc*/])
    ->add([/*Add more order not more than 25*/])
    ->create() // finally create order and return array of Order model which hold the values you provided with response id and success status
    // or

foreach($orders as $order) {
    echo $order->id; // response success id
    echo $order->getError(); // if error on particular order
    echo $order->hasError(); // true or false
}

To cancel order

$shyplite->order()->cancel([/* array of order id */])

Shipment

Getting slip

$slip = $shyplite->shipment()->getSlip(/* order id */);

echo $slip->name; // name of slip

echo $slip->download(/* download location */);

Getting manifest

$menifest = $shyplite->shipment()->menifest(/* menifest id provided by getSlip function */);
echo $menifest->name; // name of menifest
echo $menifest->path // path to download menifest
$menifest->download(/*path to download*/);

Service

To check service availability.

$available = $shyplite->service()->availability($sourcePincode, $destinationPincode);

print_r($avaialable);

Configuration

Required:

$config = [
    'username'=> '<email-id>',
    'password' => '<password>',
    'app_id' => '<app-id>', // Your app's ID
    'seller_id' => '<seller-id>',   // Your seller ID
    'key' => '<key>'
];

Default:

protected $configs = [
    'verified_request' => false,
    'base_uri' => 'https://api.shyplite.com',
    'order_uri' => 'order',
    'get_slip_uri' => 'getSlip',
    'availablity_uri' => 'getserviceability',
    'track_uri' => 'track',
    'manifest_uri' => 'getManifestPDF',
    'ordercancel_uri' => 'ordercancel'
];

You can override default configs by providing the key your own config like:

$configs = [
    /* our configs */,
    'verified_request' => true, // Now you need to add certificate to make verified reques.
    'order_uri' => 'orders', // If later on shyplite decide to change their uri.
]

Laravel Integration

Let the laravel know about your plugin.

configs/app.php

    return [

        // providers section.
      
        'providers' => [
            // ...,
            Adil\Shyplite\Laravel\ShypliteServiceProvider::class
        ],

        'aliases' => [

            // ...
            'Shyplite' => Adil\Shyplite\Laravel\Facade\Shyplite::class

        ]
      
    ];

    // use it in your app

Shyplite::setToken($yourtoken);
Shyplite::order()->add()->create();

Now add shyplite specific settings in your configs directory.

configs/shyplite.php

return [
    'username'=> '<email-id>',
    'password' => '<password>',
    'app_id' => '<app-id>', // Your app's ID
    'seller_id' => '<seller-id>',   // Your seller ID
    'key' => '<key>'
];

This is unofficial shyplite sdk for php / laravel.

I appreciate your feedback. If you find any issues please don't forget to letme know either mail me or create github issue. if you like my efforts please dont forget to give star.

Thank you :)