1
+ <?php
2
+ namespace JiraRestApi \Issue ;
3
+
4
+ class Notify implements \JsonSerializable
5
+ {
6
+ /** @var string */
7
+ public $ subject ;
8
+
9
+ /** @var string */
10
+ public $ textBody ;
11
+
12
+ /** @var */
13
+ public $ htmlBody ;
14
+
15
+ /** @var array|null */
16
+ public $ to ;
17
+
18
+ /** @var array|null */
19
+ public $ groups ;
20
+
21
+ public function __construct ()
22
+ {
23
+ $ this ->to = [];
24
+ $ this ->to ['users ' ] = [];
25
+ $ this ->groups = [];
26
+
27
+ $ this ->to ['reporter ' ] = false ;
28
+ $ this ->to ['assignee ' ] = false ;
29
+ $ this ->to ['watchers ' ] = true ;
30
+ $ this ->to ['voters ' ] = true ;
31
+ }
32
+
33
+ public function setSubject ($ subject ) {
34
+ $ this ->subject = $ subject ;
35
+ return $ this ;
36
+ }
37
+
38
+ public function setTextBody ($ textBody ) {
39
+ $ this ->textBody = $ textBody ;
40
+ return $ this ;
41
+ }
42
+
43
+ public function setHtmlBody ($ htmlBody ) {
44
+ $ this ->htmlBody = $ htmlBody ;
45
+ return $ this ;
46
+ }
47
+
48
+ public function sendToReporter ($ bool )
49
+ {
50
+ $ this ->to ['reporter ' ] = $ bool ;
51
+ return $ this ;
52
+ }
53
+
54
+ public function sendToAssignee ($ bool )
55
+ {
56
+ $ this ->to ['assignee ' ] = $ bool ;
57
+ return $ this ;
58
+ }
59
+
60
+ public function sendToWatchers ($ bool )
61
+ {
62
+ $ this ->to ['watchers ' ] = $ bool ;
63
+ return $ this ;
64
+ }
65
+
66
+ public function sendToVoters ($ bool )
67
+ {
68
+ $ this ->to ['voters ' ] = $ bool ;
69
+ return $ this ;
70
+ }
71
+
72
+ public function sendToUser ($ name , $ active )
73
+ {
74
+ $ user ['name ' ] = $ name ;
75
+ $ user ['active ' ] = $ active ;
76
+
77
+ array_push ($ this ->to ['users ' ], $ user );
78
+
79
+ return $ this ;
80
+ }
81
+
82
+ public function sendToGroup ($ groupName )
83
+ {
84
+ $ group ['name ' ] = $ groupName ;
85
+ // FIXME "self": "http://www.example.com/jira/rest/api/2/group?groupname=notification-group"
86
+ //$group['self'] = $active;
87
+
88
+ array_push ($ this ->groups , $ group );
89
+
90
+ return $ this ;
91
+ }
92
+
93
+ public function jsonSerialize ()
94
+ {
95
+ return array_filter (get_object_vars ($ this ));
96
+ }
97
+ }
0 commit comments