PHP code example of mhunesi / yii2-hepsijet
1. Go to this page and download the library: Download mhunesi/yii2-hepsijet 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/ */
mhunesi / yii2-hepsijet example snippets
'component' => [
...
'hepsiJet' => [
'class' => '\mhunesi\hepsijet\HepsiJet',
'username' => 'username',
'password' => 'password',
'clientOptions' => [
'verify' => false,
'debug' => false,
'timeout' => '2.0'
]
]
]
$hepsiJet = Yii::$app->hepsiJet;
$hepsiJet = new HepsiJet([
'username' => 'username',
'password' => 'password',
'clientOptions' => [
'verify' => false,
'debug' => false,
'timeout' => '2.0'
]
]);
use mhunesi\hepsijet\HepsiJet;
use mhunesi\hepsijet\models\City;
use mhunesi\hepsijet\models\DeliveryContent;
use mhunesi\hepsijet\models\Town;
use mhunesi\hepsijet\models\Cargo;
use mhunesi\hepsijet\models\Company;
use mhunesi\hepsijet\models\Country;
use mhunesi\hepsijet\models\Address;
use mhunesi\hepsijet\models\Product;
use mhunesi\hepsijet\models\Delivery;
use mhunesi\hepsijet\models\District;
use mhunesi\hepsijet\models\Receiver;
use mhunesi\hepsijet\models\CurrentXDock;
use mhunesi\hepsijet\enums\ProductCode;
use mhunesi\hepsijet\enums\DeliverySlotOriginal;
use mhunesi\hepsijet\enums\DeliveryType;
$model = new Cargo([
'company' => new Company([
'name' => 'CompanyName',
'abbreviationCode' => 'CMPNYNM'
]),
'currentXDock' => new CurrentXDock([
'abbreviationCode' => 'CMP_ENSYRT'
]),
'delivery' => new Delivery([
'customerDeliveryNo' => 'OrderNumber',
'customerOrderId' => 'OrderNumber',
'totalParcels' => 1,
'desi' => 4,
'deliverySlotOriginal' => 0,
'deliveryDateOriginal' => date('Y-m-d'),
'deliveryType' => 'RETAIL',
'product' => new Product([
'productCode' => 'HX_STD'
]),
'receiver' => new Receiver([
'companyCustomerId' => 'companyCustomerId',
'firstName' => 'Receiver Name',
'lastName' => 'Receiver Last Name',
'phone1' => '7777777777',
'email' => '[email protected] '
]),
'senderAddress' => new Address([
'companyAddressId' => 'ADD-12314',
'country' => new Country([
'name' => 'Türkiye'
]),
'city' => new City([
'name' => 'İstanbul'
]),
'town' => new Town([
'name' => 'Esenyurt',
]),
'district' => new District([
'name' => 'Akçaburgaz',
]),
'addressLine1' => 'Akçaburgaz Mahallesi Muhsin Yazıcıoğlu Caddesi 121. Sok No:21 Esenyurt/İSTANBUL Esenyurt İstanbul Türkiye'
]),
'recipientAddress' => new Address([
'companyAddressId' => 'ADD-1012432',
'country' => new Country([
'name' => 'Türkiye'
]),
'city' => new City([
'name' => 'İstanbul'
]),
'town' => new Town([
'name' => 'Tuzla',
]),
'district' => new District([
'name' => 'Postane',
]),
'addressLine1' => 'Postane Mah. Barbaros Hayrettin Cad. Şule Sok. Kardeşler Apartmanı 4/11 Tuzla/İstanbul'
]),
'deliveryContent' => [
new DeliveryContent([
'sku' => 'P1',
'description' => 'Product 1',
'quantity' => 2
]),
new DeliveryContent([
'sku' => 'P2',
'description' => 'Product 2',
'quantity' => 1
])
],
'recipientPerson' => 'Receiver Name Lastname',
'recipientPersonPhone1' => '7777777777'
])
]);
$cargoResult = $hepsiJet->delivery()->sendDeliveryOrderEnhanced($model);
$data = [
'company' => [
'name' => 'CompanyName',
'abbreviationCode' => 'CMPNYNM'
],
'delivery' => [
'customerDeliveryNo' => 'OrderNumber',
'customerOrderId' => 'OrderNumber',
'totalParcels' => 1,
'desi' => 4,
'deliverySlotOriginal' => 0,
'deliveryDateOriginal' => '2021-12-17',
'deliveryType' => 'RETAIL',
'recipientPerson' => 'Receiver Name Lastname',
'recipientPersonPhone1' => '7777777777',
'receiver' => [
'companyCustomerId' => 'companyCustomerId',
'firstName' => 'Receiver Name',
'lastName' => 'Receiver Last Name',
'phone1' => '7777777777',
'email' => '[email protected] ',
],
'product' => [
'productCode' => 'HX_STD',
],
'senderAddress' => [
'companyAddressId' => 'ADD-12314',
'addressLine1' => 'Akçaburgaz Mahallesi Muhsin Yazıcıoğlu Caddesi 121. Sok No:21 Esenyurt/İSTANBUL Esenyurt İstanbul Türkiye',
'country' => [
'name' => 'Türkiye',
],
'city' => [
'name' => 'İstanbul',
],
'town' => [
'name' => 'Esenyurt',
],
'district' => [
'name' => 'Akçaburgaz',
],
],
'recipientAddress' => [
'companyAddressId' => 'ADD-1012432',
'addressLine1' => 'Postane Mah. Barbaros Hayrettin Cad. Şule Sok. Kardeşler Apartmanı 4/11 Tuzla/İstanbul',
'country' => [
'name' => 'Türkiye',
],
'city' => [
'name' => 'İstanbul',
],
'town' => [
'name' => 'Tuzla',
],
'district' => [
'name' => 'Postane',
],
],
'deliveryContent' => [
[
'sku' => 'P1',
'description' => 'Product 1',
'quantity' => 2
],
[
'sku' => 'P2',
'description' => 'Product 2',
'quantity' => 1
]
]
],
'currentXDock' => [
'abbreviationCode' => 'CMP_ENSYRT'
],
];
$model = new Cargo($data);
$cargoResult = $hepsiJet->delivery()->sendDeliveryOrderEnhanced($model);
$deleteDeliveryOrder = $hepsiJet->delivery()->deleteDeliveryOrder(['OrderNumber']);
if($deleteDeliveryOrder->status){
$data = $deleteDeliveryOrder->toArray();
}else{
echo $deleteDeliveryOrder->message;
}
$trackResponse = $hepsiJet->delivery()->track(['OrderNumber']);
if($trackResponse->status){
$data = $trackResponse->toArray();
}else{
echo $trackResponse->message;
}
$trackResponse = $hepsiJet->deliveryTransaction()->getDeliveryTracking(['OrderNumber']);
if($trackResponse->status){
$data = $trackResponse->toArray();
}else{
echo $trackResponse->message;
}
$trackResponse = $hepsiJet->deliveryTransaction()->getDeliveryTrackingV2(['OrderNumber']);
if($trackResponse->status){
$data = $trackResponse->toArray();
}else{
echo $trackResponse->message;
}
$getEndOfTheDayResponse = $hepsiJet->deliveryTransaction()->getEndOfTheDay();
if($getEndOfTheDayResponse->status){
$data = $getEndOfTheDayResponse->toArray();
}else{
echo $getEndOfTheDayResponse->message;
}
$cities = $hepsiJet->settlement()->cities();
$cities = $cities->toArray();
$towns = $hepsiJet->settlement()->towns($id);
$towns = $towns->toArray();
$districts = $hepsiJet->settlement()->districts(1);
$districts = $districts->toArray();