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