Passed
Push — master ( 7c0ad0...6b5b4a )
by Andrey
03:37
created

InternetDocument::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 23
rs 9.7333
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
     * @return array
46
     */
47
    public function save($description = null)
48
    {
49
        $this->calledMethod = 'save';
50
51
        $this->getPayerType();
52
        $this->getServiceType();
53
        $this->getPaymentMethod();
54
        $this->getCargoType();
55
56
        $this->getDateTime();
57
        $this->setDescription($description);
58
        $this->getSeatsAmount();
59
        $this->getCost();
60
        $this->getOptionsSeat();
61
62
        //Отправитель и другое
63
        $this->getSender();
64
        $this->getRecipientType();
65
        $this->getBackwardDeliveryData();
66
        $this->getNote();
67
        $this->getAdditionalInformation();
68
69
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
70
    }
71
72
    /**
73
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/55701fa5a0fe4f0cf4fc53ec
74
     *
75
     * @param string||array $DocumentRefs
0 ignored issues
show
Documentation Bug introduced by
The doc comment string||array at position 2 could not be parsed: Unknown type name '|' at position 2 in string||array.
Loading history...
76
     * @return array
77
     */
78
    public function delete($DocumentRefs)
79
    {
80
        $this->calledMethod = 'delete';
81
82
        if (is_array($DocumentRefs) === false) {
83
            $DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs);
84
        }
85
86
        $this->methodProperties['DocumentRefs'] = array_values($DocumentRefs);
87
88
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
89
    }
90
91
}
92