-
Notifications
You must be signed in to change notification settings - Fork 3
/
users.go
233 lines (186 loc) · 7.64 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package zoom
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
)
const (
UsersActionAutoCreate UsersCreateAction = "autoCreate"
UsersActionCreate UsersCreateAction = "create"
UsersActionCustCreate UsersCreateAction = "custCreate"
UsersActionSSOCreate UsersCreateAction = "ssoCreate"
UsersRecordingFileTypeCC UsersRecordingFileType = "CC"
UsersRecordingFileTypeChat UsersRecordingFileType = "CHAT"
UsersRecordingFileTypeCSV UsersRecordingFileType = "CSV"
UsersRecordingFileTypeM4A UsersRecordingFileType = "M4A"
UsersRecordingFileTypeMP4 UsersRecordingFileType = "MP4"
UsersRecordingFileTypeSummary UsersRecordingFileType = "SUMMARY"
UsersRecordingFileTypeTimeline UsersRecordingFileType = "TIMELINE"
UsersRecordingFileTypeTranscript UsersRecordingFileType = "TRANSCRIPT"
UsersRecordingStatusCompleted UsersRecordingStatus = "completed"
UsersRecordingStatusProcessing UsersRecordingStatus = "processing"
)
type UsersCreateAction string
func (u UsersCreateAction) String() string {
return string(u)
}
type UsersRecordingFileType string
type UsersRecordingStatus string
type UsersServicer interface {
AddGroupMembers(ctx context.Context, groupID string, opts *UsersAddGroupMembersOptions) (*http.Response, error)
Create(ctx context.Context, opts *UsersCreateOptions) (*UsersCreateResponse, *http.Response, error)
Delete(ctx context.Context, userID string, opts *UsersDeleteOptions) (*http.Response, error)
List(ctx context.Context, opts *UsersListOptions) (*UsersListResponse, *http.Response, error)
ListRecordings(ctx context.Context, userID string, opts *UsersListRecordingsOptions) (*UsersListRecordingsResponse, *http.Response, error)
}
type UsersService struct {
client *Client
}
var _ UsersServicer = (*UsersService)(nil)
type UsersAddGroupMembersOptions struct {
Members []*UsersAddGroupMembersOptionsMember `json:"members"`
}
type UsersAddGroupMembersOptionsMember struct {
Email string `json:"email"`
UserID string `json:"id"`
}
func (u *UsersService) AddGroupMembers(ctx context.Context, groupID string, opts *UsersAddGroupMembersOptions) (*http.Response, error) {
out := &UsersCreateResponse{}
res, err := u.client.request(ctx, http.MethodPost, "/groups/"+url.PathEscape(groupID)+"/members", nil, opts, out)
if err != nil {
return res, fmt.Errorf("making request: %w", err)
}
return res, nil
}
type UsersCreateOptions struct {
Action UsersCreateAction `json:"action"`
UserInfo *UsersCreateOptionsUserInfo `json:"user_info"`
}
type UsersCreateOptionsUserInfo struct {
DisplayName *string `json:"display_name,omitempty"`
Email string `json:"email"`
FirstName *string `json:"first_name,omitempty"`
LastName *string `json:"last_name,omitempty"`
Password *string `json:"password,omitempty"`
Type int `json:"type"`
}
type UsersCreateResponse struct {
Email string `json:"email"`
FirstName string `json:"first_name"`
ID string `json:"id"`
LastName string `json:"last_name"`
Type int `json:"type"`
}
func (u *UsersService) Create(ctx context.Context, opts *UsersCreateOptions) (*UsersCreateResponse, *http.Response, error) {
out := &UsersCreateResponse{}
res, err := u.client.request(ctx, http.MethodPost, "/users", nil, opts, out)
if err != nil {
return nil, res, fmt.Errorf("making request: %w", err)
}
return out, res, nil
}
type UsersDeleteOptions struct {
Action *string `url:"action,omitempty"`
}
func (u *UsersService) Delete(ctx context.Context, userID string, opts *UsersDeleteOptions) (*http.Response, error) {
res, err := u.client.request(ctx, http.MethodDelete, "/users/"+url.QueryEscape(userID), opts, nil, nil)
if err != nil {
return res, fmt.Errorf("making request: %w", err)
}
return res, nil
}
type UsersListOptions struct {
*PaginationOptions `url:",omitempty"`
IncludeFields *string `url:"include_fields,omitempty"`
RoleID *string `url:"role_id,omitempty"`
Status *string `url:"status,omitempty"`
}
type UsersListResponse struct {
*PaginationResponse
Users []*UsersListItem `json:"users"`
}
type UsersListItem struct {
CustomAttributes []*UsersListItemCustomAttribute `json:"custom_attributes"`
Dept string `json:"dept"`
DisplayName string `json:"display_name"`
Email string `json:"email"`
EmployeeUniqueID string `json:"employee_unique_id"`
FirstName string `json:"first_name"`
GroupIDs []string `json:"group_ids"`
ID string `json:"id"`
ImGroupIDs []string `json:"im_group_ids"`
LastClientVersion string `json:"last_client_version"`
LastLoginTime time.Time `json:"last_login_time"`
LastName string `json:"last_name"`
PlanUnitedType string `json:"plan_united_type"`
Pmi int64 `json:"pmi"`
RoleID string `json:"role_id"`
Status string `json:"status"`
Timezone string `json:"timezone"`
Type int `json:"type"`
UserCreatedAt time.Time `json:"user_created_at"`
Verified int `json:"verified"`
}
type UsersListItemCustomAttribute struct {
Key string `json:"key"`
Name string `json:"name"`
Value string `json:"value"`
}
func (u *UsersService) List(ctx context.Context, opts *UsersListOptions) (*UsersListResponse, *http.Response, error) {
out := &UsersListResponse{}
res, err := u.client.request(ctx, http.MethodGet, "/users", opts, nil, out)
if err != nil {
return nil, res, fmt.Errorf("making request: %w", err)
}
return out, res, nil
}
type UsersListRecordingsOptions struct {
*PaginationOptions `url:",omitempty"`
MeetingID *int64 `url:"meeting_id,omitempty"`
}
type UsersListRecordingsResponse struct {
*PaginationResponse
Meetings []*UsersListRecordingsMeeting `json:"meetings"`
}
type UsersListRecordingsMeeting struct {
HostID string `json:"host_id"`
ID int64 `json:"id"`
RecordingFiles []*UsersListRecordingsFile `json:"recording_files"`
StartTime time.Time `json:"start_time"`
}
type EmptyTime struct {
Time *time.Time
}
func (ct *EmptyTime) UnmarshalJSON(data []byte) error {
if string(data) == `""` {
ct.Time = nil
return nil
}
var t time.Time
if err := json.Unmarshal(data, &t); err != nil {
return err
}
ct.Time = &t
return nil
}
type UsersListRecordingsFile struct {
DownloadURL string `json:"download_url"`
FileSize int `json:"file_size"`
FileType UsersRecordingFileType `json:"file_type"`
ID string `json:"id"`
MeetingID string `json:"meeting_id"`
RecordingEnd EmptyTime `json:"recording_end,omitempty"`
RecordingStart time.Time `json:"recording_start"`
Status UsersRecordingStatus `json:"status"`
}
func (u *UsersService) ListRecordings(ctx context.Context, userID string, opts *UsersListRecordingsOptions) (*UsersListRecordingsResponse, *http.Response, error) {
out := &UsersListRecordingsResponse{}
res, err := u.client.request(ctx, http.MethodGet, "/users/"+url.QueryEscape(userID)+"/recordings", opts, nil, out)
if err != nil {
return nil, res, fmt.Errorf("making HTTP request: %w", err)
}
return out, res, nil
}