|
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
|
|
|
|
|
97
|
|
|
//Отправитель и другое |
|
98
|
|
|
$this->getSender(); |
|
99
|
|
|
$this->getRecipientType(); |
|
100
|
|
|
$this->getBackwardDeliveryData(); |
|
101
|
|
|
$this->getNote(); |
|
102
|
|
|
$this->getAdditionalInformation(); |
|
103
|
|
|
|
|
104
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/55701fa5a0fe4f0cf4fc53ec |
|
109
|
|
|
* |
|
110
|
|
|
* @param string|array $DocumentRefs |
|
111
|
|
|
* @return array |
|
112
|
|
|
*/ |
|
113
|
|
|
public function delete($DocumentRefs) |
|
114
|
|
|
{ |
|
115
|
|
|
$this->calledMethod = 'delete'; |
|
116
|
|
|
|
|
117
|
|
|
if (is_array($DocumentRefs) === false) { |
|
118
|
|
|
$DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
$this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $DocumentRefs); |
|
122
|
|
|
|
|
123
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* printDocument method of InternetDocument model. |
|
128
|
|
|
* |
|
129
|
|
|
* @param array|string $documentRefs Array of Documents IDs |
|
130
|
|
|
* @param string $type (pdf|html) |
|
131
|
|
|
* |
|
132
|
|
|
* @return mixed |
|
133
|
|
|
*/ |
|
134
|
|
|
public function printDocument($DocumentRefs, $type = 'html') |
|
135
|
|
|
{ |
|
136
|
|
|
$this->calledMethod = 'printDocument'; |
|
137
|
|
|
|
|
138
|
|
|
if (is_array($DocumentRefs) === false) { |
|
139
|
|
|
$DocumentRefs = explode(', ', /** @scrutinizer ignore-type */ $DocumentRefs); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
$this->methodProperties['DocumentRefs'] = array_values(/** @scrutinizer ignore-type */ $DocumentRefs); |
|
143
|
|
|
$this->methodProperties['type'] = $type; |
|
144
|
|
|
|
|
145
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|