Test Failed
Pull Request — master (#3)
by Lars
04:32
created
src/Pakkelabels.php 3 patches
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -54,301 +54,301 @@  discard block
 block discarded – undo
54 54
  */
55 55
 class Pakkelabels {
56 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 \PakkelabelsDKException
99
-   */
100
-  public function __construct($api_user, $api_key) {
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 \PakkelabelsDKException
99
+     */
100
+    public function __construct($api_user, $api_key) {
101 101
     $this->api_user = $api_user;
102 102
     $this->api_key  = $api_key;
103 103
     $this->login();
104
-  }
105
-
106
-  /**
107
-   * Login
108
-   *
109
-   * @return void
110
-   * @throws \PakkelabelsDKException
111
-   */
112
-  protected function login() {
104
+    }
105
+
106
+    /**
107
+     * Login
108
+     *
109
+     * @return void
110
+     * @throws \PakkelabelsDKException
111
+     */
112
+    protected function login() {
113 113
     $result = $this->makeApiCall(
114
-      'users/login',
115
-      TRUE,
116
-      array('api_user' => $this->api_user, 'api_key' => $this->api_key)
114
+        'users/login',
115
+        TRUE,
116
+        array('api_user' => $this->api_user, 'api_key' => $this->api_key)
117 117
     );
118 118
 
119 119
     $this->token = $result['token'];
120
-  }
121
-
122
-  /**
123
-   * Get balance
124
-   *
125
-   * @return void
126
-   * @throws \PakkelabelsDKException
127
-   */
128
-  public function balance() {
120
+    }
121
+
122
+    /**
123
+     * Get balance
124
+     *
125
+     * @return void
126
+     * @throws \PakkelabelsDKException
127
+     */
128
+    public function balance() {
129 129
     $result = $this->makeApiCall('users/balance');
130 130
 
131 131
     return $result['balance'];
132
-  }
133
-
134
-  /**
135
-   * Get PDF
136
-   *
137
-   * @return base64 encoded string
138
-   * @throws \PakkelabelsDKException
139
-   */
140
-  public function pdf($id) {
132
+    }
133
+
134
+    /**
135
+     * Get PDF
136
+     *
137
+     * @return base64 encoded string
138
+     * @throws \PakkelabelsDKException
139
+     */
140
+    public function pdf($id) {
141 141
     $result = $this->makeApiCall('shipments/pdf', FALSE, array('id' => $id));
142 142
 
143 143
     return $result['base64'];
144
-  }
145
-
146
-  /**
147
-   * PDF Multiple.
148
-   *
149
-   * @param string $ids
150
-   *
151
-   * @return base64 encoded string.
152
-   */
153
-  public function pdfMulti(string $ids) {
144
+    }
145
+
146
+    /**
147
+     * PDF Multiple.
148
+     *
149
+     * @param string $ids
150
+     *
151
+     * @return base64 encoded string.
152
+     */
153
+    public function pdfMulti(string $ids) {
154 154
     $result = $this->makeApiCall(
155
-      'shipments/pdf_multi',
156
-      FALSE,
157
-      array('ids' => $ids)
155
+        'shipments/pdf_multi',
156
+        FALSE,
157
+        array('ids' => $ids)
158 158
     );
159 159
 
160 160
     return $result['base64'];
161
-  }
162
-
163
-  /**
164
-   * Get ZPL
165
-   *
166
-   * @return base64 encoded string
167
-   * @throws \PakkelabelsDKException
168
-   */
169
-  public function zpl($id) {
161
+    }
162
+
163
+    /**
164
+     * Get ZPL
165
+     *
166
+     * @return base64 encoded string
167
+     * @throws \PakkelabelsDKException
168
+     */
169
+    public function zpl($id) {
170 170
     $result = $this->makeApiCall('shipments/zpl', FALSE, array('id' => $id));
171 171
 
172 172
     return $result['base64'];
173
-  }
174
-
175
-  /**
176
-   * Search shipments
177
-   *
178
-   * @param array $params
179
-   *
180
-   * @return mixed
181
-   * @throws \PakkelabelsDKException
182
-   */
183
-  public function shipments($params = array()) {
173
+    }
174
+
175
+    /**
176
+     * Search shipments
177
+     *
178
+     * @param array $params
179
+     *
180
+     * @return mixed
181
+     * @throws \PakkelabelsDKException
182
+     */
183
+    public function shipments($params = array()) {
184 184
     $result = $this->makeApiCall('shipments/shipments', FALSE, $params);
185 185
 
186 186
     return $result;
187
-  }
188
-
189
-  /**
190
-   * Get imported shipments
191
-   *
192
-   * @param array $params
193
-   *
194
-   * @return mixed
195
-   * @throws \PakkelabelsDKException
196
-   */
197
-  public function importedShipments($params = array()) {
187
+    }
188
+
189
+    /**
190
+     * Get imported shipments
191
+     *
192
+     * @param array $params
193
+     *
194
+     * @return mixed
195
+     * @throws \PakkelabelsDKException
196
+     */
197
+    public function importedShipments($params = array()) {
198 198
     $result = $this->makeApiCall(
199
-      'shipments/imported_shipments',
200
-      FALSE,
201
-      $params
199
+        'shipments/imported_shipments',
200
+        FALSE,
201
+        $params
202 202
     );
203 203
 
204 204
     return $result;
205
-  }
206
-
207
-  /**
208
-   * Create imported shipment
209
-   *
210
-   * @param array $params
211
-   *
212
-   * @return mixed
213
-   * @throws \PakkelabelsDKException
214
-   */
215
-  public function createImportedShipment($params) {
205
+    }
206
+
207
+    /**
208
+     * Create imported shipment
209
+     *
210
+     * @param array $params
211
+     *
212
+     * @return mixed
213
+     * @throws \PakkelabelsDKException
214
+     */
215
+    public function createImportedShipment($params) {
216 216
     $result = $this->makeApiCall('shipments/imported_shipment', TRUE, $params);
217 217
 
218 218
     return $result;
219
-  }
220
-
221
-  /**
222
-   * Create shipment
223
-   *
224
-   * @param array $params
225
-   *
226
-   * @return mixed
227
-   * @throws \PakkelabelsDKException
228
-   */
229
-  public function createShipment($params) {
219
+    }
220
+
221
+    /**
222
+     * Create shipment
223
+     *
224
+     * @param array $params
225
+     *
226
+     * @return mixed
227
+     * @throws \PakkelabelsDKException
228
+     */
229
+    public function createShipment($params) {
230 230
     $result = $this->makeApiCall('shipments/shipment', TRUE, $params);
231 231
 
232 232
     return $result;
233
-  }
234
-
235
-  /**
236
-   * Create shipment own customernumber.
237
-   *
238
-   * @param array $params
239
-   *
240
-   * @return mixed
241
-   * @throws \PakkelabelsDKException
242
-   */
243
-  public function createShipmentOwnCustomerNumber($params) {
233
+    }
234
+
235
+    /**
236
+     * Create shipment own customernumber.
237
+     *
238
+     * @param array $params
239
+     *
240
+     * @return mixed
241
+     * @throws \PakkelabelsDKException
242
+     */
243
+    public function createShipmentOwnCustomerNumber($params) {
244 244
     $result = $this->makeApiCall(
245
-      'shipments/shipment_own_customer_number',
246
-      TRUE,
247
-      $params
245
+        'shipments/shipment_own_customer_number',
246
+        TRUE,
247
+        $params
248 248
     );
249 249
 
250 250
     return $result;
251
-  }
252
-
253
-  /**
254
-   * Get freight rates
255
-   *
256
-   * @return mixed
257
-   * @throws \PakkelabelsDKException
258
-   */
259
-  public function freightRates() {
251
+    }
252
+
253
+    /**
254
+     * Get freight rates
255
+     *
256
+     * @return mixed
257
+     * @throws \PakkelabelsDKException
258
+     */
259
+    public function freightRates() {
260 260
     $result = $this->makeApiCall('shipments/freight_rates');
261 261
 
262 262
     return $result;
263
-  }
264
-
265
-  /**
266
-   * Add to print queue.
267
-   *
268
-   * @param $params
269
-   *
270
-   * @return mixed
271
-   */
272
-  public function addToPrintQueue($params) {
263
+    }
264
+
265
+    /**
266
+     * Add to print queue.
267
+     *
268
+     * @param $params
269
+     *
270
+     * @return mixed
271
+     */
272
+    public function addToPrintQueue($params) {
273 273
     return $this->makeApiCall('shipments/add_to_print_queue', TRUE, $params);
274
-  }
275
-
276
-  /**
277
-   * Get payment requests
278
-   *
279
-   * @return mixed
280
-   * @throws \PakkelabelsDKException
281
-   */
282
-  public function paymentRequests() {
274
+    }
275
+
276
+    /**
277
+     * Get payment requests
278
+     *
279
+     * @return mixed
280
+     * @throws \PakkelabelsDKException
281
+     */
282
+    public function paymentRequests() {
283 283
     $result = $this->makeApiCall('users/payment_requests');
284 284
 
285 285
     return $result;
286
-  }
287
-
288
-  /**
289
-   * Get GLS Droppoints
290
-   *
291
-   * @param array $params
292
-   *
293
-   * @return mixed
294
-   * @throws \PakkelabelsDKException
295
-   */
296
-  public function glsDroppoints($params) {
286
+    }
287
+
288
+    /**
289
+     * Get GLS Droppoints
290
+     *
291
+     * @param array $params
292
+     *
293
+     * @return mixed
294
+     * @throws \PakkelabelsDKException
295
+     */
296
+    public function glsDroppoints($params) {
297 297
     $result = $this->makeApiCall('shipments/gls_droppoints', FALSE, $params);
298 298
 
299 299
     return $result;
300
-  }
301
-
302
-  /**
303
-   * Get PDK Droppoints
304
-   *
305
-   * @param array $params
306
-   *
307
-   * @return mixed
308
-   * @throws \PakkelabelsDKException
309
-   */
310
-  public function pdkDroppoints($params) {
300
+    }
301
+
302
+    /**
303
+     * Get PDK Droppoints
304
+     *
305
+     * @param array $params
306
+     *
307
+     * @return mixed
308
+     * @throws \PakkelabelsDKException
309
+     */
310
+    public function pdkDroppoints($params) {
311 311
     $result = $this->makeApiCall('shipments/pdk_droppoints', FALSE, $params);
312 312
 
313 313
     return $result;
314
-  }
315
-
316
-  /**
317
-   * Get token
318
-   *
319
-   * @return string
320
-   */
321
-  public function getToken() {
314
+    }
315
+
316
+    /**
317
+     * Get token
318
+     *
319
+     * @return string
320
+     */
321
+    public function getToken() {
322 322
     return $this->token;
323
-  }
324
-
325
-  /**
326
-   * Make API Call
327
-   *
328
-   * @param string  $method
329
-   * @param boolean $doPost
330
-   * @param array   $params
331
-   *
332
-   * @return mixed
333
-   * @throws \PakkelabelsDK\Exception\PakkelabelsDKException
334
-   */
335
-  protected function makeApiCall($method, $doPost = FALSE, $params = array()) {
323
+    }
324
+
325
+    /**
326
+     * Make API Call
327
+     *
328
+     * @param string  $method
329
+     * @param boolean $doPost
330
+     * @param array   $params
331
+     *
332
+     * @return mixed
333
+     * @throws \PakkelabelsDK\Exception\PakkelabelsDKException
334
+     */
335
+    protected function makeApiCall($method, $doPost = FALSE, $params = array()) {
336 336
     $ch                   = curl_init();
337 337
     $params['token']      = $this->token;
338 338
     $params['user_agent'] = 'pdk_php_library v' . self::VERSION;
339 339
 
340 340
     $query = http_build_query($params);
341 341
     if ($doPost === TRUE) {
342
-      curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . $method);
343
-      curl_setopt($ch, CURLOPT_POST, 1);
344
-      curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
342
+        curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . $method);
343
+        curl_setopt($ch, CURLOPT_POST, 1);
344
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
345 345
     }
346 346
     else {
347
-      curl_setopt(
347
+        curl_setopt(
348 348
         $ch,
349 349
         CURLOPT_URL,
350 350
         self::API_ENDPOINT . '/' . $method . '?' . $query
351
-      );
351
+        );
352 352
     }
353 353
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
354 354
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
     $output = json_decode($output, TRUE);
361 361
 
362 362
     if ($http_code != 200) {
363
-      throw new PakkelabelsDKException($output['message']);
363
+        throw new PakkelabelsDKException($output['message']);
364 364
     }
365 365
 
366 366
     return $output;
367
-  }
367
+    }
368 368
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
   protected function makeApiCall($method, $doPost = FALSE, $params = array()) {
336 336
     $ch                   = curl_init();
337 337
     $params['token']      = $this->token;
338
-    $params['user_agent'] = 'pdk_php_library v' . self::VERSION;
338
+    $params['user_agent'] = 'pdk_php_library v'.self::VERSION;
339 339
 
340 340
     $query = http_build_query($params);
341 341
     if ($doPost === TRUE) {
342
-      curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . $method);
342
+      curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT.'/'.$method);
343 343
       curl_setopt($ch, CURLOPT_POST, 1);
344 344
       curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
345 345
     }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
       curl_setopt(
348 348
         $ch,
349 349
         CURLOPT_URL,
350
-        self::API_ENDPOINT . '/' . $method . '?' . $query
350
+        self::API_ENDPOINT.'/'.$method.'?'.$query
351 351
       );
352 352
     }
353 353
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -342,8 +342,7 @@
 block discarded – undo
342 342
       curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . $method);
343 343
       curl_setopt($ch, CURLOPT_POST, 1);
344 344
       curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
345
-    }
346
-    else {
345
+    } else {
347 346
       curl_setopt(
348 347
         $ch,
349 348
         CURLOPT_URL,
Please login to merge, or discard this patch.