accu / postmen-sdk
Postmen.com包裹运输API的SDK。
3.0.0
2022-01-04 14:51 UTC
Requires
- php: ^7.2|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.5|^7.0
- psr/event-dispatcher: ^1.0
- swaggest/json-schema: ^0.12.39
Requires (Dev)
- phpunit/phpunit: ^7.5|^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-09-09 23:31:35 UTC
README
Accu Postmen SDK
一个可组合的包,提供了与Postmen.com API一起使用的现代客户端。
$client = new \Accu\Postmen\Client( (new \Accu\Postmen\Configuration('your-api-key', $testMode = true)) ->setMaxRetries(1) ); /** @var \Accu\Postmen\Entities\Label $label */ $label = $client->send((new \Accu\Postmen\Requests\Labels\Create()) ->addReference('Dispatch #1') ->setServiceType('dpd-uk_parcel_1d') ->setShipperAccount((new \Accu\Postmen\Entities\ShipperAccount()) ->setId('your-shipper-account-id') ) ->setShipment((new \Accu\Postmen\Entities\Shipment()) ->setShipTo((new \Accu\Postmen\Entities\Address()) ->setContactName('Goods In') ->setCompanyName('Accu Limited') ->setStreet1('Haggwood Stone Quarry') ->setStreet2('Woodhead Road') ->setCity('Holmfirth') ->setPostalCode('HD9 6PW') ->setCountry('GBR') ->setEmail('goods-in@accu.co.uk') ->setPhone('0123456789') ) ->setShipFrom((new \Accu\Postmen\Entities\Address()) ->setContactName('Goods Out') ->setCompanyName('Accu Limited') ->setStreet1('Haggwood Stone Quarry') ->setStreet2('Woodhead Road') ->setCity('Holmfirth') ->setPostalCode('HD9 6PW') ->setCountry('GBR') ->setEmail('goods-out@accu.co.uk') ->setPhone('0123456789') ) ->setDeliveryInstructions('Please ring the bell') ->addParcel((new \Accu\Postmen\Entities\Parcel()) ->setBoxType('custom') ->setDimension((new \Accu\Postmen\Entities\Dimension()) ->setUnit('cm') ->setHeight(30) ->setWidth(50) ->setDepth(30) ) ->addItem((new \Accu\Postmen\Entities\Item()) ->setSku('APC000001') ->setItemId('tiny-screw-1') ->setDescription('A small screw') ->setWeight((new \Accu\Postmen\Entities\Weight()) ->setUnit('kg') ->setValue(0.001) ) ->setQuantity(1000) ->setPrice((new \Accu\Postmen\Entities\Money()) ->setCurrency('GBP') ->setAmount(0.005) ) ->setOriginCountry('GBR') ->setHsCode('7318141090') ) ->setWeight((new \Accu\Postmen\Entities\Weight()) ->setUnit('kg') // Sum of items plus packaging. ->setValue(1.2) ) ) ) ); echo $label->getId(); // the-label-identifier echo $label->getTrackingNumbers(); // ['tracking-1..', 'tracking-2..', ...] echo $label->getFiles()->getLabel()->getUrl(); // The shipping labels to be printed
帮助和文档
请使用GitHub问题讨论错误和新功能。
安装Postmen SDK
安装SDK的推荐方法是使用Composer。
composer require accu/postmen-sdk
由
准确。送达。