dinja/poste-delivery-business-sdk
最新稳定版本:1.0.6
Composer 安装命令:
composer require dinja/poste-delivery-business-sdk
包简介
Unofficial PHP SDK for Poste Delivery Business Rest API services
README 文档
README
This package is an unofficial simple PHP SDK for Poste Delivery Business Rest API services v.1.8.5.
Installing
Install with composer
composer require dinja/poste-delivery-business-sdk
Features
Waybill Services
- Create Waybill
- Get Nations
Tracking
- Get Shipment Tracking
Digipod
- Digipod Request
- Digipod Download
Usage
Create Waybill
$debug = false; $timestamp = new \DateTime(); $timezone = new \DateTimeZone('Europe/Rome'); $timestamp->setTimezone($timezone); $waybillDataReceiver = new Dinja\PosteDeliveryBusinessSDK\Api\WaybillDataContact(); $waybillDataReceiver->setNameSurname("Mario Rossi")->setContactName("Dinja Srl") ->setAddressId("") ->setAddress("Via Roma 1") ->setZipCode("70044") ->setCity("Polignano a Mare") ->setCountry("ITA1") ->setProvince("BA") ->setCountryName("Italia") ->setPhone("") ->setCellphone("") ->setEmail("info@sellengine.it"); $waybillDataSender = new Dinja\PosteDeliveryBusinessSDK\Api\WaybillDataContact(); $waybillDataSender->setZipCode("70044") ->setStreetNumber("") ->setPhone("") ->setEmail("info@sellengine.it") ->setCity("Polignano a Mare") ->setAddressId("") ->setAddress("Via Leonardo da Vinci 22") ->setProvince("BA") ->setCountry("ITA1") ->setCountryName("Italia") ->setNameSurname("Dinja Srl") ->setNote1("TEST"); $waybillDataServices = new Dinja\PosteDeliveryBusinessSDK\Api\WaybillDataServices(); $dataWrapper = array(); $waybillDataServices->setDataWrapper($dataWrapper); $declaredArr = array(); $waybillDataDeclared = new Dinja\PosteDeliveryBusinessSDK\Api\WaybillDataDeclared(); $waybillDataDeclared->setWeight("1") ->setHeight("1") ->setLength("1") ->setWidth("1"); array_push($declaredArr, $waybillDataDeclared); $waybillData = new Dinja\PosteDeliveryBusinessSDK\Api\WaybillData(); $waybillData->setDeclared($declaredArr) ->setSender($waybillDataSender) ->setServices($waybillDataServices) ->setReceiver($waybillDataReceiver) ->setContent("Vario"); $waybill = new Dinja\PosteDeliveryBusinessSDK\Api\Waybill(); $waybill->setPrintFormat("ZPL") ->setClientReferenceId("1") ->setProduct("APT000901") ->setData($waybillData); $request = new Dinja\PosteDeliveryBusinessSDK\Request\WaybillRequest("poste_api_client_id", "poste_api_secret_id", "poste_api_scope", $debug); $request->setCostCenterCode("poste_api_cost_center_code") ->setShipmentDate($timestamp->format(\DateTime::ISO8601)) ->setWaybill($waybill); $response = $request->call($debug); if ($response->hasError()) { echo $response->getResult()->getErrorCode(); } else { $waybills = $response->getWaybills(); }
Get Nations
$debug = false; $request = new Dinja\PosteDeliveryBusinessSDK\Request\NationsRequest("poste_api_client_id", "poste_api_secret_id", "poste_api_scope", $debug); $response = $request->call($debug); if ($response->hasError()) { echo $response->getResult()->getErrorCode(); } else { $countries = $response->getCountries(); foreach ($countries as $country) { echo $country->getIso4(); } }
Get Shipment Tracking
$shipmentsData = new Dinja\PosteDeliveryBusinessSDK\Api\ShipmentsData(); $shipmentsData->setWaybillNumber($trackingNumber)->setLastTracingState("N"); $request = new Dinja\PosteDeliveryBusinessSDK\Request\TrackingRequest("poste_api_client_id", "poste_api_secret_id", "poste_api_scope", $debug); $request->setShipmentsData($shipmentsData)->setStatusDescription("E")->setCustomerType("DQ"); $response = $request->call($debug); if ($response->hasError()) { echo $response->getCode(); } else { $shipment = $response->getShipment(); }
Digipod Request
$request = new Dinja\PosteDeliveryBusinessSDK\Request\DigipodReqRequest("poste_api_client_id", "poste_api_secret_id", "poste_api_scope", $debug); $request->setBarcode("TEST"); $response = $request->call($debug); if ($response->hasError()) { echo $response->getResult()->getErrorCode(); } else { $result = $response->getResult()->getResult(); }
Digipod Download
$request = new Dinja\PosteDeliveryBusinessSDK\Request\DigipodDownloadRequest("poste_api_client_id", "poste_api_secret_id", "poste_api_scope", $debug); $request->setBarcode("TEST"); $response = $request->call($debug); if ($response->getResult() == "KO") { echo $response->getErrorCode(); } else { $digipodBase64 = $response->getAttached(); }
Credits
License
This project is licensed under the MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 803
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-29