1 | <?php |
||
54 | class Pakkelabels |
||
55 | { |
||
56 | |||
57 | /** |
||
58 | * API Endpoint URL |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | const API_ENDPOINT = 'https://app.pakkelabels.dk/api/public/v2'; |
||
63 | |||
64 | /** |
||
65 | * API Endpoint URL |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | const VERSION = '1.1'; |
||
70 | |||
71 | /** |
||
72 | * API user |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | protected $api_user; |
||
77 | |||
78 | /** |
||
79 | * API key |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $api_key; |
||
84 | |||
85 | /** |
||
86 | * Token |
||
87 | * |
||
88 | * @var string |
||
89 | */ |
||
90 | protected $token; |
||
91 | |||
92 | /** |
||
93 | * Constructor |
||
94 | * |
||
95 | * @param string $api_user |
||
96 | * @param string $api_key |
||
97 | * |
||
98 | * @throws \PakkelabelsException |
||
99 | */ |
||
100 | 1 | public function __construct($api_user, $api_key) |
|
106 | |||
107 | /** |
||
108 | * Login |
||
109 | * |
||
110 | * @return void |
||
111 | * @throws \PakkelabelsException |
||
112 | */ |
||
113 | 1 | protected function login() |
|
122 | |||
123 | /** |
||
124 | * Get balance |
||
125 | * |
||
126 | * @return void |
||
127 | * @throws \PakkelabelsException |
||
128 | */ |
||
129 | public function balance() |
||
134 | |||
135 | /** |
||
136 | * Get PDF |
||
137 | * |
||
138 | * @return base64 encoded string |
||
139 | * @throws \PakkelabelsException |
||
140 | */ |
||
141 | public function pdf($id) |
||
146 | |||
147 | /** |
||
148 | * Get pickup points. |
||
149 | * |
||
150 | * @param array $params |
||
151 | * |
||
152 | * @return mixed |
||
153 | * @throws \PakkelabelsException |
||
154 | */ |
||
155 | public function getPickupPoints($params = array()) |
||
159 | |||
160 | /** |
||
161 | * Search shipments |
||
162 | * |
||
163 | * @param array $params |
||
164 | * |
||
165 | * @return mixed |
||
166 | * @throws \PakkelabelsException |
||
167 | */ |
||
168 | public function shipments($params = array()) |
||
173 | |||
174 | /** |
||
175 | * Get imported shipments |
||
176 | * |
||
177 | * @param array $params |
||
178 | * |
||
179 | * @return mixed |
||
180 | * @throws \PakkelabelsException |
||
181 | */ |
||
182 | public function importedShipments($params = array()) |
||
187 | |||
188 | /** |
||
189 | * Create imported shipment |
||
190 | * |
||
191 | * @param array $params |
||
192 | * |
||
193 | * @return mixed |
||
194 | * @throws \PakkelabelsException |
||
195 | */ |
||
196 | public function createImportedShipment($params) |
||
201 | |||
202 | /** |
||
203 | * Create shipment |
||
204 | * |
||
205 | * @param array $params |
||
206 | * |
||
207 | * @return mixed |
||
208 | * @throws \PakkelabelsException |
||
209 | */ |
||
210 | public function createShipment($params) |
||
215 | |||
216 | /** |
||
217 | * Get freight rates |
||
218 | * |
||
219 | * @return mixed |
||
220 | * @throws \PakkelabelsException |
||
221 | */ |
||
222 | public function freightRates() |
||
227 | |||
228 | /** |
||
229 | * Get payment requests |
||
230 | * |
||
231 | * @return mixed |
||
232 | * @throws \PakkelabelsException |
||
233 | */ |
||
234 | public function paymentRequests() |
||
239 | |||
240 | /** |
||
241 | * Get GLS Droppoints |
||
242 | * |
||
243 | * @param array $params |
||
244 | * |
||
245 | * @return mixed |
||
246 | * @throws \PakkelabelsException |
||
247 | */ |
||
248 | public function glsDroppoints($params) |
||
253 | |||
254 | /** |
||
255 | * Get PostDK Droppoints |
||
256 | * |
||
257 | * @param array $params |
||
258 | * |
||
259 | * @return mixed |
||
260 | * @throws \PakkelabelsException |
||
261 | */ |
||
262 | public function pdkDroppoints($params) |
||
266 | |||
267 | /** |
||
268 | * Get token |
||
269 | * |
||
270 | * @return string |
||
271 | */ |
||
272 | public function getToken() |
||
276 | |||
277 | /** |
||
278 | * Make API Call |
||
279 | * |
||
280 | * @param string $method |
||
281 | * @param boolean $doPost |
||
282 | * @param array $params |
||
283 | * |
||
284 | * @return mixed |
||
285 | * @throws \PakkelabelsException |
||
286 | */ |
||
287 | 1 | protected function makeApiCall($method, $doPost = false, $params = array()) |
|
313 | } |
||
314 |