1 | <?php |
||
7 | class OneSignalMessage |
||
8 | { |
||
9 | /** @var string */ |
||
10 | protected $body; |
||
11 | |||
12 | /** @var string */ |
||
13 | protected $subject; |
||
14 | |||
15 | /** @var string */ |
||
16 | protected $url; |
||
17 | |||
18 | /** @var string */ |
||
19 | protected $icon; |
||
20 | |||
21 | /** @var array */ |
||
22 | protected $data = []; |
||
23 | |||
24 | /** @var array */ |
||
25 | protected $buttons = []; |
||
26 | |||
27 | /** @var array */ |
||
28 | protected $webButtons = []; |
||
29 | |||
30 | /** @var array */ |
||
31 | protected $extraParameters = []; |
||
32 | |||
33 | /** |
||
34 | * @param string $body |
||
35 | * |
||
36 | * @return static |
||
37 | */ |
||
38 | 1 | public static function create($body = '') |
|
42 | |||
43 | /** |
||
44 | * @param string $body |
||
45 | */ |
||
46 | 17 | public function __construct($body = '') |
|
50 | |||
51 | /** |
||
52 | * Set the message body. |
||
53 | * |
||
54 | * @param string $value |
||
55 | * |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function body($value) |
|
64 | |||
65 | /** |
||
66 | * Set the message icon. |
||
67 | * |
||
68 | * @param string $value |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | 6 | public function icon($value) |
|
78 | |||
79 | /** |
||
80 | * Set the message subject. |
||
81 | * |
||
82 | * @param string $value |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | 6 | public function subject($value) |
|
92 | |||
93 | /** |
||
94 | * Set the message url. |
||
95 | * |
||
96 | * @param string $value |
||
97 | * |
||
98 | * @return $this |
||
99 | */ |
||
100 | 6 | public function url($value) |
|
106 | |||
107 | /** |
||
108 | * Set additional data. |
||
109 | * |
||
110 | * @param string $key |
||
111 | * @param string $value |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | 1 | public function setData($key, $value) |
|
121 | |||
122 | /** |
||
123 | * Set additional parameters. |
||
124 | * |
||
125 | * @param string $key |
||
126 | * @param string $value |
||
127 | * |
||
128 | * @return $this |
||
129 | */ |
||
130 | 1 | public function setParameter($key, $value) |
|
131 | { |
||
132 | 1 | $this->extraParameters[$key] = $value; |
|
133 | |||
134 | 1 | return $this; |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * Add a web button to the message. |
||
139 | * |
||
140 | * @param OneSignalWebButton $button |
||
141 | * |
||
142 | * @return $this |
||
143 | */ |
||
144 | 1 | public function webButton(OneSignalWebButton $button) |
|
150 | |||
151 | /** |
||
152 | * Add a native button to the message. |
||
153 | * |
||
154 | * @param OneSignalButton $button |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | 1 | public function button(OneSignalButton $button) |
|
164 | |||
165 | /** |
||
166 | * Set an image to all possible attachment variables. |
||
167 | * @param string $imageUrl |
||
168 | * |
||
169 | * @return $this |
||
170 | */ |
||
171 | 1 | public function setImageAttachments($imageUrl) |
|
180 | |||
181 | /** |
||
182 | * @return array |
||
183 | */ |
||
184 | 17 | public function toArray() |
|
208 | |||
209 | 17 | protected function subjectToArray() |
|
217 | } |
||
218 |