Skip to content

Commit

Permalink
Merge pull request #26 from bird-system/master
Browse files Browse the repository at this point in the history
add schema version property.
  • Loading branch information
alfallouji authored Jan 6, 2017
2 parents 063eeb7 + d7ef928 commit 9564078
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion DHL/Entity/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ abstract class Base extends BaseDataType
*/
protected $_isSubobject = null;

/**
* @var string
* The schema version
*/
protected $_schemaVersion = '1.0';

/**
* @var boolean
* Render the schema version or not
Expand Down Expand Up @@ -140,7 +146,7 @@ public function toXML(\XMLWriter $xmlWriter = null)

if ($this->_displaySchemaVersion)
{
$xmlWriter->writeAttribute('schemaVersion', '1.0');
$xmlWriter->writeAttribute('schemaVersion', $this->_schemaVersion);
}

if (null !== $this->_xmlNodeName)
Expand Down
13 changes: 12 additions & 1 deletion DHL/Entity/GB/ShipmentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class ShipmentRequest extends Base
*/
protected $_serviceXSD = 'ShipmentRequest.xsd';

/**
* @var string
* The schema version
*/
protected $_schemaVersion = '1.0';

/**
* Display the schema version
* @var boolean
Expand Down Expand Up @@ -178,7 +184,12 @@ class ShipmentRequest extends Base
'type' => 'string',
'required' => false,
'subobject' => false,
),
),
'NumberOfArchiveDoc' => array(
'type' => 'integer',
'required' => false,
'subobject' => false,
),
'Label' => array(
'type' => 'Label',
'required' => false,
Expand Down

3 comments on commit 9564078

@pardeep7387
Copy link

@pardeep7387 pardeep7387 commented on 9564078 May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear alfallouji,
I am new to Laravel and i got this API to use with laravel. Actually After insatallation Laravel new project where to place this project. There are following folder under DHL-API-master----------------
**
->conf
-->DHL
-->samples
-->vendor

and Files
-->composer
-->init
-->README
**
Now After Laravel installation there is another Vendor and config directories. Now i am confused your project folders need to be copy under laravel project or should made changes if any in composer.json file. When i create controller using php artisan make:controller then i get following error---------------------

**
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'autoloadManager' not found **

Alll is mess for me. Please let me know steps to integrate with laravel DHL_API.

Thanks in Advance from Novice..........

@nikhilordercup
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give example for how to create a dhl pickup.

@SUFYANafsar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function shipping_dhl($product, $pickupLocation, $destinationLocation, $receiver_info, $qty = '1') {
ini_set('display_errors', 'On');
$company_name = $this->crud_model->get_settings_value('general_settings', 'system_name');
// echo "

Got You product:->";
// print_r($product);
// echo "
Got You pickupLocation:->";
// print_r($pickupLocation);
// echo "
Got You destinationLocation:->";
// print_r($destinationLocation);
// echo "
Got You receiver_info:->";
// print_r($receiver_info);
// echo "
Got You qty:->";
// print_r($qty);
// exit;
$cuurency_selected = $this->get_currency_format();
require(APPPATH . 'libraries/DHL/init.php');
$dhl = $config['dhl'];
$sample = new ShipmentRequest(); // Test a ShipmentRequest using DHL XML API
/* Assuming there is a config array variable with id and pass to DHL XML Service /
$sample->SiteID = $dhl['id'];
$sample->Password = $dhl['pass'];
/
Set values of the request */
$sample->MessageTime = date("Y-m-d") . 'T09:30:47-05:00';
$sample->MessageReference = '1234567890123456789012345678901';
$sample->RegionCode = 'AM';
$sample->RequestedPickupTime = 'Y';
$sample->NewShipper = 'Y';
$sample->LanguageCode = 'en';
$sample->PiecesEnabled = 'Y';

    $sample->Billing->ShipperAccountNumber = $dhl['shipperAccountNumber'];
    $sample->Billing->ShippingPaymentType = 'S';
    $sample->Billing->BillingAccountNumber = $dhl['billingAccountNumber'];
    $sample->Billing->DutyPaymentType = 'S';
    $sample->Billing->DutyAccountNumber = $dhl['dutyAccountNumber'];
    /* Shipment charges will be cahrged to this account */
    $sample->Consignee->CompanyName = $receiver_info->firstname . ' ' . $receiver_info->lastname;
    if (!empty($destinationLocation->street_number)) {
        $cosingeeAddress .= $destinationLocation->street_number;
    }
    if (!empty($destinationLocation->route)) {
        $cosingeeAddress .= $destinationLocation->route;
    }
    if (strlen($cosingeeAddress) > 34) {
        $cosingeeAddress = substr($cosingeeAddress, 0, 34);
    }
    $sample->Consignee->addAddressLine($cosingeeAddress);
    if (!empty($destinationLocation->sublocality)) {
        $sample->Consignee->addAddressLine($destinationLocation->sublocality);
    }


    $sample->Consignee->City = $destinationLocation->city;
    $sample->Consignee->PostalCode = $destinationLocation->Postalcode;
    $sample->Consignee->CountryCode = $destinationLocation->CountryCode;
    $sample->Consignee->CountryName = $destinationLocation->country;


    $sample->Consignee->Contact->PersonName = $receiver_info->firstname . ' ' . $receiver_info->lastname;
    $sample->Consignee->Contact->PhoneNumber = $receiver_info->phone;
    $sample->Consignee->Contact->PhoneExtension = '';
    $sample->Consignee->Contact->FaxNumber = $receiver_info->phone;
    $sample->Consignee->Contact->Telex = $receiver_info->phone;
    $sample->Consignee->Contact->Email = $receiver_info->email;

    $sample->Commodity->CommodityCode = 'cc';
    $sample->Commodity->CommodityName = 'cn';

//
$sample->Dutiable->DeclaredValue = '10.00';
$sample->Dutiable->DeclaredCurrency = $cuurency_selected->code;
$sample->Dutiable->ScheduleB = '3002905110';
$sample->Dutiable->ExportLicense = 'D123456';
$sample->Dutiable->ShipperEIN = '112233445566';
$sample->Dutiable->ShipperIDType = 'S';
$sample->Dutiable->ImportLicense = 'ALFAL';
$sample->Dutiable->ConsigneeEIN = 'ConEIN2123';
$sample->Dutiable->TermsOfTrade = 'DTP';
$sample->Reference->ReferenceID = 'AM international shipment';
$sample->Reference->ReferenceType = 'St';
if ($qty > 1) {
$sample->ShipmentDetails->NumberOfPieces = $product['qty'];
$weight = '';
for ($x = 1; $x <= $product['qty']; $x++) {
$weight += $product['weight'];
}
$piece = new Piece();
$piece->PieceID = $product['product_id'];
$piece->PackageType = 'EE';
$piece->Weight = round($weight);
$piece->DimWeight = round($weight);
$piece->Width = round($product['width']);
$piece->Height = round($product['height']);
$piece->Depth = round($product['length']);
$sample->ShipmentDetails->addPiece($piece);
} else {
$sample->ShipmentDetails->NumberOfPieces = 1;
$piece = new Piece();
$piece->PieceID = $product['product_id'];
$piece->PackageType = 'EE';
$piece->Weight = round($product['weight']);
$piece->DimWeight = round($product['weight']);
$piece->Width = round($product['width']);
$piece->Height = round($product['height']);
$piece->Depth = round($product['length']);
$sample->ShipmentDetails->addPiece($piece);
$weight = $product['weight'];
}

    /*  if ($qty > 1) {
      $sample->ShipmentDetails->NumberOfPieces = $product['qty'];
      for ($x = 1; $x <= $product['qty']; $x++) {
      $piece = new Piece();
      $piece->PieceID = $x;
      $piece->PackageType = 'EE';
      $piece->Weight = round($product['weight']);
      $piece->DimWeight = round($product['weight']);
      $piece->Width = round($product['width']);
      $piece->Height = round($product['height']);
      $piece->Depth = round($product['length']);
      $sample->ShipmentDetails->addPiece($piece);
      $weight += $product['weight'];
      }
      } else {
      $sample->ShipmentDetails->NumberOfPieces = 1;
      $piece = new Piece();
      $piece->PieceID = 1;
      $piece->PackageType = 'EE';
      $piece->Weight = round($product['weight']);
      $piece->DimWeight = round($product['weight']);
      $piece->Width = round($product['width']);
      $piece->Height = round($product['height']);
      $piece->Depth = round($product['length']);
      $sample->ShipmentDetails->addPiece($piece);
      $weight = $product['weight'];
      }
     */

    $sample->ShipmentDetails->Weight = $weight;
    $sample->ShipmentDetails->WeightUnit = 'L';
    $sample->ShipmentDetails->GlobalProductCode = 'P';
    $sample->ShipmentDetails->LocalProductCode = 'P';
    $sample->ShipmentDetails->Date = date('Y-m-d');
    $sample->ShipmentDetails->Contents = 'AM international shipment contents';
    $sample->ShipmentDetails->DoorTo = 'DD';
    $sample->ShipmentDetails->DimensionUnit = 'I';
    $sample->ShipmentDetails->InsuredAmount = '1295.00';
    $sample->ShipmentDetails->PackageType = 'EE';
    $sample->ShipmentDetails->IsDutiable = 'N';
    $sample->ShipmentDetails->CurrencyCode = 'SAR';


    /* shipper params */
    if ($pickupLocation['type'] == 'vendor') {
        $sample->Shipper->ShipperID = $pickupLocation['data']->vendor_id;
        $company = $pickupLocation['data']->company;
        if (empty($company)) {
            $company = $pickupLocation['data']->name;
        }
        $sample->Shipper->CompanyName = $company;
        $sample->Shipper->RegisteredAccount = '751008818';
        $shiperAddres = $pickupLocation['data']->address1 . ' ' . $pickupLocation['data']->address2;
        if (strlen($shiperAddres) > 34) {
            $shiperAddres = substr($shiperAddres, 0, 34);
        }
        $sample->Shipper->addAddressLine($shiperAddres);
        $sample->Shipper->addAddressLine($pickupLocation['data']->city);
        $sample->Shipper->City = $pickupLocation['data']->city;
        $sample->Shipper->Division = $pickupLocation['data']->state;
        $sample->Shipper->DivisionCode = '';
        $sample->Shipper->PostalCode = $pickupLocation['data']->zip;
        $sample->Shipper->CountryCode = $this->db->get_where('countrie', array('name' => $pickupLocation['data']->country))->row()->country_code;
        $sample->Shipper->CountryName = $pickupLocation['data']->country;
        $sample->Shipper->Contact->PersonName = $pickupLocation['data']->name;
        $sample->Shipper->Contact->PhoneNumber = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->PhoneExtension = '';
        $sample->Shipper->Contact->FaxNumber = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->Telex = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->Email = $pickupLocation['data']->email;
    } else if ($pickupLocation['type'] == 'admin') {
        $sample->Shipper->ShipperID = $pickupLocation['data']->admin_id;
        $company = $pickupLocation['data']->company;
        if (empty($company)) {
            $company = $pickupLocation['data']->name;
        }
        $sample->Shipper->CompanyName = $company;

        $sample->Shipper->RegisteredAccount = '751008818';
        $shiperAddres = $pickupLocation['data']->address1 . ' ' . $pickupLocation['data']->address2;
        if (strlen($shiperAddres) > 34) {
            $shiperAddres = substr($shiperAddres, 0, 34);
        }
        $sample->Shipper->addAddressLine($shiperAddres);
        $sample->Shipper->addAddressLine($pickupLocation['data']->city);
        $sample->Shipper->City = $pickupLocation['data']->city;
        $sample->Shipper->Division = $pickupLocation['data']->state;
        $sample->Shipper->DivisionCode = '';
        $sample->Shipper->PostalCode = $pickupLocation['data']->zip;
        $sample->Shipper->CountryCode = $this->db->get_where('countrie', array('name' => $pickupLocation['data']->country))->row()->country_code;
        $sample->Shipper->CountryName = $pickupLocation['data']->country;
        $sample->Shipper->Contact->PersonName = $pickupLocation['data']->name;
        $sample->Shipper->Contact->PhoneNumber = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->PhoneExtension = '';
        $sample->Shipper->Contact->FaxNumber = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->Telex = $pickupLocation['data']->phone;
        $sample->Shipper->Contact->Email = $pickupLocation['data']->email;
    }
    $specialService = new SpecialService();
    $specialService->SpecialServiceType = 'A';
    $sample->addSpecialService($specialService);

    $specialService = new SpecialService();
    $specialService->SpecialServiceType = 'I';
    $sample->addSpecialService($specialService);

    $sample->EProcShip = 'N';
    $sample->LabelImageFormat = 'PDF';

// Call DHL XML API
$start = microtime(true);
//
// echo "

 Display the XML that will be sent to DHL";
// print_r($sample->toXML());
// DHL webservice client using the staging environment
$client = new WebserviceClient('staging');

    $xml = $client->call($sample);

// $response = new ShipmentResponse();
$xml_Object = simplexml_load_string($xml);
$AirwayBillNumber = $this->xml2array($xml_Object->AirwayBillNumber);
$ChargeableWeight = $this->xml2array($xml_Object->ChargeableWeight);
$Barcodes = $xml_Object->Barcodes;
$pieces = $this->xml2array($xml_Object->Piece);

    $data['AirwayBillNumber'] = $AirwayBillNumber[0];
    $data['ChargeableWeight'] = $ChargeableWeight[0];
    $data['Barcodes'] = json_encode($Barcodes[0]);
    $data['pieces'] = $pieces[0];
    return $data;
}

Please sign in to comment.