-
Notifications
You must be signed in to change notification settings - Fork 1
/
querylogin.go
107 lines (80 loc) · 2.74 KB
/
querylogin.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package go_ts3
// queryloginadd `manage_scope, write_scope`
type QueryloginAddResponse struct {
ClientDbId int `json:"cldbid,string"`
ClientLoginName string `json:"client_login_name"`
ServerId int `json:"sid,string"`
ClientLoginPassword string `json:"client_login_password"`
}
type queryloginAddRequest struct {
ClientLoginName string `schema:"client_login_name,required"`
ClientDbId int `schema:"cldbid,omitempty"`
}
func (c *TeamspeakHttpClient) QueryloginAddGlobal(clientLoginName string) (*QueryloginAddResponse, error) {
var logins []QueryloginAddResponse
oldServerId := c.serverID
c.SetServerID(0)
err := c.requestWithParams("queryloginadd", queryloginAddRequest{
ClientLoginName: clientLoginName,
}, &logins)
c.SetServerID(oldServerId)
if err != nil {
return nil, err
}
return &logins[0], nil
}
func (c *TeamspeakHttpClient) QueryloginAddCurrent(clientLoginName string, clientDbId int) (*QueryloginAddResponse, error) {
var logins []QueryloginAddResponse
err := c.requestWithParams("queryloginadd", queryloginAddRequest{
ClientLoginName: clientLoginName,
ClientDbId: clientDbId,
}, &logins)
if err != nil {
return nil, err
}
return &logins[0], nil
}
// querylogindel `manage_scope, write_scope`
type queryloginDeleteRequest struct {
ClientDbId int `schema:"cldbid,required"`
}
func (c *TeamspeakHttpClient) QueryloginDelete(clientDbId int) error {
return c.requestWithParams("querylogindel", queryloginDeleteRequest{ClientDbId: clientDbId}, nil)
}
func (c *TeamspeakHttpClient) QueryloginDeleteGlobal(clientDbId int) error {
oldServerId := c.serverID
c.SetServerID(0)
err := c.requestWithParams("querylogindel", queryloginDeleteRequest{ClientDbId: clientDbId}, nil)
c.SetServerID(oldServerId)
return err
}
// queryloginlist `manage_scope, write_scope, read_scope`
type Querylogin struct {
ClientDbId int `json:"cldbid,string"`
ClientLoginName string `json:"client_login_name"`
ServerId int `json:"sid,string"`
}
type QueryloginListRequest struct {
Pattern string `schema:"pattern,omitempty"`
Start int `schema:"start,omitempty"`
Duration int `schema:"duration,omitempty"`
}
func (c *TeamspeakHttpClient) QueryloginListGlobal(request QueryloginListRequest) (*[]Querylogin, error) {
var logins []Querylogin
oldServerId := c.serverID
c.SetServerID(0)
err := c.requestWithParams("queryloginlist", request, &logins)
if err != nil {
return nil, err
}
c.SetServerID(oldServerId)
return &logins, nil
}
func (c *TeamspeakHttpClient) QueryloginList(request QueryloginListRequest) (*[]Querylogin, error) {
var logins []Querylogin
err := c.requestWithParams("queryloginlist", request, &logins)
if err != nil {
return nil, err
}
return &logins, nil
}