1 | <?php |
||
7 | class PushbulletMessage |
||
8 | { |
||
9 | const TYPE_NOTE = 'note'; |
||
10 | const TYPE_LINK = 'link'; |
||
11 | |||
12 | /** |
||
13 | * Type of message (currently: note or link). |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | public $type = 'note'; |
||
18 | |||
19 | /** @var \NotificationChannels\Pushbullet\Targets\Targetable */ |
||
20 | protected $target; |
||
21 | |||
22 | /** |
||
23 | * Notification title. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | public $title; |
||
28 | |||
29 | /** |
||
30 | * Notification message. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | public $message; |
||
35 | |||
36 | /** |
||
37 | * Url if notification is of link type. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public $url; |
||
42 | |||
43 | /** |
||
44 | * Push notification to all devices. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | public $toAll = false; |
||
49 | |||
50 | /** |
||
51 | * @param string $message |
||
52 | * |
||
53 | * @return static |
||
54 | */ |
||
55 | public static function create($message) |
||
59 | |||
60 | /** |
||
61 | * @param string $message |
||
62 | */ |
||
63 | public function __construct($message) |
||
67 | |||
68 | /** |
||
69 | * @param \NotificationChannels\Pushbullet\Targets\Targetable $targetable |
||
70 | * |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function target(Targetable $targetable) |
||
79 | |||
80 | /** |
||
81 | * Specify that notification is of `note` type. |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function note() |
||
91 | |||
92 | /** |
||
93 | * Specify that notification is of `link` type. |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function link() |
||
103 | |||
104 | /** |
||
105 | * Set notification title. |
||
106 | * |
||
107 | * @param string $title |
||
108 | * |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function title($title) |
||
117 | |||
118 | /** |
||
119 | * Set notification message. |
||
120 | * |
||
121 | * @param string $message |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function message($message) |
||
131 | |||
132 | /** |
||
133 | * Set notification url (if notification is of `link` type). |
||
134 | * |
||
135 | * @param string $url |
||
136 | * |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function url($url) |
||
145 | |||
146 | /** |
||
147 | * @param mixed $toAll |
||
148 | * |
||
149 | * @return PushbulletMessage |
||
150 | */ |
||
151 | public function toAll($toAll = true) |
||
157 | |||
158 | /** |
||
159 | * @return mixed |
||
160 | */ |
||
161 | public function getToAll() |
||
165 | |||
166 | /** |
||
167 | * Get array representation of message for Pushbullet client. |
||
168 | * |
||
169 | * @return array |
||
170 | */ |
||
171 | public function toArray() |
||
189 | } |
||
190 |