-
Notifications
You must be signed in to change notification settings - Fork 0
/
Groups.go
36 lines (31 loc) · 952 Bytes
/
Groups.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
package msgraph
import (
"strings"
)
// Groups represents multiple Group-instances and provides funcs to work with them.
type Groups []Group
func (g Groups) String() string {
var groups = make([]string, len(g))
for i, calendar := range g {
groups[i] = calendar.String()
}
return "Groups(" + strings.Join(groups, " | ") + ")"
}
// setGraphClient sets the GraphClient within that particular instance. Hence it's directly created by GraphClient
func (g Groups) setGraphClient(gC *GraphClient) Groups {
for i := range g {
g[i].setGraphClient(gC)
}
return g
}
// GetByDisplayName returns the Group obj of that array whose DisplayName matches
// the given name. Returns an ErrFindGroup if no group exists that matches the given
// DisplayName.
func (g Groups) GetByDisplayName(displayName string) (Group, error) {
for _, group := range g {
if group.DisplayName == displayName {
return group, nil
}
}
return Group{}, ErrFindGroup
}