Passed
Push — master ( 3713cc...07ea52 )
by Andrey
04:19
created

InternetDocument::getMoneyTransferDocuments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
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; //getDocumentList || getMoneyTransferDocuments
17
    use DocumentList; //getDocumentList
18
    use InternetDocumentProperty, SenderProperty, OptionsSeatProperty, RecipientProperty; //save
19
20
    protected $model = 'InternetDocument';
21
    protected $calledMethod;
22
    protected $methodProperties = [];
23
24
    /**
25
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/557eb417a0fe4f02fc455b2c
26
     *
27
     * @return array
28
     */
29
    public function getDocumentList()
30
    {
31
        $this->calledMethod = 'getDocumentList';
32
33
        $this->getPage();
34
        $this->addLimit();
35
36
        //DateTime
37
        $this->getDateTime();
38
        $this->getDateTimeFromTo();
39
40
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
41
    }
42
43
    /**
44
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/556ef753a0fe4f02049c664f
45
     *
46
     * @param string|null $description
47
     * @return array
48
     */
49
    public function save($description = null)
50
    {
51
        $this->calledMethod = 'save';
52
53
        $this->getPayerType();
54
        $this->getServiceType();
55
        $this->getPaymentMethod();
56
        $this->getCargoType();
57
58
        $this->getDateTime();
59
        $this->setDescription($description);
60
        $this->getSeatsAmount();
61
        $this->getCost();
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/55701fa5a0fe4f0cf4fc53ec
76
     *
77
     * @param string|array $DocumentRefs
78
     * @return array
79
     */
80
    public function delete($DocumentRefs)
81
    {
82
        $this->calledMethod = 'delete';
83
84
        if (is_array($DocumentRefs) === false) {
85
            $DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs);
86
        }
87
88
        $this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $DocumentRefs);
89
90
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
91
    }
92
93
    /**
94
     * @param string|array $DocumentRefs
95
     * @return array
96
     */
97
    public function getMoneyTransferDocuments($dateFrom = null, $dateTo = null)
98
    {
99
        $this->calledMethod = 'getMoneyTransferDocuments';
100
101
        $this->addLimit();
102
        $this->getPage();
103
        $this->getDateFromTo($dateFrom, $dateTo);
104
105
        // dd($this->methodProperties);
106
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
107
    }
108
}
109