ScanSheet   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 161
Duplicated Lines 0 %

Importance

Changes 6
Bugs 3 Features 0
Metric Value
eloc 44
c 6
b 3
f 0
dl 0
loc 161
rs 10
wmc 14

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getScanSheetDocuments() 0 10 1
A getScanSheet() 0 8 1
A deleteScanSheet() 0 11 2
A updateScanSheet() 0 9 1
A insertDocuments() 0 19 5
A getScanSheetList() 0 5 1
A removeDocuments() 0 16 3
1
<?php
2
3
namespace Daaner\NovaPoshta\Models;
4
5
use Carbon\Carbon;
6
use Daaner\NovaPoshta\NovaPoshta;
7
use Daaner\NovaPoshta\Traits\DateTimes;
8
use Daaner\NovaPoshta\Traits\Limit;
9
10
class ScanSheet extends NovaPoshta
11
{
12
    use Limit, DateTimes;
13
14
    protected $model = 'ScanSheet';
15
    protected $calledMethod;
16
    protected $methodProperties = null;
17
18
    /**
19
     * Удалить (расформировать) реестр отправлений.
20
     *
21
     * @see https://developers.novaposhta.ua/view/model/a46fc4f4-8512-11ec-8ced-005056b2dbe1/method/a50e049b-8512-11ec-8ced-005056b2dbe1 Расформировать реестр
22
     * @since 2022-11-07
23
     *
24
     * @param  string|array  $ScanSheetRefs  Ref реестра
25
     * @return array
26
     */
27
    public function deleteScanSheet($ScanSheetRefs): array
28
    {
29
        $this->calledMethod = 'deleteScanSheet';
30
31
        if (is_array($ScanSheetRefs) === false) {
32
            $ScanSheetRefs = explode(', ', /** @scrutinizer ignore-type */ $ScanSheetRefs);
33
        }
34
35
        $this->methodProperties['ScanSheetRefs'] = array_values(/** @scrutinizer ignore-type */ $ScanSheetRefs);
36
37
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
38
    }
39
40
    /**
41
     * Добавить экспресс-накладные в реестр.
42
     *
43
     * @see https://developers.novaposhta.ua/view/model/a46fc4f4-8512-11ec-8ced-005056b2dbe1/method/a482293c-8512-11ec-8ced-005056b2dbe1 Добавить экспресс-накладные в реестр
44
     * @since 2022-11-07
45
     *
46
     * @param  string|array  $DocumentRefs  Ref или массив Ref ТТН
47
     * @param  string|null  $Ref  Ref реестра, если есть
48
     * @param  string|Carbon|null  $Date  Дата, если необходимо создать реестр на определенную дату
49
     * @return array
50
     */
51
    public function insertDocuments($DocumentRefs, ?string $Ref = null, $Date = null): array
52
    {
53
        $this->calledMethod = 'insertDocuments';
54
55
        if (is_array($DocumentRefs) === false) {
56
            $DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs);
57
        }
58
59
        $this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $DocumentRefs);
60
61
        if ($Ref) {
62
            $this->methodProperties['Ref'] = $Ref;
63
        }
64
65
        if ($Date && $newDate = $this->checkDate($Date)) {
66
            $this->methodProperties['Date'] = $newDate;
67
        }
68
69
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
70
    }
71
72
    /**
73
     * Загрузить список реестров.
74
     *
75
     * @see https://developers.novaposhta.ua/view/model/a46fc4f4-8512-11ec-8ced-005056b2dbe1/method/a4abdd36-8512-11ec-8ced-005056b2dbe1 Загрузить список реестров
76
     * @since 2022-11-07
77
     *
78
     * @return array
79
     */
80
    public function getScanSheetList(): array
81
    {
82
        $this->calledMethod = 'getScanSheetList';
83
84
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
85
    }
86
87
    /**
88
     * Загрузить информацию по одному реестру.
89
     *
90
     * @since 2022-11-07 НЕ ДОКУМЕНТИРОВАНО
91
     *
92
     * @param  string  $ref  Ref реестра
93
     * @return array
94
     */
95
    public function getScanSheet(string $ref): array
96
    {
97
        $this->calledMethod = 'getScanSheet';
98
99
        $this->methodProperties = [];
100
        $this->methodProperties['Ref'] = $ref;
101
102
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
103
    }
104
105
    /**
106
     * Удалить экспресс-накладные из реестра.
107
     *
108
     * @see https://developers.novaposhta.ua/view/model/a46fc4f4-8512-11ec-8ced-005056b2dbe1/method/a53dea8a-8512-11ec-8ced-005056b2dbe1 Удалить экспресс-накладные из реестра
109
     * @since 2022-11-07
110
     *
111
     * @param  string|array  $documents  Ref или массив Ref ТТН
112
     * @param  string|null  $ref  Ref реестра
113
     * @return array
114
     */
115
    public function removeDocuments($documents, ?string $ref = null): array
116
    {
117
        $this->calledMethod = 'removeDocuments';
118
119
        $this->methodProperties = [];
120
        if ($ref) {
121
            $this->methodProperties['Ref'] = $ref;
122
        }
123
124
        if (is_array($documents) === false) {
125
            $documents = explode(', ', /** @scrutinizer ignore-type */ $documents);
126
        }
127
128
        $this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $documents);
129
130
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
131
    }
132
133
    /**
134
     * Получить краткий список ТТН реестра.
135
     *
136
     * @since 2022-11-07
137
     *
138
     * @param  string  $ref  Ref реестра
139
     * @return array
140
     */
141
    public function getScanSheetDocuments(string $ref): array
142
    {
143
        $this->methodProperties = [];
144
        $this->getPage();
145
        $this->getLimit();
146
147
        $this->calledMethod = 'getScanSheetDocuments';
148
        $this->methodProperties['Ref'] = $ref;
149
150
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
151
    }
152
153
    /**
154
     * Обновить описание реестра.
155
     *
156
     * @since 2022-11-07
157
     *
158
     * @param  string  $ref  Ref реестра
159
     * @param  string  $description  Описание
160
     * @return array
161
     */
162
    public function updateScanSheet(string $ref, string $description): array
163
    {
164
        $this->methodProperties = [];
165
166
        $this->calledMethod = 'updateScanSheet';
167
        $this->methodProperties['Ref'] = $ref;
168
        $this->methodProperties['Description'] = $description;
169
170
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
171
    }
172
}
173