1 | <?php |
||
14 | class OneSignalMessage |
||
15 | { |
||
16 | use AppearanceHelpers, AttachmentHelpers, ButtonHelpers, DeliveryHelpers, GroupingHelpers, SilentHelpers, Deprecated; |
||
17 | |||
18 | /** @var array */ |
||
19 | protected $payload = []; |
||
20 | |||
21 | /** |
||
22 | * @param string $body |
||
23 | * |
||
24 | * @return static |
||
25 | */ |
||
26 | public static function create($body = '') |
||
27 | { |
||
28 | return new static($body); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param string $body |
||
33 | */ |
||
34 | public function __construct($body = '') |
||
35 | { |
||
36 | $this->setBody($body); |
||
37 | } |
||
38 | 1 | ||
39 | /** |
||
40 | 1 | * Set the message body. |
|
41 | * |
||
42 | * @param mixed $value |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | 20 | public function setBody($value) |
|
47 | { |
||
48 | 20 | return $this->setParameter('contents', $this->parseValueToArray($value)); |
|
49 | 20 | } |
|
50 | |||
51 | /** |
||
52 | * Set the message subject. |
||
53 | * |
||
54 | * @param mixed $value |
||
55 | * |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function setSubject($value) |
|
62 | 1 | ||
63 | /** |
||
64 | * Set the message template_id. |
||
65 | * |
||
66 | * @param string $value |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function setTemplate($value) |
||
76 | 6 | ||
77 | /** |
||
78 | * @param mixed $value |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | protected function parseValueToArray($value) |
||
86 | 6 | ||
87 | /** |
||
88 | 6 | * Set additional data. |
|
89 | * |
||
90 | 6 | * @param string $key |
|
91 | * @param mixed $value |
||
92 | * |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setData(string $key, $value) |
||
99 | |||
100 | 6 | /** |
|
101 | * Set parameters. |
||
102 | 6 | * |
|
103 | * @param string $key |
||
104 | 6 | * @param mixed $value |
|
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function setParameter(string $key, $value) |
||
114 | 1 | ||
115 | /** |
||
116 | 1 | * Get parameters. |
|
117 | 1 | * |
|
118 | * @param string $key |
||
119 | * @param mixed $default |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function getParameter(string $key, $default = null) |
||
127 | 1 | ||
128 | /** |
||
129 | 1 | * @return array |
|
130 | 1 | */ |
|
131 | public function toArray() |
||
135 | } |
||
136 |