A composable package that provides a modern client to use with the 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('[email protected]')
->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('[email protected]')
->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
Please use GitHub issues to discuss bugs and new features.
The recommended way to install the SDK is through Composer.
composer require accu/postmen-sdk
Brought to you by:
Accuracy. Delivered.