1 | <?php |
||
8 | class PushoverMessage |
||
9 | { |
||
10 | /** |
||
11 | * The text content of the message. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | public $content; |
||
16 | |||
17 | /** |
||
18 | * The (optional) title of the message. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | public $title; |
||
23 | |||
24 | /** |
||
25 | * The (optional) timestamp of the message. |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | public $timestamp; |
||
30 | |||
31 | /** |
||
32 | * The (optional) priority of the message. |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | public $priority; |
||
37 | |||
38 | /** |
||
39 | * The (optional) timeout between retries when sending a message |
||
40 | * with an emergency priority. The timeout is in seconds. |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | public $retry; |
||
45 | |||
46 | /** |
||
47 | * The (optional) expire time of a message with an emergency priority. |
||
48 | * The expire time is in seconds. |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | public $expire; |
||
53 | |||
54 | /** |
||
55 | * The (optional) supplementary url of the message. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | public $url; |
||
60 | |||
61 | /** |
||
62 | * The (optional) supplementary url title of the message. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | public $urlTitle; |
||
67 | |||
68 | /** |
||
69 | * The (optional) sound of the message. |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | public $sound; |
||
74 | |||
75 | /** |
||
76 | * Set Message Type to HTML. |
||
77 | * |
||
78 | * @var int |
||
79 | */ |
||
80 | public $html; |
||
81 | |||
82 | /** |
||
83 | * Message priorities. |
||
84 | */ |
||
85 | const LOWEST_PRIORITY = -2; |
||
86 | const LOW_PRIORITY = -1; |
||
87 | const NORMAL_PRIORITY = 0; |
||
88 | const HIGH_PRIORITY = 1; |
||
89 | const EMERGENCY_PRIORITY = 2; |
||
90 | |||
91 | /** |
||
92 | * @param string $content |
||
93 | * |
||
94 | * @return static |
||
95 | */ |
||
96 | 2 | public static function create($content = '') |
|
100 | |||
101 | /** |
||
102 | * @param string $content |
||
103 | */ |
||
104 | 20 | public function __construct($content = '') |
|
108 | |||
109 | /** |
||
110 | * Set the content of the Pushover message. |
||
111 | * |
||
112 | * @param string $content |
||
113 | * @return $this |
||
114 | */ |
||
115 | 1 | public function content($content) |
|
121 | |||
122 | /** |
||
123 | * Set the title of the Pushover message. |
||
124 | * |
||
125 | * @param string $title |
||
126 | * @return $this |
||
127 | */ |
||
128 | 3 | public function title($title) |
|
134 | |||
135 | /** |
||
136 | * Set the time of the Pushover message. |
||
137 | * |
||
138 | * @param Carbon|int $time |
||
139 | * @return $this |
||
140 | */ |
||
141 | 4 | public function time($time) |
|
151 | |||
152 | /** |
||
153 | * Set a supplementary url for the Pushover message. |
||
154 | * |
||
155 | * @param string $url |
||
156 | * @param string $title |
||
157 | * @return $this |
||
158 | */ |
||
159 | 4 | public function url($url, $title = null) |
|
166 | |||
167 | /** |
||
168 | * Set the sound of the Pushover message. |
||
169 | * |
||
170 | * @param string $sound |
||
171 | * @return $this |
||
172 | */ |
||
173 | 3 | public function sound($sound) |
|
179 | |||
180 | /** |
||
181 | * Set the priority of the Pushover message. |
||
182 | * Retry and expire are mandatory when setting the priority to emergency. |
||
183 | * |
||
184 | * @param int $priority |
||
185 | * @param int $retryTimeout |
||
186 | * @param int $expireAfter |
||
187 | * @return $this |
||
188 | */ |
||
189 | 10 | public function priority($priority, $retryTimeout = null, $expireAfter = null) |
|
199 | |||
200 | /** |
||
201 | * Set the priority of the Pushover message to the lowest priority. |
||
202 | * |
||
203 | * @return $this |
||
204 | */ |
||
205 | 1 | public function lowestPriority() |
|
209 | |||
210 | /** |
||
211 | * Set the priority of the Pushover message to low. |
||
212 | * |
||
213 | * @return $this |
||
214 | */ |
||
215 | 1 | public function lowPriority() |
|
219 | |||
220 | /** |
||
221 | * Set the priority of the Pushover message to normal. |
||
222 | * |
||
223 | * @return $this |
||
224 | */ |
||
225 | 1 | public function normalPriority() |
|
229 | |||
230 | /** |
||
231 | * Set the priority of the Pushover message to high. |
||
232 | * |
||
233 | * @return $this |
||
234 | */ |
||
235 | 1 | public function highPriority() |
|
239 | |||
240 | /** |
||
241 | * Set the text type of the Pushover message to HTML. |
||
242 | * |
||
243 | * @return this |
||
244 | */ |
||
245 | public function setHtml() |
||
251 | |||
252 | /** |
||
253 | * Set the priority of the Pushover message to emergency. |
||
254 | * Retry and expire are mandatory when setting the priority to emergency. |
||
255 | * |
||
256 | * @param int $retryTimeout |
||
257 | * @param int $expireAfter |
||
258 | * @return $this |
||
259 | */ |
||
260 | 3 | public function emergencyPriority($retryTimeout, $expireAfter) |
|
264 | |||
265 | /** |
||
266 | * Array representation of Pushover Message. |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | 2 | public function toArray() |
|
285 | |||
286 | /** |
||
287 | * Ensure an emergency message has an retry and expiry time. |
||
288 | * |
||
289 | * @param int $priority |
||
290 | * @param int $retry |
||
291 | * @param int $expire |
||
292 | * @throws EmergencyNotificationRequiresRetryAndExpire |
||
293 | */ |
||
294 | 10 | protected function noEmergencyWithoutRetryOrExpire($priority, $retry, $expire) |
|
300 | } |
||
301 |