deliverea / deliverea-php
此包的最新版本(0.0.25)没有可用的许可信息。
此包的官方存储库似乎已消失,因此已将其冻结。
0.0.25
2018-07-23 08:34 UTC
Requires
- php: ^5.4
- dev-master
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-DSD-000--balclis
- dev-shipment-drop-point-key
- dev-DSD-618-pro-service-CA
- dev-DSD-586
- dev-DSD-336-Export-csv
- dev-DSD-341-Clients-area
- dev-DSD-367-add-to-php-library
- dev-DSD-337-Drop-point-endpoint
- dev-DSD-124-Error
- dev-DSD-81-Api-Errors
This package is not auto-updated.
Last update: 2024-01-20 14:20:55 UTC
README
Deliverea PHP API 库
这是用于与 Deliverea API 集成的官方库,目前处于测试阶段,因此如果您有任何想要贡献的bug或修复,请通过 Pull Requests 进行。
兼容性
- Deliverea v1: https://www.deliverea.com/es/api/
安装
composer require deliverea/deliverea-php 0.0.9
方法
- 获取客户承运商
- 获取客户服务
- 获取运输费率
- 获取运输到货时间估计
- 获取服务信息
- 新建运输
- 获取收集截止时间
- 获取投放点
- 新建收集
- 获取运输标签
- 获取运输
- 获取运输
- 获取运输跟踪
异常
使用这些异常的 try-catch 或简单地使用标准 \Exception 包装所有请求。
- \Deliverea\Exception\CurlException
- \Deliverea\Exception\ErrorResponseException
- \Deliverea\Exception\UnexpectedResponseException
####示例
try {
$deliverea->newShipment($shipment, 32, $address);
} catch (\Deliverea\Exception\CurlException $e) {
} catch (\Deliverea\Exception\ErrorResponseException $e) {
} catch (\Deliverea\Exception\UnexpectedResponseException $e) {
}
获取客户承运商
$delivereaClient->getClientCarriers();
获取客户服务
此方法中的所有参数都是可选的,状态可以是 0、1 或 null。
$delivereaClient->getClientServices(
'Carrier Code',
'Service Code',
'Service Region',
'Service Type',
'Status'
);
获取运输费率
$delivereaClient->getShipmentsRates(
new CountryCode('ES'),
new ZipCode('08018'),
new CountryCode('ES'),
new ZipCode('07800'),
new ParcelDimensions(2.0,1.0,1.0,1.0),
new ParcelWeight(1.5)
);
获取运输到货时间估计
$delivereaClient->getShipmentTimeArrivalEstimation(
new CountryCode('ES'),
new ZipCode('08018'),
new CountryCode('ES'),
new ZipCode('07800'),
new \DateTime()
);
获取服务信息
$delivereaClient->getServiceInfo(
'Carrier Code',
'Service Code',
'From Country Code',
'From Zip Code',
'To Country Code',
'To Zip Code'
);
新建运输
// Create API Client
$deliverea = new \Deliverea\Deliverea('apiuser', 'apisecret');
// Enable Sandbox
$deliverea->setSandbox(true);
// Create shipment
$shipment = new \Deliverea\Model\Shipment(1, substr(md5(strtotime('now')), 0, 14), new \DateTime(), 'custom',
'ovirtual', 'ovirtual-servicio-19');
$fromAddress = new Address(
'Full Name',
'Address',
'City',
'Zip Code',
'Country Code',
'Phone'
);
$toAddress = new \Deliverea\Model\Address(
'Full name',
'Address',
'City',
'Zip Code',
'Country Code',
'Phone'
);
$shipment = $deliverea->newShipment($shipment, $fromAddress, $toAddress);
要添加特定承运商的参数,可以将其分配给对象本身。
$shipment->parcel_type = "DOCUMENTS";
获取收集截止时间
$cutoffHour = $this->delivereaClient->getCollectionCutoffHour([
'zip_code' => '12345',
'country_code' => 'ES',
'service_code' => 'ovirtual-servicio-19',
'carrier_code' => 'ovirtual'
]);
获取投放点
$deliverea->getDropPoints([
'country_code' => 'ES',
'zip_code' => '08018',
'carrier_code' => 'mondialRelay',
]);
新建收集
// Create API Client
$deliverea = new \Deliverea\Deliverea('apiuser', 'apisecret');
// Create collection
$collection = new \Deliverea\Model\Collection(substr(md5(strtotime('now')), 0, 14), new \DateTime(),
'ovirtual', 'ovirtual-servicio-19', '11:00', '16:00');
$fromAddress = new Address(
'Full Name',
'Address',
'City',
'Zip Code',
'Country Code',
'Phone'
);
$toAddress = new \Deliverea\Model\Address(
'Full name',
'Address',
'City',
'Zip Code',
'Country Code',
'Phone'
);
$collection = $deliverea->newCollection($collection, $fromAddress, $toAddress);
获取运输标签
$deliverea->getShipmentLabel('dlvrref');
获取运输
$deliverea->getShipment('dlvrref');
通过 API 中的筛选器获取运输(不包括跟踪事件)
$deliverea->getShipments([
'filter_shipping_dlvr_ref' => 'dlvrref'
...
]);
获取运输跟踪
$deliverea->getShipmentTracking('dlvrref');