-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddShipmentsExample.php
More file actions
67 lines (60 loc) · 2.49 KB
/
Copy pathAddShipmentsExample.php
File metadata and controls
67 lines (60 loc) · 2.49 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
<?php
#-------------------------------------------------------------------------------
# INCLUDE THE CONFIGURATION FILE
#
# This file contains some default environment configuration which are used to
# ensure your examples will run.
#-------------------------------------------------------------------------------
require 'config.php';
#-------------------------------------------------------------------------------
# SETUP CLIENT
#
# Edit your credentials in config.php to use the examples.
#-------------------------------------------------------------------------------
$client = new Vleks\SDK\Client(
VLEKS_API_PUBLIC_KEY, VLEKS_API_PRIVATE_KEY,
VLEKS_MERCHANT_ID, VLEKS_API_CLUSTER
);
#-------------------------------------------------------------------------------
# ADD SHIPMENT TO ORDER
#-------------------------------------------------------------------------------
try {
$request = new Vleks\SDK\Requests\AddShipments(array (
'Shipment' => array (
array (
'OrderID' => '-- ORDER ID --',
'Transport' => array (
'TransporterCode' => Vleks\SDK\Enumerables\Transporter::DHL,
'TrackAndTrace' => '-- TRACK AND TRACE CODE --'
),
'Address' => array (
'Firstname' => '-- FIRSTNAME --',
'Surname' => '-- SURNAME --',
'StreetName' => '-- STREETNAME --',
'HouseNumber' => '-- HOUSENUMBER --',
'PostalCode' => '-- POSTALCODE --',
'City' => '-- CITY --',
'CountryCode' => Vleks\SDK\Enumerables\CountryCode::NL
),
'OrderLines' => array (
'OrderLine' => array (
array (
'OrderLineID' => '-- ORDERLINE ID --',
'QuantityShipped' => 1
)
)
)
)
)
));
$result = $client->addShipments($request);
if ($result->hasFeeds()) {
foreach ($result->getFeeds() as $feed) {
var_dump($feed->getRequestID());
}
}
} catch (Vleks\SDK\Exceptions\ClientException $clientException) {
var_dump($clientException->getMessage());
} catch (Vleks\SDK\Exceptions\ServiceException $serviceException) {
var_dump($serviceException->getMessage());
}