1 | <?php |
||
2 | |||
3 | // require |
||
4 | require_once __DIR__ . '/../vendor/autoload.php'; |
||
5 | require_once __DIR__ . '/config.php'; |
||
6 | |||
7 | use Bpost\BpostApiClient\Bpost; |
||
8 | use Bpost\BpostApiClient\Bpost\Order; |
||
9 | use Bpost\BpostApiClient\Bpost\Order\Address; |
||
10 | use Bpost\BpostApiClient\Bpost\Order\Box; |
||
11 | use Bpost\BpostApiClient\Bpost\Order\Box\At247; |
||
12 | use Bpost\BpostApiClient\Bpost\Order\Box\AtBpost; |
||
13 | use Bpost\BpostApiClient\Bpost\Order\Box\AtHome; |
||
14 | use Bpost\BpostApiClient\Bpost\Order\Box\CustomsInfo\CustomsInfo; |
||
15 | use Bpost\BpostApiClient\Bpost\Order\Box\International; |
||
16 | use Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging; |
||
17 | use Bpost\BpostApiClient\Bpost\Order\Line as OrderLine; |
||
18 | use Bpost\BpostApiClient\Bpost\Order\ParcelsDepotAddress; |
||
19 | use Bpost\BpostApiClient\Bpost\Order\PugoAddress; |
||
20 | use Bpost\BpostApiClient\Bpost\Order\Receiver; |
||
21 | use Bpost\BpostApiClient\Bpost\Order\Sender; |
||
22 | |||
23 | // create instance |
||
24 | $bpost = new Bpost(ACCOUNT_ID, PASSPHRASE); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
25 | |||
26 | // create order |
||
27 | $orderId = time(); |
||
28 | $order = new Order($orderId); |
||
29 | $order->setCostCenter('Cost Center'); |
||
30 | |||
31 | // add lines |
||
32 | $line1 = new OrderLine('Beer', 1); |
||
33 | $order->addLine($line1); |
||
34 | $line2 = new OrderLine('Whisky', 100); |
||
35 | $order->addLine($line2); |
||
36 | |||
37 | // add box |
||
38 | $address = new Address(); |
||
39 | $address->setStreetName('Afrikalaan'); |
||
40 | $address->setNumber('289'); |
||
41 | $address->setPostalCode('9000'); |
||
42 | $address->setLocality('Gent'); |
||
43 | $address->setCountryCode('BE'); |
||
44 | |||
45 | $sender = new Sender(); |
||
46 | $sender->setAddress($address); |
||
47 | $sender->setName('Tijs Verkoyen'); |
||
48 | $sender->setCompany('Sumo Coders'); |
||
49 | $sender->setPhoneNumber('+32 9 395 02 51'); |
||
50 | $sender->setEmailAddress('[email protected]'); |
||
51 | |||
52 | $box = new Box(); |
||
53 | $box->setSender($sender); |
||
54 | $box->setRemark('Remark'); |
||
55 | |||
56 | // add label |
||
57 | $address = new Address(); |
||
58 | $address->setStreetName('Kerkstraat'); |
||
59 | $address->setNumber('108'); |
||
60 | $address->setPostalCode('9050'); |
||
61 | $address->setLocality('Gentbrugge'); |
||
62 | $address->setCountryCode('BE'); |
||
63 | |||
64 | $receiver = new Receiver(); |
||
65 | $receiver->setAddress($address); |
||
66 | $receiver->setName('Tijs Verkoyen'); |
||
67 | $receiver->setCompany('Sumo Coders'); |
||
68 | $receiver->setPhoneNumber('+32 9 395 02 51'); |
||
69 | $receiver->setEmailAddress('[email protected]'); |
||
70 | |||
71 | // options |
||
72 | $option = new Messaging('infoDistributed', 'NL', '[email protected]'); |
||
73 | // $option = new Messaging('infoNextDay', 'NL', '[email protected]'); |
||
74 | // $option = new Messaging('infoReminder', 'NL', '[email protected]'); |
||
75 | // $option = new Messaging('keepMeInformed', 'NL', '[email protected]'); |
||
76 | // $option = new CashOnDelivery( |
||
77 | // 1251, |
||
78 | // 'BE19210023508812', |
||
79 | // 'GEBABEBB' |
||
80 | // ); |
||
81 | // $option = new Signature(); |
||
82 | // $option = new Insurance('additionalInsurance', 3); |
||
83 | // $option = new AutomaticSecondPresentation(); |
||
84 | |||
85 | // @Home |
||
86 | $atHome = new AtHome(); |
||
87 | $atHome->setProduct('bpack 24h Pro'); |
||
88 | $atHome->setWeight(2000); |
||
89 | $atHome->setReceiver($receiver); |
||
90 | $atHome->addOption($option); |
||
91 | $box->setNationalBox($atHome); |
||
92 | |||
93 | // @Bpost |
||
94 | $pugoAddress = new PugoAddress( |
||
95 | 'Turnhoutsebaan', |
||
96 | '468', |
||
97 | null, |
||
98 | '2110', |
||
99 | 'Wijnegem', |
||
100 | 'BE' |
||
101 | ); |
||
102 | |||
103 | $atBpost = new AtBpost(); |
||
104 | $atBpost->setWeight(2000); |
||
105 | $atBpost->setPugoId('207500'); |
||
106 | $atBpost->setPugoName('WIJNEGEM'); |
||
107 | $atBpost->setPugoAddress($pugoAddress); |
||
108 | $atBpost->setReceiverName('Tijs Verkoyen'); |
||
109 | $atBpost->setReceiverCompany('Sumo Coders'); |
||
110 | // $box->setNationalBox($atBpost); |
||
111 | |||
112 | // @24/7 |
||
113 | $parcelsDepotAddress = new ParcelsDepotAddress( |
||
114 | 'Turnhoutsebaan', |
||
115 | '468', |
||
116 | null, |
||
117 | '2110', |
||
118 | 'Wijnegem', |
||
119 | 'BE' |
||
120 | ); |
||
121 | $parcelsDepotAddress->setBox('A'); |
||
122 | |||
123 | $at247 = new At247(); |
||
124 | $at247->setParcelsDepotId('014472'); |
||
125 | $at247->setParcelsDepotName('WIJNEGEM'); |
||
126 | $at247->setParcelsDepotAddress($parcelsDepotAddress); |
||
127 | $at247->setMemberId('188565346'); |
||
128 | $at247->setReceiverName('Tijs Verkoyen'); |
||
129 | $at247->setReceiverCompany('Sumo Coders'); |
||
130 | // $box->setNationalBox($at247); |
||
131 | |||
132 | // international |
||
133 | $customsInfo = new CustomsInfo(); |
||
134 | $customsInfo->setParcelValue(700); |
||
135 | $customsInfo->setContentDescription('BOOK'); |
||
136 | $customsInfo->setShipmentType('DOCUMENTS'); |
||
137 | $customsInfo->setParcelReturnInstructions('RTS'); |
||
138 | $customsInfo->setPrivateAddress(false); |
||
139 | |||
140 | $international = new International(); |
||
141 | $international->setProduct('bpack World Express Pro'); |
||
142 | $international->setReceiver($receiver); |
||
143 | $international->setParcelWeight(2000); |
||
144 | $international->setCustomsInfo($customsInfo); |
||
145 | // $box->setInternationalBox($international); |
||
146 | |||
147 | $order->addBox($box); |
||
148 | |||
149 | try { |
||
150 | // Bpost webservices |
||
151 | // $response = $bpost->createOrReplaceOrder($order); |
||
152 | // $response = $bpost->modifyOrderStatus($orderId, 'OPEN'); |
||
153 | // $response = $bpost->fetchOrder($orderId); |
||
154 | // $response = $bpost->createLabelForOrder('1398779096', 'A4'); |
||
155 | // $response = $bpost->createLabelForBox('323212345659900357664050', 'A4'); |
||
156 | // $response = $bpost->createLabelInBulkForOrders( |
||
157 | // array('1398779096', '1398862819'), 'A4' |
||
158 | // ); |
||
159 | |||
160 | // GEO6 webservices |
||
161 | // $geo6 = new Geo6(GEO6_PARTNER, GEO6_APP_ID); |
||
162 | // $response = $geo6->getNearestServicePoint('Afrikalaan', '289', '9000', 'nl', 7, 100); |
||
163 | // $response = $geo6->getServicePointDetails('220000', 'nl', '1'); |
||
164 | // $response = $geo6->getServicePointPage('220000', 'nl', '1'); |
||
165 | |||
166 | // Bpack 24/7 webservices |
||
167 | // $bpack247 = new Bpack247(BPACK_EMAIL, BPACK_PASSPHRASE); |
||
168 | // $response = $bpack247->getMember('344337728'); |
||
169 | |||
170 | // $customer = new Bpack247\Customer(); |
||
171 | // $customer->setFirstName('Tijs'); |
||
172 | // $customer->setLastName('Verkoyen'); |
||
173 | // $customer->setEmail('[email protected]'); |
||
174 | // $customer->setStreet('Afrikalaan'); |
||
175 | // $customer->setNumber('289'); |
||
176 | // $customer->setMobileNumber('123456'); |
||
177 | // $customer->setPostalCode('9000'); |
||
178 | // $customer->setPreferredLanguage('nl-BE'); |
||
179 | // $customer->setTitle('Mr.'); |
||
180 | // |
||
181 | // $response = $bpack247->createMember($customer); |
||
182 | |||
183 | // Form handler |
||
184 | // $formHandler = new FormHandler(ACCOUNT_ID, PASSPHRASE); |
||
185 | // $formHandler->setParameter('action', 'START'); |
||
186 | // $formHandler->setParameter('orderReference', $order->getReference()); |
||
187 | // $formHandler->setParameter('customerCountry', $sender->getAddress()->getCountryCode()); |
||
188 | // $response = $formHandler->getParameters(true); |
||
189 | } catch (Exception $e) { |
||
190 | var_dump($e); |
||
191 | } |
||
192 | |||
193 | // output |
||
194 | var_dump($response); |
||
195 |