PHP code example of seshac / laravel-shiprocket-api

1. Go to this page and download the library: Download seshac/laravel-shiprocket-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

seshac / laravel-shiprocket-api example snippets


return [
    /*
    |--------------------------------------------------------------------------
    | Default Shiprocket Credentilas
    |--------------------------------------------------------------------------
    |
    | Here you can set the default shiprocket credentilas. However, you can pass the credentials while connecting to shiprocket client
    | 
    */

    'credentials' => [
        'email' => env('SHIPROCKET_EMAIL', '[email protected]'),
        'password' => env('SHIPROCKET_PASSWORD', 'password'),
    ],
  

   /*
    |--------------------------------------------------------------------------
    | Default output response type
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the output response you need.
    | 
    | Supported: "collection" , "object", "array"
    | 
    */
    
    'responseType' => 'collection',  
];

use Seshac\Shiprocket\Shiprocket;
.
.
.

$loginDetails =  Shiprocket::login([
    'email' => '[email protected]', 
    'password' => 'example'
])
// if you added credentials at shiprocket.php config file no need to pass credentials

use Seshac\Shiprocket\Shiprocket;
.
.
.

$token =  Shiprocket::getToken();//  if you added credentials at shiprocket.php config

$token =  Shiprocket::getToken();
$orderDetails = [
        // refer above url for rs($orderDetails);


$token =  Shiprocket::getToken();
$orderId = 16167171;
$response =  Shiprocket::order($token)->find($orderId);


$orderDetails = [
    // refer above url for se =  Shiprocket::order($token)->create($orderDetails);

$orderDetails = [
    // refer above url for  =  Shiprocket::order($token)->create($orderDetails,$channelSpecificOrder);

$orderDetails = [
    // refer aboce url for uickCreate($orderDetails);

$ids = [12345,12346]; 
$response =  Shiprocket::order($token)->cancel(['ids' => $ids]);
   
$orderDetails = [
    'order_id' => [12345,123456 ]
    'pickup_location' => 'location name'
];
$response =  Shiprocket::order($token)->updatePickupLocation($orderDetails);

$data = [
    'shipment_id' => '',
    'courier_id' => ''
];
$response =  Shiprocket::courier($token)->generateAWB($data);
// for more details visit above url

$pincodeDetails = [
    // for paramets refer obove url.
];
$response =  Shiprocket::courier($token)->checkServiceability($pincodeDetails);

$pincodeDetails = [
    // for paramets refer obove url.
];
$response =  Shiprocket::courier($token)->checkInterNationalServiceability($pincodeDetails);

$pickupDetails = [
    // for paramets refer obove url.
];
$response =  Shiprocket::courier($token)->requestPickup($pickupDetails);

 $filterParam = [];  // you can use sort, sort_by, filter,filter_by
 $shipments = Shiprocket::shipment($token)->get();

$shipemntId = 1232122;
$shipments = Shiprocket::shipment($token)->getSpecific($shipemntId);

$awb = 1234444222; 
$response =  Shiprocket::track($token)->throughAwb($awb);
 

$shipmentId = 123213;
$response =  Shiprocket::track($token)->throwShipmentId($shipmentId);

$orderId = 123213;
$channelID = 121; //optional
$shipment =  Shiprocket::track($token)->throwOrderId($orderId,$channelID);

$newLocation = []; //Refer the above url for ocation($newLocation);

$location = Shiprocket::pickup($token)->getLocations();

$channels = Shiprocket::channel($token)->get();

$shipmentIds = [ 'shipment_id' => [121221,122112] ];
$manifestDetails = Shiprocket::generate($token)->manifest(shipmentIds);

$orderIds = [ 'order_ids' => [121221,122112] ];
$response = Shiprocket::generate($token)->printManifest(orderIds);

$shipmentIds = [ 'shipment_id' => [121221,122112] ];
$response = Shiprocket::generate($token)->label(shipmentIds);

$orderIds = [ 'ids' => [121221,122112] ];
$response = Shiprocket::generate($token)->invoice(orderIds);

 $filterParam = [];  // you can use sort, sort_by, filter,filter_by
 $shipments = Shiprocket::product($token)->get();

$productId = 1232122;
$shipments = Shiprocket::product($token)->getSpecific($productId);

$productDetails = [
    // refer above url for reate($productDetails);

 
 $response = Shiprocket::ndr($this->token)->getShipments();
 
 // EX : GET : https://apiv2.shiprocket.in/v1/external/ndr/all where you can get all the shipments that are in NDR.

 $awb_code = '0212331233322';
 $response = Shiprocket::ndr($this->token)->getSpecificShipment($awb_code);
 
 // GET :  https://apiv2.shiprocket.in/v1/external/ndr/{AWB} Where you can information of specific AWB which is in NDR

 $shipmentDetails = ['awb' => '', 'address_1' => '', 'address2' => '', 'phone' => ''];
 $response = Shiprocket::ndr($this->token)->reattempt($shipmentDetails);
 
 // POST : https://apiv2.shiprocket.in/v1/external/ndr/reattempt?awb=190729394&address1=Dr Nageshwar&address2=opposite Ashok Nagar&phone=9534952626&deferred_date=2020-08-27

 $filterParam = [
    'postcode' => 110030, // Delivery Post Code 
    'sku' => "SKU name",
    'quantity' => 1, //Quantity in numbers
 ];  
 $response = Shiprocket::warehouse($this->token)->checkServiceability($filterParam);
 
 // EX : https://apiv2.shiprocket.in/v1/warehouse/srf-serviceability?postcode=784001&sku=Baby-socket&quantity=1
 // Response :  ['serviceability'=>true,'etd'=>'2020-12-06']
bash
php artisan vendor:publish --provider="Seshac\Shiprocket\ShiprocketServiceProvider" --tag="config"
 php
$awbs = ["788830567028","788829354408"];
$response =  Shiprocket::track($token)->throwMultipleAwb($awb);