1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Teebot\Api\Entity; |
4
|
|
|
|
5
|
|
|
use Teebot\Api\Entity\Inline\InlineQuery; |
6
|
|
|
use Teebot\Api\Entity\Inline\Result\ChosenInlineResult; |
7
|
|
|
|
8
|
|
|
class Update extends AbstractEntity |
9
|
|
|
{ |
10
|
|
|
const ENTITY_TYPE = 'Update'; |
11
|
|
|
|
12
|
|
|
protected $updateType = Message::ENTITY_TYPE; |
13
|
|
|
|
14
|
|
|
protected $update_id; |
15
|
|
|
|
16
|
|
|
protected $message; |
17
|
|
|
|
18
|
|
|
protected $edited = false; |
19
|
|
|
|
20
|
|
|
protected $inline_query; |
21
|
|
|
|
22
|
|
|
protected $chosen_inline_result; |
23
|
|
|
|
24
|
|
|
protected $builtInEntities = [ |
25
|
|
|
'message' => Message::class, |
26
|
|
|
'inline_query' => InlineQuery::class, |
27
|
|
|
'chosen_inline_result' => ChosenInlineResult::class |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @return mixed |
32
|
|
|
*/ |
33
|
|
|
public function getUpdateId() |
34
|
|
|
{ |
35
|
|
|
return $this->update_id; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param mixed $update_id |
40
|
|
|
*/ |
41
|
|
|
public function setUpdateId($update_id) |
42
|
|
|
{ |
43
|
|
|
$this->update_id = $update_id; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return mixed |
48
|
|
|
*/ |
49
|
|
|
public function getMessage() |
50
|
|
|
{ |
51
|
|
|
return $this->message; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param mixed $message |
56
|
|
|
*/ |
57
|
|
|
public function setMessage($message) |
58
|
|
|
{ |
59
|
|
|
$this->message = $message; |
60
|
|
|
$this->setUpdateType($message); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return bool |
65
|
|
|
*/ |
66
|
|
|
public function isEdited() |
67
|
|
|
{ |
68
|
|
|
return $this->edited; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param bool $edited |
73
|
|
|
*/ |
74
|
|
|
public function setEdited($edited) |
75
|
|
|
{ |
76
|
|
|
$this->edited = $edited; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param mixed $message |
81
|
|
|
*/ |
82
|
|
|
public function setEditedMessage($message) |
83
|
|
|
{ |
84
|
|
|
$this->setMessage($message); |
85
|
|
|
$this->setEdited(true); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return mixed |
90
|
|
|
*/ |
91
|
|
|
public function getInlineQuery() |
92
|
|
|
{ |
93
|
|
|
return $this->inline_query; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param mixed $inline_query |
98
|
|
|
*/ |
99
|
|
|
public function setInlineQuery($inline_query) |
100
|
|
|
{ |
101
|
|
|
$this->inline_query = $inline_query; |
102
|
|
|
$this->setUpdateType($inline_query); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return mixed |
107
|
|
|
*/ |
108
|
|
|
public function getChosenInlineResult() |
109
|
|
|
{ |
110
|
|
|
return $this->chosen_inline_result; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param mixed $chosen_inline_result |
115
|
|
|
*/ |
116
|
|
|
public function setChosenInlineResult($chosen_inline_result) |
117
|
|
|
{ |
118
|
|
|
$this->chosen_inline_result = $chosen_inline_result; |
119
|
|
|
$this->setUpdateType($chosen_inline_result); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
public function getUpdateType() |
126
|
|
|
{ |
127
|
|
|
return $this->updateType; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param AbstractEntity $object |
132
|
|
|
*/ |
133
|
|
|
public function setUpdateType($object) |
134
|
|
|
{ |
135
|
|
|
$this->updateType = static::ENTITY_TYPE; |
136
|
|
|
|
137
|
|
|
if ($object instanceof AbstractEntity) { |
138
|
|
|
$this->updateType = $object->getEntityType(); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getUpdateTypeEntity() |
143
|
|
|
{ |
144
|
|
|
$updateTypeEntity = null; |
145
|
|
|
|
146
|
|
|
switch ($this->getUpdateType()) { |
147
|
|
|
case Message::ENTITY_TYPE: |
148
|
|
|
$updateTypeEntity = $this->message; |
149
|
|
|
break; |
150
|
|
|
case InlineQuery::ENTITY_TYPE: |
151
|
|
|
$updateTypeEntity = $this->inline_query; |
152
|
|
|
break; |
153
|
|
|
case ChosenInlineResult::ENTITY_TYPE: |
154
|
|
|
$updateTypeEntity = $this->chosen_inline_result; |
155
|
|
|
break; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return $updateTypeEntity; |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|