PHP code example of mohannadnaj / smsa-sdk

1. Go to this page and download the library: Download mohannadnaj/smsa-sdk 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/ */

    

mohannadnaj / smsa-sdk example snippets



use SmsaSDK\Smsa;

Smsa::key('my-smsa-key');




namespace App\Providers;

use SmsaSDK\Smsa;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Smsa::key(env('SMSA_PASSKEY'));
    }
}



use SmsaSDK\Smsa;

// set up the key
Smsa::key('my-smsa-key');

// SECOM WSDL address, set by default to the url: http://track.smsaexpress.com/SECOM/SMSAwebService.asmx?wsdl
Smsa::uri('http://track.smsaexpress.com/SECOM/SMSAwebService.asmx?wsdl');

// or just use the setup method
Smsa::setUp(['key' => 'my-smsa-key','uri' => 'http://track.smsaexpress.com/SECOM/SMSAwebService.asmx?wsdl']);

// Set the null values, the ignored arguments in a SECOM method call, to an empty string
Smsa::nullValues('');

}



use SmsaSDK\Smsa;

Smsa::key('my-smsa-key');   // Setting up the SMSA Key

// Since we are not filling all the SECOM method arguments
// as defined in the WSDL, here we are telling SMSA SDK to
// fill the null values by an empty string
Smsa::nullValues(''); 

$shipmentData = [
        'refNo' => 'my_app_name' . time(), // shipment reference in your application
        'cName' => 'Mohannad Najjar', // customer name
        'cntry' => 'SA', // shipment country
        'cCity' => 'JEDDAH', // shipment city, try: Smsa::getRTLCities() to get the supported cities
        'cMobile' => '0555555555', // customer mobile
        'cAddr1' => 'ALNAHDA DIST, ...detailed address here', // customer address
        'cAddr2' => 'ALBAWADI DIST, ...detailed address here', // customer address 2
        'shipType' => 'DLV', // shipment type
        'PCs' => 1, // quantity of the shipped pieces
        'cEmail' => '[email protected]', // customer email
        'codAmt' => '50', // payment amount if it's cash on delivery, 0 if not cash on delivery
        'weight' => '10', // pieces weight
        'itemDesc' => 'Foo Bar', // extra description will be printed
    ];

/** @var SmsaSDK\Methods\addShipmentResponse $shipment */
$shipment = Smsa::addShipment($shipmentData);

$awbNumber = $shipment->getAddShipmentResult();

echo "shipment AWB: " . $awbNumber ;
echo "\r\n";

$status = Smsa::getStatus(['awbNo' => $awbNumber])->getGetStatusResult();

echo "shipment Status: " . $status;
}


use SmsaSDK\SoapClient;

SoapClient::setTestingClient($myMockedClient);
// do stuff will affect the mocked client only..

SoapClient::turnOffTestingClient();
// turn off testing, do stuff with the real soap client

print_r(SoapClient::$lastCall); // whether in testing or not, access all the arguments passed to the SoapClient

 php


use SmsaSDK\Smsa;

$result = Smsa::key('my-smsa-key')
            ->getRTLCities()
            ->getGetRTLCitiesResult()
            ->getAny();

print_r($result);