1 | <?php |
||
11 | class OneSignalMessage |
||
12 | { |
||
13 | |||
14 | use AppearanceHelpers, AttachmentHelpers, ButtonHelpers, DeliveryHelpers, GroupingHelpers, Deprecated; |
||
15 | |||
16 | /** @var array */ |
||
17 | protected $payload = []; |
||
18 | |||
19 | /** |
||
20 | * @param string $body |
||
21 | * |
||
22 | * @return static |
||
23 | */ |
||
24 | 1 | public static function create($body = '') |
|
25 | { |
||
26 | 1 | return new static($body); |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $body |
||
31 | */ |
||
32 | 21 | public function __construct($body = '') |
|
33 | { |
||
34 | 21 | $this->setBody($body); |
|
35 | 21 | } |
|
36 | |||
37 | |||
38 | /** |
||
39 | * Set the message body. |
||
40 | * |
||
41 | * @param mixed $value |
||
42 | * |
||
43 | * @return $this |
||
44 | */ |
||
45 | 21 | public function setBody($value) |
|
49 | |||
50 | |||
51 | /** |
||
52 | * Set the message subject. |
||
53 | * |
||
54 | * @param mixed $value |
||
55 | * |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function setSubject($value) |
|
62 | |||
63 | /** |
||
64 | * @param mixed $value |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | 21 | protected function parseValueToArray($value) |
|
72 | |||
73 | |||
74 | /** |
||
75 | * Set additional data. |
||
76 | * |
||
77 | * @param string $key |
||
78 | * @param mixed $value |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | 1 | public function setData(string $key, $value) |
|
83 | { |
||
84 | 1 | return $this->setParameter("data.{$key}", $value); |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * Set parameters. |
||
89 | * |
||
90 | * @param string $key |
||
91 | * @param mixed $value |
||
92 | * |
||
93 | * @return $this |
||
94 | */ |
||
95 | 21 | public function setParameter(string $key, $value) |
|
96 | { |
||
97 | 21 | Arr::set($this->payload, $key, $value); |
|
98 | |||
99 | 21 | return $this; |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * Get parameters. |
||
104 | * |
||
105 | * @param string $key |
||
106 | * @param mixed $default |
||
107 | * |
||
108 | * @return mixed |
||
109 | */ |
||
110 | 3 | public function getParameter(string $key, $default = null) |
|
114 | |||
115 | /** |
||
116 | * @return array |
||
117 | */ |
||
118 | 21 | public function toArray() |
|
122 | } |
||
123 |