martijnpieters / pakketmail
PakketMail SDK for API version 2.0
dev-master
2017-11-19 16:20 UTC
Requires
- php: >=7.0
- ext-curl: *
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2025-06-22 08:23:30 UTC
README
Requirements
- PakketMail account
- PHP >= 7.0
- PHP cURL extension
Installation
The easiest way to install the PakketMail SDK is to require it with Composer.
$ composer require martijnpieters/pakketmail:dev-master
Getting started
Require the Composer autoloader and include the PakketMail namespace.
require 'vendor/autoload.php'; use MartijnPieters\PakketMail;
Initialize a request with your username and password, and optionally the development flag true
.
$pakketMailRequest = new PakketMail\Request('username', 'password', true);
Create a new parcel and add it to the request.
$shipmentProperties = [ 'pakketMailProduct' => PakketMail\Shipment::PAKKETMAIL_PRODUCT_DPD, 'clientReference' => 'A123', 'name1' => 'John Doe', 'streetName' => 'Main street', 'city' => 'Foo City', 'postalCode' => '1234 AB', 'country' => 'NLD', ]; $shipment = new PakketMail\Shipment($shipmentProperties); $pakketMailRequest->addShipment($shipment);
Execute the request and retrieve the day close URL (dagafsluiting
).
$pakketMailRequest->sendToApi(); print($pakketMailRequest->getDayCloseUrl());
Exceptions
Catch exceptions during the API call.
try { $pakketMailRequest->sendToApi(); } catch (PakketMail\Exception $e) { throw new Exception($e->getMessage()); }