forked from appwrite/sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.go
138 lines (104 loc) · 3.53 KB
/
users.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package appwrite
import (
"strings"
)
// Users service
type Users struct {
client Client
}
func NewUsers(clt Client) Users {
service := Users{
client: clt,
}
return service
}
// List get a list of all the project users. You can use the query params to
// filter your results.
func (srv *Users) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) {
path := "/users"
params := map[string]interface{}{
"search": Search,
"limit": Limit,
"offset": Offset,
"orderType": OrderType,
}
return srv.client.Call("GET", path, nil, params)
}
// Create create a new user.
func (srv *Users) Create(Email string, Password string, Name string) (map[string]interface{}, error) {
path := "/users"
params := map[string]interface{}{
"email": Email,
"password": Password,
"name": Name,
}
return srv.client.Call("POST", path, nil, params)
}
// Get get user by its unique ID.
func (srv *Users) Get(UserId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}")
params := map[string]interface{}{
}
return srv.client.Call("GET", path, nil, params)
}
// GetLogs get user activity logs list by its unique ID.
func (srv *Users) GetLogs(UserId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/logs")
params := map[string]interface{}{
}
return srv.client.Call("GET", path, nil, params)
}
// GetPrefs get user preferences by its unique ID.
func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/prefs")
params := map[string]interface{}{
}
return srv.client.Call("GET", path, nil, params)
}
// UpdatePrefs update user preferences by its unique ID. You can pass only the
// specific settings you wish to update.
func (srv *Users) UpdatePrefs(UserId string, Prefs object) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/prefs")
params := map[string]interface{}{
"prefs": Prefs,
}
return srv.client.Call("PATCH", path, nil, params)
}
// GetSessions get user sessions list by its unique ID.
func (srv *Users) GetSessions(UserId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/sessions")
params := map[string]interface{}{
}
return srv.client.Call("GET", path, nil, params)
}
// DeleteSessions delete all user sessions by its unique ID.
func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/sessions")
params := map[string]interface{}{
}
return srv.client.Call("DELETE", path, nil, params)
}
// DeleteSession delete user sessions by its unique ID.
func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/sessions/:session")
params := map[string]interface{}{
"sessionId": SessionId,
}
return srv.client.Call("DELETE", path, nil, params)
}
// UpdateStatus update user status by its unique ID.
func (srv *Users) UpdateStatus(UserId string, Status string) (map[string]interface{}, error) {
r := strings.NewReplacer("{userId}", UserId)
path := r.Replace("/users/{userId}/status")
params := map[string]interface{}{
"status": Status,
}
return srv.client.Call("PATCH", path, nil, params)
}