martijnpieters / pakketmail

PakketMail SDK for API version 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PakketMail SDK (PHP 7.0+)

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());
}

About

PakketMail SDK for API version 2.0

License:MIT License


Languages

Language:PHP 100.0%