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