|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GorkaLaucirica\HipchatAPIv2Client\Model; |
|
4
|
|
|
|
|
5
|
|
|
class Webhook |
|
6
|
|
|
{ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* The unique identifier for the created entity |
|
10
|
|
|
* @var string|null |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $id = null; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* The URL to send the webhook POST to |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $url; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* The regular expression pattern to match against messages. |
|
22
|
|
|
* Only applicable for message events. |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $pattern; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* The event to listen for |
|
29
|
|
|
* Valid values: |
|
30
|
|
|
* room_message, room_notification, room_exit, room_enter, room_topic_change. |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $event; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* The label for this webhook |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $name; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* URLs to retrieve webhook information |
|
43
|
|
|
* @var array |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $links; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Webhook constructor |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct($json = null) |
|
51
|
|
|
{ |
|
52
|
|
|
if ($json) { |
|
53
|
|
|
$this->parseJson($json); |
|
54
|
|
|
} else { |
|
55
|
|
|
$this->url = ''; |
|
56
|
|
|
$this->pattern = ''; |
|
57
|
|
|
$this->event = 'room_message'; |
|
58
|
|
|
$this->name = ''; |
|
59
|
|
|
$this->links = ''; |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function parseJson($json) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->id = isset($json['id']) ? $json['id'] : null; |
|
66
|
|
|
$this->url = $json['url']; |
|
67
|
|
|
$this->pattern = $json['pattern']; |
|
68
|
|
|
$this->event = $json['event']; |
|
69
|
|
|
$this->name = $json['name']; |
|
70
|
|
|
$this->links = (isset($json['links']) && is_array($json['links'])) ? $json['links'] : array(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Serializes Webhook object |
|
76
|
|
|
* |
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
public function toJson() |
|
80
|
|
|
{ |
|
81
|
|
|
$json = array(); |
|
82
|
|
|
$json['id'] = $this->id; |
|
83
|
|
|
$json['url'] = $this->url; |
|
84
|
|
|
$json['pattern'] = $this->pattern; |
|
85
|
|
|
$json['event'] = $this->event; |
|
86
|
|
|
$json['name'] = $this->name; |
|
87
|
|
|
$json['links'] = $this->links; |
|
88
|
|
|
|
|
89
|
|
|
return $json; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Gets the unique identifier for the created entity |
|
94
|
|
|
* @return null|string |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getId() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->id; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Sets the unique identifier for the created entity |
|
103
|
|
|
* @param null|string $id |
|
104
|
|
|
* @return self |
|
105
|
|
|
*/ |
|
106
|
|
|
public function setId($id) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->id = $id; |
|
109
|
|
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Gets the event to listen for |
|
114
|
|
|
* |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
|
|
public function getEvent() { |
|
118
|
|
|
return $this->event; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Sets the event to listen for |
|
123
|
|
|
* |
|
124
|
|
|
* @param string $event |
|
125
|
|
|
* @return self |
|
126
|
|
|
*/ |
|
127
|
|
|
public function setEvent($event) { |
|
128
|
|
|
$this->event = $event; |
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Gets the URLs to retrieve webhook information |
|
134
|
|
|
* @return array |
|
135
|
|
|
*/ |
|
136
|
|
|
public function getLinks() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->links; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Sets the URLs to retrieve webhook information |
|
143
|
|
|
* @param array $links |
|
144
|
|
|
* @return self |
|
145
|
|
|
*/ |
|
146
|
|
|
public function setLinks($links) |
|
147
|
|
|
{ |
|
148
|
|
|
$this->links = $links; |
|
149
|
|
|
return $this; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Gets the label for this webhook |
|
154
|
|
|
* @return string |
|
155
|
|
|
*/ |
|
156
|
|
|
public function getName() |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->name; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* Sets the label for this webhook |
|
163
|
|
|
* @param string $name |
|
164
|
|
|
* @return self |
|
165
|
|
|
*/ |
|
166
|
|
|
public function setName($name) |
|
167
|
|
|
{ |
|
168
|
|
|
$this->name = $name; |
|
169
|
|
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Gets the regular expression pattern to match against messages. |
|
174
|
|
|
* @return string |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getPattern() |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->pattern; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Sets the regular expression pattern to match against messages. |
|
183
|
|
|
* @param string $pattern |
|
184
|
|
|
* @return self |
|
185
|
|
|
*/ |
|
186
|
|
|
public function setPattern($pattern) |
|
187
|
|
|
{ |
|
188
|
|
|
$this->pattern = $pattern; |
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Gets the URL to send the webhook POST to |
|
194
|
|
|
* @return string |
|
195
|
|
|
*/ |
|
196
|
|
|
public function getUrl() |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->url; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Sets the URL to send the webhook POST to |
|
203
|
|
|
* @param string $url |
|
204
|
|
|
* @return self |
|
205
|
|
|
*/ |
|
206
|
|
|
public function setUrl($url) |
|
207
|
|
|
{ |
|
208
|
|
|
$this->url = $url; |
|
209
|
|
|
return $this; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
} |
|
213
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..