-
Notifications
You must be signed in to change notification settings - Fork 1
/
roles.go
41 lines (31 loc) · 887 Bytes
/
roles.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
package guildedgo
import (
"log"
)
type RoleService interface {
AddMemberToGroup(groupId string, userId string)
RemoveMemberFromGroup(groupId string, userId string)
}
type roleEndpoints struct{}
func (e *roleEndpoints) GroupMember(groupId, userId string) string {
return guildedApi + "/groups/" + groupId + "/members/" + userId
}
type roleService struct {
client *Client
endpoints *roleEndpoints
}
var _ RoleService = &roleService{}
func (rs *roleService) AddMemberToGroup(groupId string, userId string) {
endpoint := rs.endpoints.GroupMember(groupId, userId)
_, err := rs.client.PutRequest(endpoint, nil)
if err != nil {
log.Fatalln(err)
}
}
func (rs *roleService) RemoveMemberFromGroup(groupId string, userId string) {
endpoint := rs.endpoints.GroupMember(groupId, userId)
_, err := rs.client.DeleteRequest(endpoint)
if err != nil {
log.Fatalln(err)
}
}