accu/postmen-sdk

SDK for Postmen.com Parcel Shipping API.

3.0.0 2022-01-04 14:51 UTC

This package is auto-updated.

Last update: 2022-09-09 19:01:44 UTC


README

68747470733a2f2f612e73746f7279626c6f6b2e636f6d2f662f38303839392f782f353732616466663631392f706f73746d656e5f7777775f6c6f676f2e737667

Build Status Total Downloads Latest Stable Version License

Accu Postmen SDK

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('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

Help and docs

Please use GitHub issues to discuss bugs and new features.

Installing the Postmen SDK

The recommended way to install the SDK is through Composer.

composer require accu/postmen-sdk

Brought to you by:

68747470733a2f2f692e616363752e636f2e756b2f6c6f676f2f616363752e737667

Accuracy. Delivered.