-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
84 lines (67 loc) · 2.29 KB
/
Copy pathexample.php
File metadata and controls
84 lines (67 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require 'vendor/autoload.php';
use Onetoweb\Parcelpro\Client;
$userId = '';
$apiKey = 'apiKey';
$client = new Client($userId, $apiKey);
// validate apikey
$result = $client->validateApikey();
// create account
// https://login.parcelpro.nl/api/docs/#operation--account-aanmaken
$account = $client->createAccount([
'Email' => 'info@example.com',
'Naam' => 'Naam',
'Contactpersoon' => "Contactpersoon",
'Telefoonnummer' => 'Telefoonnummer',
'Straat' => 'Straat',
'Nummer' => '1A',
'Postcode' => '1111AA',
'Plaats' => 'Plaats',
'Land' => 'NL',
]);
// check if account exists
$result = $client->accountExists($account['Email']);
// get shimpment types
$shipmentTypes = $client->getShipmentTypes();
$shipmentType = $shipmentTypes[0];
// get pickup points
// https://login.parcelpro.nl/api/docs/#operation--uitreiklocaties
$pickupPoints = $client->getPickupPoints([
'Postcode' => 'Postcode',
'Nummer' => 'Nummer',
'Straat' => 'Straat',
]);
// create shipment
// https://login.parcelpro.nl/api/docs/#operation--nieuwe-zending
$shipment = $client->createShipment([
'Carrier' => $shipmentType['CarrierNaam'],
'Type' => $shipmentType['Type'],
'Naam' => 'Naam',
'Straat' => 'Straat',
'Nummer' => '1A',
'Postcode' => '1111AA',
'Plaats' => 'Plaats',
'Land' => 'NL',
'Email' => 'info@example.com',
'AantalPakketten' => 1,
'Gewicht' => 3.14,
'Opmerking' => 'test shipment',
]);
// get shipment label url
$labelUrl = $client->getLabelUrl($shipment['Id']);
// get shipment label content
$labelContents = $client->getLabelContents($shipment['Id']);
// save shipment label
$filename = '/path/to/file.pdf';
$client->saveLabel($shipment['Id'], $filename);
// get shipments
// https://login.parcelpro.nl/api/docs/#operation--zendingen
$shipments = $client->getShipments([
'ZendingId' => $shipment['Id']
]);
// print label
// https://login.parcelpro.nl/api/docs/#operation--label-afdrukken
$client->printLabel($shipment['Id']);
// create trigger
// https://login.parcelpro.nl/api/docs/#operation--status-terugmelding
$trigger = $client->createTrigger('http://www.example.com/trigger.php', 'afgedrukt', 'ZendingId=?id&Status=Shipped&Referentie=?referentie');