PHP code example of aniket-in / laravel-shiprocket

1. Go to this page and download the library: Download aniket-in/laravel-shiprocket 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/ */

    

aniket-in / laravel-shiprocket example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Shiprocket Credentilas
    |--------------------------------------------------------------------------
    |
    | Here you can set multiple shiprocket credentilas pair.
    | And then use any credential pair by their key i.e. default, second 
    | 
    */

    'credentials' => [
        'default' => [
            'email' => env('SHIPROCKET_EMAIL', '[email protected]'),
            'password' => env('SHIPROCKET_PASSWORD', 'password'),
        ],
        // 'second' => [
        //     'email' => env('SHIPROCKET_SECOND_EMAIL', '[email protected]'),
        //     'password' => env('SHIPROCKET_SECOND_PASSWORD', 'password'),
        // ],
    ],

    
     /*
    |--------------------------------------------------------------------------
    | Shiprocket Credentilas
    |--------------------------------------------------------------------------
    |
    | Here you can set the default credentilas to use by their key.
    | i.e. default, second 
    | 
    */

    'default_credentials' => env('SHIPROCKET_DEFAULT_CREDENTIALS', 'default'),


     /*
    |--------------------------------------------------------------------------
    | Shiprocket Credentilas
    |--------------------------------------------------------------------------
    |
    | Here you can set the behaviour whether to use caching or not for auth tokens.
    | 
    */
    'token_cache' => env('SHIPROCKET_TOKEN_CACHE', true),



    /*
    |--------------------------------------------------------------------------
    | Token Cache Expiry Duration
    |--------------------------------------------------------------------------
    |
    | Here you can set token's cache expiry duration
    | 
    */
    'token_cache_duration' => env('SHIPROCKET_TOKEN_CACHE_DURATION', 86400),

];

use AniketIN\Shiprocket\Facades\Shiprocket;

Shiprocket::getToken();

Shiprocket::withCredential('another-credential-key')->nowCallYourMethod(...);

Shiprocket::order()->all()->json();

$response->body() : string;
$response->json($key = null) : array|mixed;
$response->object() : object;
$response->collect($key = null) : Illuminate\Support\Collection;
$response->status() : int;
$response->ok() : bool;
$response->successful() : bool;
$response->redirect(): bool;
$response->failed() : bool;
$response->serverError() : bool;
$response->clientError() : bool;
$response->header($header) : string;
$response->headers() : array;

Shiprocket::order()->create([
    // refer above url for 

Shiprocket::order()->createChannelSpecific([
    // refer above url for 

Shiprocket::order()->updatePickupAddress([
    // refer above url for 

Shiprocket::order()->updateCustomerAddress([
    // refer above url for 

Shiprocket::order()->update([
    // refer above url for 

Shiprocket::order()->cancelByIds([ 
    // order ids... 
])

Shiprocket::order()->all([ 
    // refer above url for 

Shiprocket::order()->detailsById($orderId)

Shiprocket::courier()->generateAwbForShipment([
    // refer above url for 

Shiprocket::courier()->list([
    // refer above url for 

Shiprocket::courier()->serviceability([
    // refer above url for 

Shiprocket::courier()->internationalServiceability([
    // refer above url for 

Shiprocket::courier()->requestShipmentPickup([
    // refer above url for 

Shiprocket::return()->create([
    // refer above url for 

Shiprocket::return()->all([
    // refer above url for 

Shiprocket::shipment()->all([
    // refer above url for 

Shiprocket::shipment()->detailsById($shipment_id)

Shiprocket::shipment()->cancelByAWBs([123456, 7890123])

Shiprocket::track()->awb($awb)

Shiprocket::track()->multipleAwb($awb_array)

Shiprocket::track()->shipment($shipment_id)

Shiprocket::track()->order($order_id)

Shiprocket::pickupAddress()->all()

Shiprocket::pickupAddress()->create([
    // refer above url for 

Shiprocket::wallet()->getBalance()

Shiprocket::product()->all([
    // refer above url for 

Shiprocket::product()->detailsById($product_id)

Shiprocket::product()->create([
    // refer above url for 
bash
  php artisan vendor:publish --provider="AniketIN\Shiprocket\ShiprocketServiceProvider" --tag="shiprocket-config"