Completed
Push — master ( 037db1...ba35b9 )
by Viacheslav
02:55
created

KassaApi   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 36
c 1
b 0
f 0
dl 0
loc 77
ccs 0
cts 37
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrders() 0 19 1
A getOrdersByDate() 0 15 1
A getOrdersBySearch() 0 14 1
A getOrdersByDays() 0 14 1
1
<?php
2
3
4
namespace slavkluev\Bizon365\Api;
5
6
use slavkluev\Bizon365\Helpers\UrlHelper;
7
8
class KassaApi extends AbstractApi
9
{
10
    const METHODS = [
11
        'get.orders' => 'kassa/orders/getorders',
12
    ];
13
14
    public function getOrdersBySearch(
15
        string $search,
16
        int $skip  = 0,
17
        int $limit = 100,
18
        bool $paid = null
19
    ) {
20
        return $this->getOrders(
21
            $skip,
22
            $limit,
23
            null,
24
            null,
25
            null,
26
            $paid,
27
            $search
28
        );
29
    }
30
31
    public function getOrdersByDays(
32
        int $days,
33
        int $skip  = 0,
34
        int $limit = 100,
35
        bool $paid = null
36
    ) {
37
        return $this->getOrders(
38
            $skip,
39
            $limit,
40
            $days,
41
            null,
42
            null,
43
            $paid,
44
            null
45
        );
46
    }
47
48
    public function getOrdersByDate(
49
        string $dateBegin,
50
        string $dateEnd,
51
        int $skip  = 0,
52
        int $limit = 100,
53
        bool $paid = null
54
    ) {
55
        return $this->getOrders(
56
            $skip,
57
            $limit,
58
            null,
59
            $dateBegin,
60
            $dateEnd,
61
            $paid,
62
            null
63
        );
64
    }
65
66
    public function getOrders(
67
        int $skip         = 0,
68
        int $limit        = 100,
69
        int $days         = null,
70
        string $dateBegin = null,
71
        string $dateEnd   = null,
72
        bool $paid        = null,
73
        string $search    = null
74
    ) {
75
        $url = UrlHelper::build(self::METHODS['get.orders'], [
76
            'skip'      => $skip,
77
            'limit'     => $limit,
78
            'days'      => $days,
79
            'dateBegin' => $dateBegin,
80
            'dateEnd'   => $dateEnd,
81
            'paid'      => $paid,
82
            'search'    => $search,
83
        ]);
84
        return $this->get($url);
85
    }
86
}
87