Passed
Pull Request — master (#24)
by
unknown
04:01
created

InternetDocument::edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 26
rs 9.6666
1
<?php
2
3
namespace Daaner\NovaPoshta\Models;
4
5
use Daaner\NovaPoshta\NovaPoshta;
6
use Daaner\NovaPoshta\Traits\DateTimes;
7
use Daaner\NovaPoshta\Traits\DocumentList;
8
use Daaner\NovaPoshta\Traits\InternetDocumentProperty;
9
use Daaner\NovaPoshta\Traits\Limit;
10
use Daaner\NovaPoshta\Traits\OptionsSeatProperty;
11
use Daaner\NovaPoshta\Traits\RecipientProperty;
12
use Daaner\NovaPoshta\Traits\SenderProperty;
13
14
class InternetDocument extends NovaPoshta
15
{
16
    use Limit, DateTimes, DocumentList; //getDocumentList
17
    use InternetDocumentProperty, SenderProperty, OptionsSeatProperty, RecipientProperty; //save
18
19
    protected $model = 'InternetDocument';
20
    protected $calledMethod;
21
    protected $methodProperties = [];
22
23
    /**
24
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/557eb417a0fe4f02fc455b2c
25
     *
26
     * @return array
27
     */
28
    public function getDocumentList()
29
    {
30
        $this->calledMethod = 'getDocumentList';
31
32
        $this->getPage();
33
        $this->addLimit();
34
35
        //DateTime
36
        $this->getDateTime();
37
        $this->getDateTimeFromTo();
38
39
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
40
    }
41
42
    /**
43
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/556ef753a0fe4f02049c664f
44
     *
45
     * @param string|null $description
46
     * @return array
47
     */
48
    public function save($description = null)
49
    {
50
        $this->calledMethod = 'save';
51
52
        $this->getPayerType();
53
        $this->getServiceType();
54
        $this->getPaymentMethod();
55
        $this->getCargoType();
56
57
        $this->getDateTime();
58
        $this->setDescription($description);
59
        $this->getSeatsAmount();
60
        $this->getCost();
61
        $this->getWeight();
62
        $this->getOptionsSeat();
63
64
        //Отправитель и другое
65
        $this->getSender();
66
        $this->getRecipientType();
67
        $this->getBackwardDeliveryData();
68
        $this->getNote();
69
        $this->getAdditionalInformation();
70
71
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
72
    }
73
74
    /**
75
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/556ef753a0fe4f02049c664f
76
     *
77
     * @param string|null $description
78
     * @return array
79
     */
80
    public function edit($description = null)
81
    {
82
        $this->calledMethod = 'update';
83
84
        $this->getRef();
85
86
        $this->getPayerType();
87
        $this->getServiceType();
88
        $this->getPaymentMethod();
89
        $this->getCargoType();
90
91
        $this->getDateTime();
92
        $this->setDescription($description);
93
        $this->getSeatsAmount();
94
        $this->getCost();
95
        $this->getWeight();
96
        $this->getOptionsSeat();
97
98
        //Отправитель и другое
99
        $this->getSender();
100
        $this->getRecipientType();
101
        $this->getBackwardDeliveryData();
102
        $this->getNote();
103
        $this->getAdditionalInformation();
104
105
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
106
    }
107
108
    /**
109
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/55701fa5a0fe4f0cf4fc53ec
110
     *
111
     * @param string|array $DocumentRefs
112
     * @return array
113
     */
114
    public function delete($DocumentRefs)
115
    {
116
        $this->calledMethod = 'delete';
117
118
        if (is_array($DocumentRefs) === false) {
119
            $DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs);
120
        }
121
122
        $this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $DocumentRefs);
123
124
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
125
    }
126
}
127