-
Notifications
You must be signed in to change notification settings - Fork 1
/
users.go
252 lines (211 loc) · 6.69 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
package monday
// UsersService handles all the user related methods of the Monday API.
// Every user is a part of an account (i.e an organization) and could be a member or a guest in that account.
type UsersService service
// ListWithArgs returns a query that gets one or multiple users.
//
// DOCS: https://monday.com/developers/v2#queries-section-users
func (*UsersService) List(usersFields []UsersField, usersArgs ...UsersArgument) Query {
if len(usersFields) == 0 {
return Query{
name: "users",
fields: []field{
UsersIDField().field,
},
}
}
var fields []field
for _, uf := range usersFields {
fields = append(fields, uf.field)
}
var args []argument
for _, ua := range usersArgs {
args = append(args, ua.arg)
}
return Query{
name: "users",
fields: fields,
args: args,
}
}
// Me return a query that gets the user details of the user whose API key is being used if the API is the personal API key.
// This is the fastest way to query for the user details (same as users query) of the connected user.
//
// https://monday.com/developers/v2#queries-section-me
func (*UsersService) Me(usersFields []UsersField, usersArgs ...UsersArgument) Query {
me := Users.List(usersFields, usersArgs...)
me.name = "me"
return me
}
// The user's graphql field(s).
type UsersField struct {
field field
}
var (
usersBirthdayField = UsersField{field{"birthday", nil}}
usersCountryCodeField = UsersField{field{"country_code", nil}}
usersCreatedAtField = UsersField{field{"created_at", nil}}
usersEmailField = UsersField{field{"email", nil}}
usersEnabledField = UsersField{field{"enabled", nil}}
usersIDField = UsersField{field{"id", nil}}
usersIsGuestField = UsersField{field{"is_guest", nil}}
usersIsPendingField = UsersField{field{"is_pending", nil}}
usersJoinDateField = UsersField{field{"join_date", nil}}
usersLocationField = UsersField{field{"location", nil}}
usersMobilePhoneField = UsersField{field{"mobile_phone", nil}}
usersNameField = UsersField{field{"name", nil}}
usersPhoneField = UsersField{field{"phone", nil}}
usersPhotoOriginalField = UsersField{field{"photo_original", nil}}
usersPhotoSmallField = UsersField{field{"photo_small", nil}}
usersPhotoThumbField = UsersField{field{"photo_thumb", nil}}
usersPhotoThumbSmallField = UsersField{field{"photo_thumb_small", nil}}
usersPhotoTinyField = UsersField{field{"photo_tiny", nil}}
usersTimeZoneIdentifierField = UsersField{field{"time_zone_identifier", nil}}
usersTitleField = UsersField{field{"title", nil}}
usersURLField = UsersField{field{"url", nil}}
usersUTCHoursDifference = UsersField{field{"utc_hours_diff", nil}}
)
// The user's account.
func NewUsersAccountField(accountFields []AccountField) UsersField {
account := Account.Get(accountFields)
return UsersField{field{"account", &account}}
}
// The user's birthday.
func UsersBirthDayField() UsersField {
return usersBirthdayField
}
// The user's country code.
func UsersCountryCodeField() UsersField {
return usersCountryCodeField
}
// The user's creation date.
func UsersCreatedAtField() UsersField {
return usersCreatedAtField
}
// The user's email.
func UsersEmailField() UsersField {
return usersEmailField
}
// Is the user enabled or not.
func UsersEnabledField() UsersField {
return usersEnabledField
}
// The user's unique identifier.
func UsersIDField() UsersField {
return usersIDField
}
// Is the user a guest or not.
func UsersIsGuestField() UsersField {
return usersIsGuestField
}
// Is the user a pending user or not.
func UsersIsPendingField() UsersField {
return usersIsPendingField
}
// The date the user joined the account.
func UsersJoinDateField() UsersField {
return usersJoinDateField
}
// The user's location.
func UsersLocationField() UsersField {
return usersLocationField
}
// The user's mobile phone number.
func UsersMobilePhoneField() UsersField {
return usersMobilePhoneField
}
// The user's name.
func UsersNameField() UsersField {
return usersNameField
}
// The user's phone number.
func UsersPhoneField() UsersField {
return usersPhoneField
}
// The user's photo in the original size.
func UsersPhotoOriginalField() UsersField {
return usersPhotoOriginalField
}
// The user's photo in small size (150x150).
func UsersPhotoSmallField() UsersField {
return usersPhotoSmallField
}
// The user's photo in thumbnail size (100x100).
func UsersPhotoThumbField() UsersField {
return usersPhotoThumbField
}
// The user's photo in small thumbnail size (50x50).
func UsersPhotoThumbSmallField() UsersField {
return usersPhotoThumbSmallField
}
// The user's photo in tiny size (30x30).
func UsersPhotoTinyField() UsersField {
return usersPhotoTinyField
}
// The teams the user is a member in.
func NewUsersTeamsField(teamsFields []TeamsField, teamsArgs []TeamsArgument) UsersField {
teams := Teams.List(teamsFields, teamsArgs...)
return UsersField{field{"teams", &teams}}
}
// The user's time zone identifier.
func UsersTimeZoneIdentifierField() UsersField {
return usersTimeZoneIdentifierField
}
// The user's title.
func UsersTitleField() UsersField {
return usersTitleField
}
// The user's profile url.
func UsersURLField() UsersField {
return usersURLField
}
// The user’s utc hours difference.
func UsersUTCHoursDifferenceField() UsersField {
return usersUTCHoursDifference
}
// The user's graphql argument(s).
type UsersArgument struct {
arg argument
}
// The kind to search users by.
type UsersKind struct {
kind string
}
var (
allUsersKind = UsersKind{"all"}
nonGuestsUsersKind = UsersKind{"non_guests"}
guestsUsersKind = UsersKind{"guests"}
nonPendingKind = UsersKind{"non_pending"}
)
// All users in account.
func AllUsersKind() UsersKind {
return allUsersKind
}
// Only company members.
func NonGuestsUsersKind() UsersKind {
return nonGuestsUsersKind
}
// Only guests.
func GuestsUsersKind() UsersKind {
return guestsUsersKind
}
// All non pending members.
func NonPendingUsersKind() UsersKind {
return nonPendingKind
}
// A list of users unique identifiers.
func NewUsersIDsArgument(ids []int) UsersArgument {
return UsersArgument{argument{"ids", ids}}
}
// The kind to search users by (all / non_guests / guests / non_pending).
func NewUsersKindArgument(kind UsersKind) UsersArgument {
return UsersArgument{argument{"kind", kind}}
}
// Get the recently created users at the top of the list.
func NewUsersNewestFirstArgument(first bool) UsersArgument {
return UsersArgument{argument{"newest_first", first}}
}
// Number of users to get.
func NewUsersLimitArgument(value int) UsersArgument {
return UsersArgument{argument{"limit", value}}
}