Code Duplication    Length = 31-34 lines in 2 locations

src/Client.php 2 locations

@@ 248-278 (lines=31) @@
245
     *
246
     * @return array
247
     */
248
    public function cashup($dealerMsisdn, $start, $end)
249
    {
250
        try {
251
            $response = $this->post(
252
                '/webservice/smartload/cashup',
253
                [
254
                    'headers' => [
255
                        'Authorization' => sprintf(
256
                            'Bearer %s',
257
                            $this->options['token']
258
                        ),
259
                    ],
260
                    'json'    => [
261
                        'smartloadId' => $dealerMsisdn,
262
                        'startDate'   => $start,
263
                        'endDate'     => $end,
264
                    ],
265
                ]
266
            );
267
268
            return [
269
                'status'    => 'ok',
270
                'http_code' => $response->getStatusCode(),
271
                'body'      => (string) $response->getBody(),
272
            ];
273
        } catch (\GuzzleHttp\Exception\ClientException $e) {
274
            return $this->clientError($e);
275
        } catch (\GuzzleHttp\Exception\ServerException $e) {
276
            return $this->parseError($e);
277
        }
278
    }
279
280
    /**
281
     * Authenticate and request current day cashup report.
@@ 289-322 (lines=34) @@
286
     *
287
     * @return array
288
     */
289
    public function cashupToday($dealerMsisdn)
290
    {
291
        try {
292
            $response = $this->get(
293
                sprintf(
294
                    '/webservice/smartload/cashup/%s',
295
                    $dealerMsisdn
296
                ),
297
                [
298
                    'headers' => [
299
                        'Authorization' => sprintf(
300
                            'Bearer %s',
301
                            $this->options['token']
302
                        ),
303
                    ],
304
                    'json'    => [
305
                        'smartloadId' => $dealerMsisdn,
306
                        'startDate'   => $start,
307
                        'endDate'     => $end,
308
                    ],
309
                ]
310
            );
311
312
            return [
313
                'status'    => 'ok',
314
                'http_code' => $response->getStatusCode(),
315
                'body'      => (string) $response->getBody(),
316
            ];
317
        } catch (\GuzzleHttp\Exception\ClientException $e) {
318
            return $this->clientError($e);
319
        } catch (\GuzzleHttp\Exception\ServerException $e) {
320
            return $this->parseError($e);
321
        }
322
    }
323
324
    /**
325
     * Authenticate and retrieves a list of all available networks.