wedesignit / parcel-pro-php-api-client
PHP Client for the Parcel Pro API
Installs: 5 403
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^6|^7
This package is auto-updated.
Last update: 2024-11-12 15:24:37 UTC
README
Installing
composer require wedesignit/parcel-pro-php-api-client
Versions and PHP compatibility
Creating the connector
$client = new \WeDesignIt\ParcelPro\Client($userId, $apiKey); $parcelPro = new \WeDesignIt\ParcelPro\ParcelPro($client);
After this, the $parcelPro
class can return Endpoints
which can be called.
The endpoint methods can either be called with plain arrays or the fluent
Resource
classes can be used.
Usage examples
Always: Setting up
This applies to every following example and should be prepended to every example.
$client = new \WeDesignIt\ParcelPro\Client( '<your login ID>' '<your API key>' ); $parcelPro = new \WeDesignIt\ParcelPro\ParcelPro($client);
Check if API key is valid
$parcelPro->apiKey()->isValid();
Retrieving the shipment types
$parcelPro->shipmentType()->list();
Response example (from the docs):
[ [ "Id" => 8, "Type" => "DFY", "Code" => "00", "Label" => "DFY", "Carrier_Id" => 2, "Carrier" => "DHL", "CarrierNaam" => "DHL", "CarrierLabel" => "", "CarrierKlantcode" => "1234567", "Buitenland" => 1, "Benelux" => 1, "EU" => null, "Worldwide" => null, "Land" => null, "Tolplichtig" => null, "InleverenOpServicePoint" => 1, "ServicePoint" => 1, "HandtekeningVoorOntvangst" => 1, "NietBijBuren" => 1, "AvondLevering" => null, "ZaterdagLevering" => null1, "1100Levering" => null, "VerhoogdAansprakelijk" => 1, "Rembours" => null, "MiniPallet" => null, "Pallet" => null, "Collo" => null ], [ "Id" => 9, "Type" => "PostNL", "Code" => "3085", "Label" => "Standaard Pakket", "Carrier_Id" => 3, "Carrier" => "PostNL", "CarrierNaam" => "PostNL", "CarrierLabel" => "", "CarrierKlantcode" => "7654321", "Buitenland" => 0, "Benelux" => 0, "EU" => null, "Worldwide" => null, "Land" => null, "Tolplichtig" => null, "InleverenOpServicePoint" => null, "ServicePoint" => 1, "HandtekeningVoorOntvangst" => 1, "NietBijBuren" => 1, "AvondLevering" => null, "ZaterdagLevering" => null1, "1100Levering" => null, "VerhoogdAansprakelijk" => 1, "Rembours" => null, "MiniPallet" => null, "Pallet" => null, "Collo" => null ] ]
Which will then return a boolean value.
Sending a shipment
$shipment = [ 'Carrier' => 'Carrier name', 'Type' => 'Shipment type', 'Referentie' => 'E.g. your order number', 'Zaterdaglevering' => '1', 'NaamAfzender' => 'Michael Scott', 'StraatAfzender' => 'Street', 'NummerAfzender' => '11', 'ToevoegingAfzender' => 'A', 'PostcodeAfzender' => '1000 AB', 'PlaatsAfzender' => 'Scranton', 'LandAfzender' => 'NL', 'Naam' => 'Dwight Schrute', 'Straat' => 'Street' 'Nummer' => '11', 'Toevoeging' => 'A', 'Postcode' => '1000 AB', 'Plaats' => 'Scranton', 'Land' => 'NL', 'Email' => 'assistant-regional-manager@dundermifflin.ext', 'AantalPakketten' => 1, 'Gewicht' => 1, 'Opmerking' => 'Thanks to the world\'s #1 boss', ]; $parcelPro->shipment()->create($shipment);
If you like a more object-oriented approach you can also use the Shipment Resource class (and its subclasses).
Retrieving a shipping label
If needed for printing. Note you already get a label URL back from the shipment create call which you can also present to your users to directly access the label.
// for PDF version $label = $parcelPro->shippingLabel()->get($shipmentId); // for HTML version $pdf = false; $label = $parcelPro->shippingLabel()->get($shipmentId, $pdf);