1 | <?php |
||
9 | class PushbulletMessage |
||
10 | { |
||
11 | private const TYPE_NOTE = 'note'; |
||
12 | private const TYPE_LINK = 'link'; |
||
13 | |||
14 | /** |
||
15 | * Type of message (currently: note or link). |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $type = 'note'; |
||
20 | |||
21 | /** @var \NotificationChannels\Pushbullet\Targets\Targetable */ |
||
22 | protected $target; |
||
23 | |||
24 | /** |
||
25 | * Notification title. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | public $title; |
||
30 | |||
31 | /** |
||
32 | * Notification message. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | public $message; |
||
37 | |||
38 | /** |
||
39 | * Url if notification is of link type. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | public $url; |
||
44 | |||
45 | /** |
||
46 | * @param string $message |
||
47 | * |
||
48 | * @return static |
||
49 | */ |
||
50 | 1 | public static function create($message): self |
|
54 | |||
55 | /** |
||
56 | * @param string $message |
||
57 | */ |
||
58 | 9 | public function __construct($message) |
|
62 | |||
63 | /** |
||
64 | * @param \NotificationChannels\Pushbullet\Targets\Targetable $targetable |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | 1 | public function target(Targetable $targetable): self |
|
74 | |||
75 | /** |
||
76 | * Specify that notification is of `note` type. |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | 1 | public function note(): self |
|
86 | |||
87 | /** |
||
88 | * Specify that notification is of `link` type. |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 2 | public function link(): self |
|
98 | |||
99 | /** |
||
100 | * Set notification title. |
||
101 | * |
||
102 | * @param string $title |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | 2 | public function title($title): self |
|
112 | |||
113 | /** |
||
114 | * Set notification message. |
||
115 | * |
||
116 | * @param string $message |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | 1 | public function message($message): self |
|
126 | |||
127 | /** |
||
128 | * Set notification url (if notification is of `link` type). |
||
129 | * |
||
130 | * @param string $url |
||
131 | * |
||
132 | * @return $this |
||
133 | */ |
||
134 | 1 | public function url($url): self |
|
140 | |||
141 | /** |
||
142 | * Get array representation of message for Pushbullet client. |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | 1 | public function toArray(): array |
|
160 | |||
161 | /** |
||
162 | * @return bool |
||
163 | */ |
||
164 | 1 | private function isLink(): bool |
|
168 | |||
169 | /** |
||
170 | * @return array |
||
171 | */ |
||
172 | 1 | private function getUrlParameter(): array |
|
176 | } |
||
177 |