1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace mb24dev\AmoCRM\Entity; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Lead |
7
|
|
|
* |
8
|
|
|
* @package mb24dev\AmoCRM\Entity |
9
|
|
|
*/ |
10
|
|
|
class Lead implements AmoEntityInterface, AmoIdentityInterface |
11
|
|
|
{ |
12
|
|
|
private $id; |
13
|
|
|
private $name; |
14
|
|
|
private $statusID; |
15
|
|
|
private $pipelineID; |
16
|
|
|
private $price; |
17
|
|
|
private $responsibleUserID; |
18
|
|
|
private $requestID; |
19
|
|
|
private $customFields; |
20
|
|
|
private $tags; |
21
|
|
|
private $visitorUID; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \DateTime |
25
|
|
|
*/ |
26
|
|
|
private $dateCreate; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var \DateTime |
30
|
|
|
*/ |
31
|
|
|
private $lastModified; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Lead constructor. |
35
|
|
|
* |
36
|
|
|
* @param $name |
37
|
|
|
* @param $statusID |
38
|
|
|
*/ |
39
|
|
|
public function __construct($name, $statusID) |
40
|
|
|
{ |
41
|
|
|
$this->name = $name; |
42
|
|
|
$this->statusID = $statusID; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param mixed $id |
47
|
|
|
* @return $this |
48
|
|
|
*/ |
49
|
|
|
public function setAmoId($id) |
50
|
|
|
{ |
51
|
|
|
$this->id = $id; |
52
|
|
|
|
53
|
|
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param mixed $name |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function setAmoName($name) |
61
|
|
|
{ |
62
|
|
|
$this->name = $name; |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param \DateTime $dateCreate |
69
|
|
|
* @return $this |
70
|
|
|
*/ |
71
|
|
|
public function setAmoDateCreate(\DateTime $dateCreate) |
72
|
|
|
{ |
73
|
|
|
$this->dateCreate = $dateCreate; |
74
|
|
|
|
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param \DateTime $lastModified |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function setAmoLastModified(\DateTime $lastModified) |
83
|
|
|
{ |
84
|
|
|
$this->lastModified = $lastModified; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param mixed $statusID |
91
|
|
|
* @return $this |
92
|
|
|
*/ |
93
|
|
|
public function setAmoStatusID($statusID) |
94
|
|
|
{ |
95
|
|
|
$this->statusID = $statusID; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param mixed $pipelineID |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
|
|
public function setAmoPipelineID($pipelineID) |
105
|
|
|
{ |
106
|
|
|
$this->pipelineID = $pipelineID; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param mixed $price |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
|
|
public function setAmoPrice($price) |
116
|
|
|
{ |
117
|
|
|
$this->price = $price; |
118
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param mixed $responsibleUserID |
124
|
|
|
* @return $this |
125
|
|
|
*/ |
126
|
|
|
public function setAmoResponsibleUserID($responsibleUserID) |
127
|
|
|
{ |
128
|
|
|
$this->responsibleUserID = $responsibleUserID; |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param mixed $requestID |
135
|
|
|
* @return $this |
136
|
|
|
*/ |
137
|
|
|
public function setAmoRequestID($requestID) |
138
|
|
|
{ |
139
|
|
|
$this->requestID = $requestID; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param mixed $customFields |
146
|
|
|
* @return $this |
147
|
|
|
*/ |
148
|
|
|
public function setAmoCustomFields($customFields) |
149
|
|
|
{ |
150
|
|
|
$this->customFields = $customFields; |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param mixed $tags |
157
|
|
|
* @return $this |
158
|
|
|
*/ |
159
|
|
|
public function setAmoTags($tags) |
160
|
|
|
{ |
161
|
|
|
$this->tags = $tags; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @param mixed $visitorUID |
168
|
|
|
* @return $this |
169
|
|
|
*/ |
170
|
|
|
public function setAmoVisitorUID($visitorUID) |
171
|
|
|
{ |
172
|
|
|
$this->visitorUID = $visitorUID; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return array |
179
|
|
|
*/ |
180
|
|
|
public function toAmoArray() |
181
|
|
|
{ |
182
|
|
|
return [ |
183
|
|
|
'id' => $this->id, |
184
|
|
|
'name' => $this->name, |
185
|
|
|
'date_create' => $this->dateCreate ? $this->dateCreate->getTimestamp() : null, |
186
|
|
|
'last_modified' => $this->lastModified ? $this->lastModified->getTimestamp() : null, |
187
|
|
|
'status_id' => $this->statusID, |
188
|
|
|
'pipeline_id' => $this->pipelineID, |
189
|
|
|
'price' => $this->price, |
190
|
|
|
'responsible_user_id' => $this->responsibleUserID, |
191
|
|
|
'request_id' => $this->requestID, |
192
|
|
|
'custom_fields' => array_map( |
193
|
|
|
function (AmoEntityInterface $customField) { |
194
|
|
|
return $customField->toAmoArray(); |
195
|
|
|
}, |
196
|
|
|
$this->customFields |
197
|
|
|
), |
198
|
|
|
'tags' => $this->tags, |
199
|
|
|
'visitor_uid' => $this->visitorUID, |
200
|
|
|
]; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return mixed |
205
|
|
|
*/ |
206
|
|
|
public function getAmoID() |
207
|
|
|
{ |
208
|
|
|
return $this->id; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
} |
212
|
|
|
|