dingja/mytnt-express-connect-italy

myTNT Italy Express Connect (API) 客户端

维护者

详细信息

github.com/benjiam-gh/tnt

源代码

3.0.14 2024-09-03 08:28 UTC

README

myTNT Italy APIs 客户端版本

上游仓库原始文档

PHP 客户端,帮助开发者将 TNT EC 集成到他们的应用程序中。此软件包支持以下服务

  1. 货运
  2. 跟踪

分支仓库文档

此软件包是 myTNT Italy Express Connect APIs 的非官方 PHP 客户端。

安装

使用 composer 安装

composer require dinja/mytnt-express-connect-italy

用法

货运

  1. 创建货运的最小请求
use thm\tnt_ec\service\ShippingService\ShippingService;

$timestamp = new \DateTime();
$timezone = new \DateTimeZone('Europe/Rome');
$timestamp->setTimezone($timezone);

$shipping = new ShippingService('User ID', 'Password');

$shipping->setAccountNumber('') // will be provided by your TNT representative.
         ->setSenderAccId(''); // will be provided by your TNT representative.

$c1 = $shipping->addConsignment()->setConReference('')
                                 ->setContype('T')
                                 ->setPaymentind('S') // who pays for shipping S-sender, R-receiver
                                 ->setItems(1)
                                 ->setTotalWeight("00001000")
                                 ->setTotalVolume(0.00)
                                 ->setPackagetype('C')
                                 ->setDivision('D')
                                 ->setCollectionDate($timestamp->format('Ymd'))
                                 ->setService('N'); // will be provided by your TNT representative.

$c1->setSender()->setCompanyName('Your company')
                ->setAddressLine('Address 1')
                ->setCity('')
                ->setPostcode('')
                ->setProvince('')
                ->setCountry('')
                ->setContactDialCode('')
                ->setContactPhone('')
                ->setContactEmail('');

$c1->setReceiver()->setCompanyName('Receiver address. NOT DELIVERY!')
                  ->setAddressLine('')
                  ->setCity('')
                  ->setPostcode('')
                  ->setProvince('')
                  ->setCountry('')
                  ->setContactDialCode('')
                  ->setContactPhone('')
                  ->setContactEmail('');

$response = $shipping->send();
  1. 删除货运
use thm\tnt_ec\service\ShippingService\ShippingService;

$timestamp = new \DateTime();
$timezone = new \DateTimeZone('Europe/Rome');
$timestamp->setTimezone($timezone);

$shipping = new ShippingService('User ID', 'Password');

$shipping->setAccountNumber('') // will be provided by your TNT representative.
         ->setSenderAccId(''); // will be provided by your TNT representative.

$c1 = $shipping->addConsignment()->setConAction("D")
               ->setConNumber('tracking_number'); // Shipment Number to delete

$response = $shipping->send();

跟踪

use thm\tnt_ec\service\TrackingService\TrackingService;

$ts = new TrackingService('User ID', 'Password');
$ts->setAccountNumber('');  // will be provided by your TNT representative.

$response = $ts->searchByConsignment(array('tracking_number')); // Shipment Number to search