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/v1'; |
||
62 | |||
63 | /** |
||
64 | * API user |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $api_user; |
||
69 | |||
70 | /** |
||
71 | * API key |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | protected $api_key; |
||
76 | |||
77 | /** |
||
78 | * Token |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $token; |
||
83 | |||
84 | /** |
||
85 | * Constructor |
||
86 | * |
||
87 | * @param string $api_user |
||
88 | * @param string $api_key |
||
89 | * |
||
90 | * @throws \PakkelabelsException |
||
91 | */ |
||
92 | public function __construct($api_user, $api_key) |
||
98 | |||
99 | /** |
||
100 | * Login |
||
101 | * |
||
102 | * @return void |
||
103 | * @throws \PakkelabelsException |
||
104 | */ |
||
105 | protected function login() |
||
114 | |||
115 | /** |
||
116 | * Get balance |
||
117 | * |
||
118 | * @return void |
||
119 | * @throws \PakkelabelsException |
||
120 | */ |
||
121 | public function balance() |
||
126 | |||
127 | /** |
||
128 | * Get PDF |
||
129 | * |
||
130 | * @return base64 encoded string |
||
131 | * @throws \PakkelabelsException |
||
132 | */ |
||
133 | public function pdf($id) |
||
138 | |||
139 | /** |
||
140 | * Search shipments |
||
141 | * |
||
142 | * @param array $params |
||
143 | * |
||
144 | * @return mixed |
||
145 | * @throws \PakkelabelsException |
||
146 | */ |
||
147 | public function shipments($params = array()) |
||
152 | |||
153 | /** |
||
154 | * Get imported shipments |
||
155 | * |
||
156 | * @param array $params |
||
157 | * |
||
158 | * @return mixed |
||
159 | * @throws \PakkelabelsException |
||
160 | */ |
||
161 | public function importedShipments($params = array()) |
||
166 | |||
167 | /** |
||
168 | * Create imported shipment |
||
169 | * |
||
170 | * @param array $params |
||
171 | * |
||
172 | * @return mixed |
||
173 | * @throws \PakkelabelsException |
||
174 | */ |
||
175 | public function createImportedShipment($params) |
||
180 | |||
181 | /** |
||
182 | * Create shipment |
||
183 | * |
||
184 | * @param array $params |
||
185 | * |
||
186 | * @return mixed |
||
187 | * @throws \PakkelabelsException |
||
188 | */ |
||
189 | public function createShipment($params) |
||
194 | |||
195 | /** |
||
196 | * Get freight rates |
||
197 | * |
||
198 | * @return mixed |
||
199 | * @throws \PakkelabelsException |
||
200 | */ |
||
201 | public function freightRates() |
||
206 | |||
207 | /** |
||
208 | * Get payment requests |
||
209 | * |
||
210 | * @return mixed |
||
211 | * @throws \PakkelabelsException |
||
212 | */ |
||
213 | public function paymentRequests() |
||
218 | |||
219 | /** |
||
220 | * Get GLS Droppoints |
||
221 | * |
||
222 | * @param array $params |
||
223 | * |
||
224 | * @return mixed |
||
225 | * @throws \PakkelabelsException |
||
226 | */ |
||
227 | public function glsDroppoints($params) |
||
232 | |||
233 | /** |
||
234 | * Get token |
||
235 | * |
||
236 | * @return string |
||
237 | */ |
||
238 | public function getToken() |
||
242 | |||
243 | /** |
||
244 | * Make API Call |
||
245 | * |
||
246 | * @param string $method |
||
247 | * @param boolean $doPost |
||
248 | * @param array $params |
||
249 | * |
||
250 | * @return mixed |
||
251 | * @throws \PakkelabelsException |
||
252 | */ |
||
253 | protected function makeApiCall($method, $doPost = false, $params = array()) |
||
278 | } |
||
279 |