-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupsub.go
60 lines (49 loc) · 1.7 KB
/
groupsub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package calendarmod
type GroupSubResult struct {
successUserList []string
failUserList []string
}
// Get SuccessUserList
func (gr GroupSubResult) SuccessUserList() []string {
return gr.successUserList
}
// Get FailUserList
func (gr GroupSubResult) FailUserList() []string {
return gr.failUserList
}
// Subscribe group of user to group of calendar
//
// @param {string[]} userlist - list of valid Google emails of targeted users, in email format
// @param {string} calendarID - id of the calendar for the users to subscribe
//
// @return {GroupSubResult} - result of group calendar subscription, with a list of success users and a list of failed user cases
func (c *CalendarClient) SubscribeGroupToCalendar(calendarID string, userlist []string) GroupSubResult {
var gr GroupSubResult
for _, u := range userlist {
res := c.SubscribeUserToCalendar(u, calendarID)
if res {
gr.successUserList = append(gr.successUserList, u)
} else {
gr.failUserList = append(gr.failUserList, u)
}
}
return gr
}
// UNsubscribe group of user from calendar
//
// @param {string[]} userlist - list of valid Google emails of targeted users, in email format
// @param {string} calendarID - id of the calendar for the users to subscribe
//
// @return {GroupSubResult} - result of group calendar unsubscription, with a list of success users and a list of failed user cases
func (c *CalendarClient) UnsubscribeGroupFromCalendar(calendarID string, userlist []string) GroupSubResult {
var gr GroupSubResult
for _, u := range userlist {
res := c.UnsubscribeUserFromCalendar(u, calendarID)
if res {
gr.successUserList = append(gr.successUserList, u)
} else {
gr.failUserList = append(gr.failUserList, u)
}
}
return gr
}