-
Notifications
You must be signed in to change notification settings - Fork 1
/
custom.go
88 lines (74 loc) · 1.88 KB
/
custom.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package go_ts3
// custominfo `manage_scope, write_scope, read_scope`
type customInfoRequest struct {
ClientDbId int `schema:"cldbid"`
}
type CustomInfo struct {
Ident string `json:"ident"`
Value string `json:"value"`
}
func (c *TeamspeakHttpClient) CustomInfo(clientDbId int) (*[]CustomInfo, error) {
var customs []CustomInfo
err := c.requestWithParams("custominfo", customInfoRequest{ClientDbId: clientDbId}, &customs)
if err != nil {
return nil, err
}
return &customs, nil
}
// customsearch `manage_scope, write_scope, read_scope`
type customSearchRequest struct {
Ident string `schema:"ident"`
Pattern string `schema:"pattern"`
}
type CustomSearchResponse struct {
ClientDbId int `json:"cldbid,string"`
Ident string `json:"ident"`
Value string `json:"value"`
}
func (c *TeamspeakHttpClient) CustomSearch(ident, pattern string) (*[]CustomSearchResponse, error) {
var responses []CustomSearchResponse
err := c.requestWithParams(
"",
customSearchRequest{
Ident: ident,
Pattern: pattern,
},
&responses,
)
if err != nil {
return nil, err
}
return &responses, nil
}
// customset `manage_scope, write_scope`
type customSetRequest struct {
ClientDbId int `schema:"cldbid"`
Ident string `schema:"ident"`
Value string `schema:"value"`
}
func (c *TeamspeakHttpClient) CustomSet(clientDbId int, ident, value string) error {
return c.requestWithParams(
"customset",
customSetRequest{
ClientDbId: clientDbId,
Ident: ident,
Value: value,
},
nil,
)
}
// customdelete `manage_scope, write_scope`
type customDeleteRequest struct {
ClientDbId int `schema:"cldbid"`
Ident string `schema:"ident"`
}
func (c *TeamspeakHttpClient) CustomDelete(clientDbId int, ident string) error {
return c.requestWithParams(
"customdelete",
customDeleteRequest{
ClientDbId: clientDbId,
Ident: ident,
},
nil,
)
}