PHP code example of naqel / sdk

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

    

naqel / sdk example snippets


$naqel = new \Naqel\Naqel([
    'use_sandbox' => true,
    'client_id'   => '[YOUR_CLIENT_ID]',
    'password'    => '[YOUR_CLIENT_PASSWORD]',
    'version'     => '9.0',
]);

// Set your address
$clientAddress = (new \Naqel\Models\ClientAddress())
    ->setPhoneNumber('0555555555')
    ->setFirstAddress('King Abdulaziz Street')
    ->setCountryCode('KSA')
    ->setCityCode('RUH');

// Set your contact
$clientContact = (new \Naqel\Models\ClientContact())
    ->setName('Mohammad')
    ->setPhoneNumber('05xxxxxxxx');

// Attach both address and contact to Naqel instance
$naqel->setClientAddress($clientAddress);
$naqel->setClientContact($clientContact);

$consigneeInfo = (new \Naqel\Models\ConsigneeInfo())
    ->setConsigneeName('Abdullah')
    ->setPhoneNumber('05xxxxxxxx')
    ->setAddress('King Salman Street')
    ->setCountryCode('KSA')
    ->setCityCode('RUH');

$manifestShipment = (new \Naqel\Models\ManifestShipment())
    ->setConsigneeInfo($consigneeInfo)
    ->setBillingType(\Naqel\Constants\BillingType::ON_ACCOUNT)
    ->setLoadTypeID(\Naqel\Constants\LoadType::NON_DOCUMENT)
    ->setPiecesCount(1)
    ->setWeight(1.0);

$waybill = \Naqel\Waybill::create($manifestShipment);

$waybill = \Naqel\Waybill::create($waybill->number());

$waybillNumber = $waybill->number();

$sticker = $waybill->printSticker(
    \Naqel\Constants\StickerSize::FourMFourInches
);