1 | <?php |
||
8 | class OneSignalMessage |
||
9 | { |
||
10 | use OneSignalHelpers; |
||
11 | /** @var string */ |
||
12 | protected $body; |
||
13 | |||
14 | /** @var string */ |
||
15 | protected $subject; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected $url; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $icon; |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $data = []; |
||
25 | |||
26 | /** @var array */ |
||
27 | protected $buttons = []; |
||
28 | |||
29 | /** @var array */ |
||
30 | protected $webButtons = []; |
||
31 | |||
32 | /** @var array */ |
||
33 | protected $extraParameters = []; |
||
34 | |||
35 | /** |
||
36 | * @param string $body |
||
37 | * |
||
38 | * @return static |
||
39 | */ |
||
40 | 1 | public static function create($body = '') |
|
44 | |||
45 | /** |
||
46 | * @param string $body |
||
47 | */ |
||
48 | 20 | public function __construct($body = '') |
|
52 | |||
53 | /** |
||
54 | * Set the message body. |
||
55 | * |
||
56 | * @param string $value |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | 1 | public function body($value) |
|
66 | |||
67 | /** |
||
68 | * Set the message icon. |
||
69 | * |
||
70 | * @param string $value |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | 6 | public function icon($value) |
|
80 | |||
81 | /** |
||
82 | * Set the message subject. |
||
83 | * |
||
84 | * @param string $value |
||
85 | * |
||
86 | * @return $this |
||
87 | */ |
||
88 | 6 | public function subject($value) |
|
94 | |||
95 | /** |
||
96 | * Set the message url. |
||
97 | * |
||
98 | * @param string $value |
||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | 6 | public function url($value) |
|
108 | |||
109 | |||
110 | /** |
||
111 | * Set additional data. |
||
112 | * |
||
113 | * @param string $key |
||
114 | * @param string $value |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 1 | public function setData($key, $value) |
|
124 | |||
125 | /** |
||
126 | * Set additional parameters. |
||
127 | * |
||
128 | * @param string $key |
||
129 | * @param string $value |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | 5 | public function setParameter($key, $value) |
|
139 | |||
140 | /** |
||
141 | * Add a web button to the message. |
||
142 | * |
||
143 | * @param OneSignalWebButton $button |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | 1 | public function webButton(OneSignalWebButton $button) |
|
153 | |||
154 | /** |
||
155 | * Add a native button to the message. |
||
156 | * |
||
157 | * @param OneSignalButton $button |
||
158 | * |
||
159 | * @return $this |
||
160 | */ |
||
161 | 1 | public function button(OneSignalButton $button) |
|
167 | |||
168 | /** |
||
169 | * @return array |
||
170 | */ |
||
171 | 20 | public function toArray() |
|
195 | |||
196 | /** |
||
197 | * @return array |
||
198 | */ |
||
199 | 20 | protected function subjectToArray() |
|
207 | } |
||
208 |