1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Models; |
4
|
|
|
|
5
|
|
|
use Daaner\NovaPoshta\NovaPoshta; |
6
|
|
|
use Daaner\NovaPoshta\Traits\CounterpartyProperty; |
7
|
|
|
use Daaner\NovaPoshta\Traits\Limit; |
8
|
|
|
|
9
|
|
|
class Counterparty extends NovaPoshta |
10
|
|
|
{ |
11
|
|
|
use Limit, CounterpartyProperty; |
12
|
|
|
|
13
|
|
|
protected $model = 'Counterparty'; |
14
|
|
|
protected $calledMethod; |
15
|
|
|
protected $methodProperties = []; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Загрузить список контрагентов отправителей / получателей / третье лицо. |
19
|
|
|
* |
20
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/a37a06df-8512-11ec-8ced-005056b2dbe1 Загрузить список контрагентов |
21
|
|
|
* @since 2022-11-07 |
22
|
|
|
* |
23
|
|
|
* @param string|null $find Поиск по названию |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
public function getCounterparties(?string $find = null): array |
27
|
|
|
{ |
28
|
|
|
$this->calledMethod = 'getCounterparties'; |
29
|
|
|
$this->getPage(); |
30
|
|
|
$this->getLimit(); |
31
|
|
|
|
32
|
|
|
$this->getCounterpartyProperty(); |
33
|
|
|
|
34
|
|
|
if ($find) { |
35
|
|
|
$this->methodProperties['FindByString'] = $find; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Загрузить список контактных лиц Контрагента. |
43
|
|
|
* |
44
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/a3575a67-8512-11ec-8ced-005056b2dbe1 Загрузить список контактных лиц Контрагента |
45
|
|
|
* @since 2022-11-07 |
46
|
|
|
* |
47
|
|
|
* @param string $Ref Ref контрагента |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function getCounterpartyContactPerson(string $Ref): array |
51
|
|
|
{ |
52
|
|
|
$this->calledMethod = 'getCounterpartyContactPersons'; |
53
|
|
|
$this->getPage(); |
54
|
|
|
$this->getLimit(); |
55
|
|
|
|
56
|
|
|
$this->methodProperties['Ref'] = $Ref; |
57
|
|
|
|
58
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Создать Контрагента. |
63
|
|
|
* |
64
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/0ae5dd75-8a5f-11ec-8ced-005056b2dbe1 Создать контрагента с типом Физ лицо |
65
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/bc3c44c7-8a8a-11ec-8ced-005056b2dbe1 Создать контрагента с типом Юр лицо |
66
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/b0fdf818-8a8e-11ec-8ced-005056b2dbe1 Создать контрагента с типом Третья особа |
67
|
|
|
* @since 2022-11-07 |
68
|
|
|
* |
69
|
|
|
* @param string $firstName Имя |
70
|
|
|
* @param string|null $lastName Фамилия |
71
|
|
|
* @param string|null $middleName Отчество |
72
|
|
|
* @param string|int|null $phone Телефон |
73
|
|
|
* @param string|null $email Электронная почта |
74
|
|
|
* @return array |
75
|
|
|
*/ |
76
|
|
|
public function save( |
77
|
|
|
string $firstName, |
78
|
|
|
?string $lastName = null, |
79
|
|
|
?string $middleName = null, |
80
|
|
|
$phone = null, |
81
|
|
|
?string $email = null |
82
|
|
|
): array { |
83
|
|
|
$this->calledMethod = 'save'; |
84
|
|
|
$this->getCounterpartyType(); |
85
|
|
|
$this->getCounterpartyProperty(); |
86
|
|
|
$this->getOwnershipForm(); |
87
|
|
|
$this->getEDRPOU(); |
88
|
|
|
|
89
|
|
|
if ($this->counterpartyProperty !== 'ThirdPerson') { |
90
|
|
|
$this->methodProperties['FirstName'] = $firstName; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
if ($lastName) { |
94
|
|
|
$this->methodProperties['LastName'] = $lastName; |
95
|
|
|
} |
96
|
|
|
if ($middleName) { |
97
|
|
|
$this->methodProperties['MiddleName'] = $middleName; |
98
|
|
|
} |
99
|
|
|
if ($phone) { |
100
|
|
|
$this->methodProperties['Phone'] = $phone; |
101
|
|
|
} |
102
|
|
|
if ($email) { |
103
|
|
|
$this->methodProperties['Email'] = $email; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Скачать параметры Контрагента. |
111
|
|
|
* |
112
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/a332efbf-8512-11ec-8ced-005056b2dbe1 Скачать параметры Контрагента |
113
|
|
|
* @since 2022-11-07 |
114
|
|
|
* |
115
|
|
|
* @param string $Ref Ref контрагента |
116
|
|
|
* @return array |
117
|
|
|
*/ |
118
|
|
|
public function getCounterpartyOptions(string $Ref): array |
119
|
|
|
{ |
120
|
|
|
$this->calledMethod = 'getCounterpartyOptions'; |
121
|
|
|
|
122
|
|
|
$this->methodProperties['Ref'] = $Ref; |
123
|
|
|
|
124
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Загрузить список адресов Контрагентов. |
129
|
|
|
* |
130
|
|
|
* @see https://developers.novaposhta.ua/view/model/a28f4b04-8512-11ec-8ced-005056b2dbe1/method/a30dbb7c-8512-11ec-8ced-005056b2dbe1 Загрузить список адресов Контрагентов |
131
|
|
|
* @since 2022-11-06 |
132
|
|
|
* |
133
|
|
|
* @param string $Ref Ref контрагента |
134
|
|
|
* @return array |
135
|
|
|
*/ |
136
|
|
|
public function getCounterpartyAddresses(string $Ref): array |
137
|
|
|
{ |
138
|
|
|
$this->calledMethod = 'getCounterpartyAddresses'; |
139
|
|
|
$this->getCounterpartyProperty(); |
140
|
|
|
|
141
|
|
|
$this->methodProperties['Ref'] = $Ref; |
142
|
|
|
|
143
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Получение данных об Контрагенте по номеру телефона (ФИО и прочее). |
148
|
|
|
* |
149
|
|
|
* @since 2022-11-07 НЕ ДОКУМЕНТИРОВАНО |
150
|
|
|
* |
151
|
|
|
* @param string|int $Phone Телефон |
152
|
|
|
* @param string $LastName Фамилия (минимум 3 буквы) |
153
|
|
|
* @return array |
154
|
|
|
*/ |
155
|
|
|
public function getCatalogCounterparty($Phone, string $LastName): array |
156
|
|
|
{ |
157
|
|
|
$this->calledMethod = 'getCatalogCounterparty'; |
158
|
|
|
|
159
|
|
|
$this->methodProperties['Phone'] = $Phone; |
160
|
|
|
$this->methodProperties['LastName'] = $LastName; |
161
|
|
|
|
162
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true); |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|