appwrite 4.1.0 → 7.0.0.pre.RC1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +32 -11
  3. data/lib/appwrite/id.rb +11 -0
  4. data/lib/appwrite/input_file.rb +33 -0
  5. data/lib/appwrite/models/account.rb +82 -0
  6. data/lib/appwrite/models/algo_argon2.rb +37 -0
  7. data/lib/appwrite/models/algo_bcrypt.rb +22 -0
  8. data/lib/appwrite/models/algo_md5.rb +22 -0
  9. data/lib/appwrite/models/algo_phpass.rb +22 -0
  10. data/lib/appwrite/models/algo_scrypt.rb +42 -0
  11. data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
  12. data/lib/appwrite/models/algo_sha.rb +22 -0
  13. data/lib/appwrite/models/attribute_datetime.rb +57 -0
  14. data/lib/appwrite/models/bucket.rb +25 -25
  15. data/lib/appwrite/models/collection.rb +25 -15
  16. data/lib/appwrite/models/database.rb +42 -0
  17. data/lib/appwrite/models/database_list.rb +32 -0
  18. data/lib/appwrite/models/deployment.rb +10 -5
  19. data/lib/appwrite/models/document.rb +15 -10
  20. data/lib/appwrite/models/execution.rb +20 -10
  21. data/lib/appwrite/models/file.rb +15 -15
  22. data/lib/appwrite/models/function.rb +12 -12
  23. data/lib/appwrite/models/index.rb +1 -1
  24. data/lib/appwrite/models/membership.rb +25 -10
  25. data/lib/appwrite/models/session.rb +5 -0
  26. data/lib/appwrite/models/team.rb +10 -5
  27. data/lib/appwrite/models/token.rb +5 -0
  28. data/lib/appwrite/models/user.rb +35 -0
  29. data/lib/appwrite/models/variable.rb +52 -0
  30. data/lib/appwrite/models/variable_list.rb +32 -0
  31. data/lib/appwrite/permission.rb +21 -0
  32. data/lib/appwrite/query.rb +43 -14
  33. data/lib/appwrite/role.rb +31 -0
  34. data/lib/appwrite/services/account.rb +274 -126
  35. data/lib/appwrite/services/avatars.rb +106 -59
  36. data/lib/appwrite/services/databases.rb +1425 -0
  37. data/lib/appwrite/services/functions.rb +381 -176
  38. data/lib/appwrite/services/health.rb +34 -34
  39. data/lib/appwrite/services/locale.rb +25 -7
  40. data/lib/appwrite/services/storage.rb +195 -193
  41. data/lib/appwrite/services/teams.rb +138 -128
  42. data/lib/appwrite/services/users.rb +637 -123
  43. data/lib/appwrite.rb +19 -2
  44. metadata +22 -6
  45. data/lib/appwrite/file.rb +0 -17
  46. data/lib/appwrite/services/database.rb +0 -1049
@@ -3,29 +3,26 @@
3
3
  module Appwrite
4
4
  class Users < Service
5
5
 
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
6
10
  # Get a list of all the project's users. You can use the query params to
7
11
  # filter your results.
8
12
  #
9
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
10
- # @param [number] limit Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
11
- # @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
12
- # @param [string] cursor ID of the user used as the starting point for the query, excluding the user itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
13
- # @param [string] cursor_direction Direction of the cursor.
14
- # @param [string] order_type Order result by ASC or DESC order.
13
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification
14
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
15
15
  #
16
16
  # @return [UserList]
17
- def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
17
+ def list(queries: nil, search: nil)
18
+
18
19
  path = '/users'
19
20
 
20
21
  params = {
22
+ queries: queries,
21
23
  search: search,
22
- limit: limit,
23
- offset: offset,
24
- cursor: cursor,
25
- cursorDirection: cursor_direction,
26
- orderType: order_type,
27
24
  }
28
-
25
+
29
26
  headers = {
30
27
  "content-type": 'application/json',
31
28
  }
@@ -39,15 +36,71 @@ module Appwrite
39
36
  )
40
37
  end
41
38
 
39
+
42
40
  # Create a new user.
43
41
  #
44
- # @param [string] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
45
- # @param [string] email User email.
46
- # @param [string] password User password. Must be at least 8 chars.
47
- # @param [string] name User name. Max length: 128 chars.
42
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
43
+ # @param [String] email User email.
44
+ # @param [String] phone Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
45
+ # @param [String] password Plain text user password. Must be at least 8 chars.
46
+ # @param [String] name User name. Max length: 128 chars.
47
+ #
48
+ # @return [User]
49
+ def create(user_id:, email: nil, phone: nil, password: nil, name: nil)
50
+
51
+ path = '/users'
52
+
53
+ params = {
54
+ userId: user_id,
55
+ email: email,
56
+ phone: phone,
57
+ password: password,
58
+ name: name,
59
+ }
60
+
61
+ headers = {
62
+ "content-type": 'application/json',
63
+ }
64
+ if user_id.nil?
65
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
66
+ end
67
+
68
+
69
+ @client.call(
70
+ method: 'POST',
71
+ path: path,
72
+ headers: headers,
73
+ params: params,
74
+ response_type: Models::User
75
+ )
76
+ end
77
+
78
+
79
+ # Create a new user. Password provided must be hashed with the
80
+ # [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
81
+ # /users](/docs/server/users#usersCreate) endpoint to create users with a
82
+ # plain text password.
83
+ #
84
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
85
+ # @param [String] email User email.
86
+ # @param [String] password User password hashed using Argon2.
87
+ # @param [String] name User name. Max length: 128 chars.
48
88
  #
49
89
  # @return [User]
50
- def create(user_id:, email:, password:, name: nil)
90
+ def create_argon2_user(user_id:, email:, password:, name: nil)
91
+
92
+ path = '/users/argon2'
93
+
94
+ params = {
95
+ userId: user_id,
96
+ email: email,
97
+ password: password,
98
+ name: name,
99
+ }
100
+
101
+ headers = {
102
+ "content-type": 'application/json',
103
+ }
51
104
  if user_id.nil?
52
105
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
53
106
  end
@@ -60,7 +113,31 @@ module Appwrite
60
113
  raise Appwrite::Exception.new('Missing required parameter: "password"')
61
114
  end
62
115
 
63
- path = '/users'
116
+
117
+ @client.call(
118
+ method: 'POST',
119
+ path: path,
120
+ headers: headers,
121
+ params: params,
122
+ response_type: Models::User
123
+ )
124
+ end
125
+
126
+
127
+ # Create a new user. Password provided must be hashed with the
128
+ # [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
129
+ # /users](/docs/server/users#usersCreate) endpoint to create users with a
130
+ # plain text password.
131
+ #
132
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
133
+ # @param [String] email User email.
134
+ # @param [String] password User password hashed using Bcrypt.
135
+ # @param [String] name User name. Max length: 128 chars.
136
+ #
137
+ # @return [User]
138
+ def create_bcrypt_user(user_id:, email:, password:, name: nil)
139
+
140
+ path = '/users/bcrypt'
64
141
 
65
142
  params = {
66
143
  userId: user_id,
@@ -68,10 +145,22 @@ module Appwrite
68
145
  password: password,
69
146
  name: name,
70
147
  }
71
-
148
+
72
149
  headers = {
73
150
  "content-type": 'application/json',
74
151
  }
152
+ if user_id.nil?
153
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
154
+ end
155
+
156
+ if email.nil?
157
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
158
+ end
159
+
160
+ if password.nil?
161
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
162
+ end
163
+
75
164
 
76
165
  @client.call(
77
166
  method: 'POST',
@@ -82,28 +171,95 @@ module Appwrite
82
171
  )
83
172
  end
84
173
 
85
- # Get a user by its unique ID.
174
+
175
+ # Create a new user. Password provided must be hashed with the
176
+ # [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
177
+ # /users](/docs/server/users#usersCreate) endpoint to create users with a
178
+ # plain text password.
86
179
  #
87
- # @param [string] user_id User ID.
180
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
181
+ # @param [String] email User email.
182
+ # @param [String] password User password hashed using MD5.
183
+ # @param [String] name User name. Max length: 128 chars.
88
184
  #
89
185
  # @return [User]
90
- def get(user_id:)
186
+ def create_md5_user(user_id:, email:, password:, name: nil)
187
+
188
+ path = '/users/md5'
189
+
190
+ params = {
191
+ userId: user_id,
192
+ email: email,
193
+ password: password,
194
+ name: name,
195
+ }
196
+
197
+ headers = {
198
+ "content-type": 'application/json',
199
+ }
91
200
  if user_id.nil?
92
201
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
93
202
  end
94
203
 
95
- path = '/users/{userId}'
96
- .gsub('{userId}', user_id)
204
+ if email.nil?
205
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
206
+ end
207
+
208
+ if password.nil?
209
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
210
+ end
211
+
212
+
213
+ @client.call(
214
+ method: 'POST',
215
+ path: path,
216
+ headers: headers,
217
+ params: params,
218
+ response_type: Models::User
219
+ )
220
+ end
221
+
222
+
223
+ # Create a new user. Password provided must be hashed with the
224
+ # [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
225
+ # /users](/docs/server/users#usersCreate) endpoint to create users with a
226
+ # plain text password.
227
+ #
228
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
229
+ # @param [String] email User email.
230
+ # @param [String] password User password hashed using PHPass.
231
+ # @param [String] name User name. Max length: 128 chars.
232
+ #
233
+ # @return [User]
234
+ def create_ph_pass_user(user_id:, email:, password:, name: nil)
235
+
236
+ path = '/users/phpass'
97
237
 
98
238
  params = {
239
+ userId: user_id,
240
+ email: email,
241
+ password: password,
242
+ name: name,
99
243
  }
100
-
244
+
101
245
  headers = {
102
246
  "content-type": 'application/json',
103
247
  }
248
+ if user_id.nil?
249
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
250
+ end
251
+
252
+ if email.nil?
253
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
254
+ end
255
+
256
+ if password.nil?
257
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
258
+ end
259
+
104
260
 
105
261
  @client.call(
106
- method: 'GET',
262
+ method: 'POST',
107
263
  path: path,
108
264
  headers: headers,
109
265
  params: params,
@@ -111,41 +267,178 @@ module Appwrite
111
267
  )
112
268
  end
113
269
 
114
- # Delete a user by its unique ID.
270
+
271
+ # Create a new user. Password provided must be hashed with the
272
+ # [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
273
+ # /users](/docs/server/users#usersCreate) endpoint to create users with a
274
+ # plain text password.
115
275
  #
116
- # @param [string] user_id User ID.
276
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
277
+ # @param [String] email User email.
278
+ # @param [String] password User password hashed using Scrypt.
279
+ # @param [String] password_salt Optional salt used to hash password.
280
+ # @param [Integer] password_cpu Optional CPU cost used to hash password.
281
+ # @param [Integer] password_memory Optional memory cost used to hash password.
282
+ # @param [Integer] password_parallel Optional parallelization cost used to hash password.
283
+ # @param [Integer] password_length Optional hash length used to hash password.
284
+ # @param [String] name User name. Max length: 128 chars.
117
285
  #
118
- # @return []
119
- def delete(user_id:)
286
+ # @return [User]
287
+ def create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu:, password_memory:, password_parallel:, password_length:, name: nil)
288
+
289
+ path = '/users/scrypt'
290
+
291
+ params = {
292
+ userId: user_id,
293
+ email: email,
294
+ password: password,
295
+ passwordSalt: password_salt,
296
+ passwordCpu: password_cpu,
297
+ passwordMemory: password_memory,
298
+ passwordParallel: password_parallel,
299
+ passwordLength: password_length,
300
+ name: name,
301
+ }
302
+
303
+ headers = {
304
+ "content-type": 'application/json',
305
+ }
120
306
  if user_id.nil?
121
307
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
122
308
  end
123
309
 
124
- path = '/users/{userId}'
125
- .gsub('{userId}', user_id)
310
+ if email.nil?
311
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
312
+ end
313
+
314
+ if password.nil?
315
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
316
+ end
317
+
318
+ if password_salt.nil?
319
+ raise Appwrite::Exception.new('Missing required parameter: "passwordSalt"')
320
+ end
321
+
322
+ if password_cpu.nil?
323
+ raise Appwrite::Exception.new('Missing required parameter: "passwordCpu"')
324
+ end
325
+
326
+ if password_memory.nil?
327
+ raise Appwrite::Exception.new('Missing required parameter: "passwordMemory"')
328
+ end
329
+
330
+ if password_parallel.nil?
331
+ raise Appwrite::Exception.new('Missing required parameter: "passwordParallel"')
332
+ end
333
+
334
+ if password_length.nil?
335
+ raise Appwrite::Exception.new('Missing required parameter: "passwordLength"')
336
+ end
337
+
338
+
339
+ @client.call(
340
+ method: 'POST',
341
+ path: path,
342
+ headers: headers,
343
+ params: params,
344
+ response_type: Models::User
345
+ )
346
+ end
347
+
348
+
349
+ # Create a new user. Password provided must be hashed with the [Scrypt
350
+ # Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
351
+ # algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint
352
+ # to create users with a plain text password.
353
+ #
354
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
355
+ # @param [String] email User email.
356
+ # @param [String] password User password hashed using Scrypt Modified.
357
+ # @param [String] password_salt Salt used to hash password.
358
+ # @param [String] password_salt_separator Salt separator used to hash password.
359
+ # @param [String] password_signer_key Signer key used to hash password.
360
+ # @param [String] name User name. Max length: 128 chars.
361
+ #
362
+ # @return [User]
363
+ def create_scrypt_modified_user(user_id:, email:, password:, password_salt:, password_salt_separator:, password_signer_key:, name: nil)
364
+
365
+ path = '/users/scrypt-modified'
126
366
 
127
367
  params = {
368
+ userId: user_id,
369
+ email: email,
370
+ password: password,
371
+ passwordSalt: password_salt,
372
+ passwordSaltSeparator: password_salt_separator,
373
+ passwordSignerKey: password_signer_key,
374
+ name: name,
128
375
  }
129
-
376
+
130
377
  headers = {
131
378
  "content-type": 'application/json',
132
379
  }
380
+ if user_id.nil?
381
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
382
+ end
383
+
384
+ if email.nil?
385
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
386
+ end
387
+
388
+ if password.nil?
389
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
390
+ end
391
+
392
+ if password_salt.nil?
393
+ raise Appwrite::Exception.new('Missing required parameter: "passwordSalt"')
394
+ end
395
+
396
+ if password_salt_separator.nil?
397
+ raise Appwrite::Exception.new('Missing required parameter: "passwordSaltSeparator"')
398
+ end
399
+
400
+ if password_signer_key.nil?
401
+ raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"')
402
+ end
403
+
133
404
 
134
405
  @client.call(
135
- method: 'DELETE',
406
+ method: 'POST',
136
407
  path: path,
137
408
  headers: headers,
138
409
  params: params,
410
+ response_type: Models::User
139
411
  )
140
412
  end
141
413
 
142
- # Update the user email by its unique ID.
414
+
415
+ # Create a new user. Password provided must be hashed with the
416
+ # [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
417
+ # the [POST /users](/docs/server/users#usersCreate) endpoint to create users
418
+ # with a plain text password.
143
419
  #
144
- # @param [string] user_id User ID.
145
- # @param [string] email User email.
420
+ # @param [String] user_id User ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
421
+ # @param [String] email User email.
422
+ # @param [String] password User password hashed using SHA.
423
+ # @param [String] password_version Optional SHA version used to hash password. Allowed values are: &#039;sha1&#039;, &#039;sha224&#039;, &#039;sha256&#039;, &#039;sha384&#039;, &#039;sha512/224&#039;, &#039;sha512/256&#039;, &#039;sha512&#039;, &#039;sha3-224&#039;, &#039;sha3-256&#039;, &#039;sha3-384&#039;, &#039;sha3-512&#039;
424
+ # @param [String] name User name. Max length: 128 chars.
146
425
  #
147
426
  # @return [User]
148
- def update_email(user_id:, email:)
427
+ def create_sha_user(user_id:, email:, password:, password_version: nil, name: nil)
428
+
429
+ path = '/users/sha'
430
+
431
+ params = {
432
+ userId: user_id,
433
+ email: email,
434
+ password: password,
435
+ passwordVersion: password_version,
436
+ name: name,
437
+ }
438
+
439
+ headers = {
440
+ "content-type": 'application/json',
441
+ }
149
442
  if user_id.nil?
150
443
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
151
444
  end
@@ -154,16 +447,112 @@ module Appwrite
154
447
  raise Appwrite::Exception.new('Missing required parameter: "email"')
155
448
  end
156
449
 
157
- path = '/users/{userId}/email'
450
+ if password.nil?
451
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
452
+ end
453
+
454
+
455
+ @client.call(
456
+ method: 'POST',
457
+ path: path,
458
+ headers: headers,
459
+ params: params,
460
+ response_type: Models::User
461
+ )
462
+ end
463
+
464
+
465
+ # Get a user by its unique ID.
466
+ #
467
+ # @param [String] user_id User ID.
468
+ #
469
+ # @return [User]
470
+ def get(user_id:)
471
+
472
+ path = '/users/{userId}'
473
+
474
+ params = {
475
+ }
476
+
477
+ headers = {
478
+ "content-type": 'application/json',
479
+ }
480
+ if user_id.nil?
481
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
482
+ end
483
+
158
484
  .gsub('{userId}', user_id)
159
485
 
486
+ @client.call(
487
+ method: 'GET',
488
+ path: path,
489
+ headers: headers,
490
+ params: params,
491
+ response_type: Models::User
492
+ )
493
+ end
494
+
495
+
496
+ # Delete a user by its unique ID, thereby releasing it's ID. Since ID is
497
+ # released and can be reused, all user-related resources like documents or
498
+ # storage files should be deleted before user deletion. If you want to keep
499
+ # ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
500
+ # endpoint instead.
501
+ #
502
+ # @param [String] user_id User ID.
503
+ #
504
+ # @return []
505
+ def delete(user_id:)
506
+
507
+ path = '/users/{userId}'
508
+
160
509
  params = {
161
- email: email,
162
510
  }
511
+
512
+ headers = {
513
+ "content-type": 'application/json',
514
+ }
515
+ if user_id.nil?
516
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
517
+ end
518
+
519
+ .gsub('{userId}', user_id)
520
+
521
+ @client.call(
522
+ method: 'DELETE',
523
+ path: path,
524
+ headers: headers,
525
+ params: params,
526
+ )
527
+ end
528
+
529
+
530
+ # Update the user email by its unique ID.
531
+ #
532
+ # @param [String] user_id User ID.
533
+ # @param [String] email User email.
534
+ #
535
+ # @return [User]
536
+ def update_email(user_id:, email:)
537
+
538
+ path = '/users/{userId}/email'
163
539
 
540
+ params = {
541
+ email: email,
542
+ }
543
+
164
544
  headers = {
165
545
  "content-type": 'application/json',
166
546
  }
547
+ if user_id.nil?
548
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
549
+ end
550
+
551
+ if email.nil?
552
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
553
+ end
554
+
555
+ .gsub('{userId}', user_id)
167
556
 
168
557
  @client.call(
169
558
  method: 'PATCH',
@@ -174,64 +563,97 @@ module Appwrite
174
563
  )
175
564
  end
176
565
 
566
+
177
567
  # Get the user activity logs list by its unique ID.
178
568
  #
179
- # @param [string] user_id User ID.
180
- # @param [number] limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
181
- # @param [number] offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
569
+ # @param [String] user_id User ID.
570
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset
182
571
  #
183
572
  # @return [LogList]
184
- def get_logs(user_id:, limit: nil, offset: nil)
573
+ def get_logs(user_id:, queries: nil)
574
+
575
+ path = '/users/{userId}/logs'
576
+
577
+ params = {
578
+ queries: queries,
579
+ }
580
+
581
+ headers = {
582
+ "content-type": 'application/json',
583
+ }
185
584
  if user_id.nil?
186
585
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
187
586
  end
188
587
 
189
- path = '/users/{userId}/logs'
190
588
  .gsub('{userId}', user_id)
191
589
 
590
+ @client.call(
591
+ method: 'GET',
592
+ path: path,
593
+ headers: headers,
594
+ params: params,
595
+ response_type: Models::LogList
596
+ )
597
+ end
598
+
599
+
600
+ # Get the user membership list by its unique ID.
601
+ #
602
+ # @param [String] user_id User ID.
603
+ #
604
+ # @return [MembershipList]
605
+ def get_memberships(user_id:)
606
+
607
+ path = '/users/{userId}/memberships'
608
+
192
609
  params = {
193
- limit: limit,
194
- offset: offset,
195
610
  }
196
-
611
+
197
612
  headers = {
198
613
  "content-type": 'application/json',
199
614
  }
615
+ if user_id.nil?
616
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
617
+ end
618
+
619
+ .gsub('{userId}', user_id)
200
620
 
201
621
  @client.call(
202
622
  method: 'GET',
203
623
  path: path,
204
624
  headers: headers,
205
625
  params: params,
206
- response_type: Models::LogList
626
+ response_type: Models::MembershipList
207
627
  )
208
628
  end
209
629
 
630
+
210
631
  # Update the user name by its unique ID.
211
632
  #
212
- # @param [string] user_id User ID.
213
- # @param [string] name User name. Max length: 128 chars.
633
+ # @param [String] user_id User ID.
634
+ # @param [String] name User name. Max length: 128 chars.
214
635
  #
215
636
  # @return [User]
216
637
  def update_name(user_id:, name:)
217
- if user_id.nil?
218
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
219
- end
220
-
221
- if name.nil?
222
- raise Appwrite::Exception.new('Missing required parameter: "name"')
223
- end
224
638
 
225
639
  path = '/users/{userId}/name'
226
- .gsub('{userId}', user_id)
227
640
 
228
641
  params = {
229
642
  name: name,
230
643
  }
231
-
644
+
232
645
  headers = {
233
646
  "content-type": 'application/json',
234
647
  }
648
+ if user_id.nil?
649
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
650
+ end
651
+
652
+ if name.nil?
653
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
654
+ end
655
+
656
+ .gsub('{userId}', user_id)
235
657
 
236
658
  @client.call(
237
659
  method: 'PATCH',
@@ -242,13 +664,24 @@ module Appwrite
242
664
  )
243
665
  end
244
666
 
667
+
245
668
  # Update the user password by its unique ID.
246
669
  #
247
- # @param [string] user_id User ID.
248
- # @param [string] password New user password. Must be at least 8 chars.
670
+ # @param [String] user_id User ID.
671
+ # @param [String] password New user password. Must be at least 8 chars.
249
672
  #
250
673
  # @return [User]
251
674
  def update_password(user_id:, password:)
675
+
676
+ path = '/users/{userId}/password'
677
+
678
+ params = {
679
+ password: password,
680
+ }
681
+
682
+ headers = {
683
+ "content-type": 'application/json',
684
+ }
252
685
  if user_id.nil?
253
686
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
254
687
  end
@@ -257,16 +690,44 @@ module Appwrite
257
690
  raise Appwrite::Exception.new('Missing required parameter: "password"')
258
691
  end
259
692
 
260
- path = '/users/{userId}/password'
261
693
  .gsub('{userId}', user_id)
262
694
 
695
+ @client.call(
696
+ method: 'PATCH',
697
+ path: path,
698
+ headers: headers,
699
+ params: params,
700
+ response_type: Models::User
701
+ )
702
+ end
703
+
704
+
705
+ # Update the user phone by its unique ID.
706
+ #
707
+ # @param [String] user_id User ID.
708
+ # @param [String] number User phone number.
709
+ #
710
+ # @return [User]
711
+ def update_phone(user_id:, number:)
712
+
713
+ path = '/users/{userId}/phone'
714
+
263
715
  params = {
264
- password: password,
716
+ number: number,
265
717
  }
266
-
718
+
267
719
  headers = {
268
720
  "content-type": 'application/json',
269
721
  }
722
+ if user_id.nil?
723
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
724
+ end
725
+
726
+ if number.nil?
727
+ raise Appwrite::Exception.new('Missing required parameter: "number"')
728
+ end
729
+
730
+ .gsub('{userId}', user_id)
270
731
 
271
732
  @client.call(
272
733
  method: 'PATCH',
@@ -277,25 +738,27 @@ module Appwrite
277
738
  )
278
739
  end
279
740
 
741
+
280
742
  # Get the user preferences by its unique ID.
281
743
  #
282
- # @param [string] user_id User ID.
744
+ # @param [String] user_id User ID.
283
745
  #
284
746
  # @return [Preferences]
285
747
  def get_prefs(user_id:)
286
- if user_id.nil?
287
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
288
- end
289
748
 
290
749
  path = '/users/{userId}/prefs'
291
- .gsub('{userId}', user_id)
292
750
 
293
751
  params = {
294
752
  }
295
-
753
+
296
754
  headers = {
297
755
  "content-type": 'application/json',
298
756
  }
757
+ if user_id.nil?
758
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
759
+ end
760
+
761
+ .gsub('{userId}', user_id)
299
762
 
300
763
  @client.call(
301
764
  method: 'GET',
@@ -306,33 +769,35 @@ module Appwrite
306
769
  )
307
770
  end
308
771
 
772
+
309
773
  # Update the user preferences by its unique ID. The object you pass is stored
310
774
  # as is, and replaces any previous value. The maximum allowed prefs size is
311
775
  # 64kB and throws error if exceeded.
312
776
  #
313
- # @param [string] user_id User ID.
314
- # @param [object] prefs Prefs key-value JSON object.
777
+ # @param [String] user_id User ID.
778
+ # @param [Hash] prefs Prefs key-value JSON object.
315
779
  #
316
780
  # @return [Preferences]
317
781
  def update_prefs(user_id:, prefs:)
318
- if user_id.nil?
319
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
320
- end
321
-
322
- if prefs.nil?
323
- raise Appwrite::Exception.new('Missing required parameter: "prefs"')
324
- end
325
782
 
326
783
  path = '/users/{userId}/prefs'
327
- .gsub('{userId}', user_id)
328
784
 
329
785
  params = {
330
786
  prefs: prefs,
331
787
  }
332
-
788
+
333
789
  headers = {
334
790
  "content-type": 'application/json',
335
791
  }
792
+ if user_id.nil?
793
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
794
+ end
795
+
796
+ if prefs.nil?
797
+ raise Appwrite::Exception.new('Missing required parameter: "prefs"')
798
+ end
799
+
800
+ .gsub('{userId}', user_id)
336
801
 
337
802
  @client.call(
338
803
  method: 'PATCH',
@@ -343,25 +808,27 @@ module Appwrite
343
808
  )
344
809
  end
345
810
 
811
+
346
812
  # Get the user sessions list by its unique ID.
347
813
  #
348
- # @param [string] user_id User ID.
814
+ # @param [String] user_id User ID.
349
815
  #
350
816
  # @return [SessionList]
351
817
  def get_sessions(user_id:)
352
- if user_id.nil?
353
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
354
- end
355
818
 
356
819
  path = '/users/{userId}/sessions'
357
- .gsub('{userId}', user_id)
358
820
 
359
821
  params = {
360
822
  }
361
-
823
+
362
824
  headers = {
363
825
  "content-type": 'application/json',
364
826
  }
827
+ if user_id.nil?
828
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
829
+ end
830
+
831
+ .gsub('{userId}', user_id)
365
832
 
366
833
  @client.call(
367
834
  method: 'GET',
@@ -372,25 +839,27 @@ module Appwrite
372
839
  )
373
840
  end
374
841
 
842
+
375
843
  # Delete all user's sessions by using the user's unique ID.
376
844
  #
377
- # @param [string] user_id User ID.
845
+ # @param [String] user_id User ID.
378
846
  #
379
847
  # @return []
380
848
  def delete_sessions(user_id:)
381
- if user_id.nil?
382
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
383
- end
384
849
 
385
850
  path = '/users/{userId}/sessions'
386
- .gsub('{userId}', user_id)
387
851
 
388
852
  params = {
389
853
  }
390
-
854
+
391
855
  headers = {
392
856
  "content-type": 'application/json',
393
857
  }
858
+ if user_id.nil?
859
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
860
+ end
861
+
862
+ .gsub('{userId}', user_id)
394
863
 
395
864
  @client.call(
396
865
  method: 'DELETE',
@@ -400,13 +869,23 @@ module Appwrite
400
869
  )
401
870
  end
402
871
 
872
+
403
873
  # Delete a user sessions by its unique ID.
404
874
  #
405
- # @param [string] user_id User ID.
406
- # @param [string] session_id Session ID.
875
+ # @param [String] user_id User ID.
876
+ # @param [String] session_id Session ID.
407
877
  #
408
878
  # @return []
409
879
  def delete_session(user_id:, session_id:)
880
+
881
+ path = '/users/{userId}/sessions/{sessionId}'
882
+
883
+ params = {
884
+ }
885
+
886
+ headers = {
887
+ "content-type": 'application/json',
888
+ }
410
889
  if user_id.nil?
411
890
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
412
891
  end
@@ -415,17 +894,9 @@ module Appwrite
415
894
  raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
416
895
  end
417
896
 
418
- path = '/users/{userId}/sessions/{sessionId}'
419
897
  .gsub('{userId}', user_id)
420
898
  .gsub('{sessionId}', session_id)
421
899
 
422
- params = {
423
- }
424
-
425
- headers = {
426
- "content-type": 'application/json',
427
- }
428
-
429
900
  @client.call(
430
901
  method: 'DELETE',
431
902
  path: path,
@@ -434,31 +905,34 @@ module Appwrite
434
905
  )
435
906
  end
436
907
 
437
- # Update the user status by its unique ID.
908
+
909
+ # Update the user status by its unique ID. Use this endpoint as an
910
+ # alternative to deleting a user if you want to keep user's ID reserved.
438
911
  #
439
- # @param [string] user_id User ID.
440
- # @param [boolean] status User Status. To activate the user pass `true` and to block the user pass `false`.
912
+ # @param [String] user_id User ID.
913
+ # @param [] status User Status. To activate the user pass `true` and to block the user pass `false`.
441
914
  #
442
915
  # @return [User]
443
916
  def update_status(user_id:, status:)
444
- if user_id.nil?
445
- raise Appwrite::Exception.new('Missing required parameter: "userId"')
446
- end
447
-
448
- if status.nil?
449
- raise Appwrite::Exception.new('Missing required parameter: "status"')
450
- end
451
917
 
452
918
  path = '/users/{userId}/status'
453
- .gsub('{userId}', user_id)
454
919
 
455
920
  params = {
456
921
  status: status,
457
922
  }
458
-
923
+
459
924
  headers = {
460
925
  "content-type": 'application/json',
461
926
  }
927
+ if user_id.nil?
928
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
929
+ end
930
+
931
+ if status.nil?
932
+ raise Appwrite::Exception.new('Missing required parameter: "status"')
933
+ end
934
+
935
+ .gsub('{userId}', user_id)
462
936
 
463
937
  @client.call(
464
938
  method: 'PATCH',
@@ -469,13 +943,24 @@ module Appwrite
469
943
  )
470
944
  end
471
945
 
946
+
472
947
  # Update the user email verification status by its unique ID.
473
948
  #
474
- # @param [string] user_id User ID.
475
- # @param [boolean] email_verification User email verification status.
949
+ # @param [String] user_id User ID.
950
+ # @param [] email_verification User email verification status.
476
951
  #
477
952
  # @return [User]
478
- def update_verification(user_id:, email_verification:)
953
+ def update_email_verification(user_id:, email_verification:)
954
+
955
+ path = '/users/{userId}/verification'
956
+
957
+ params = {
958
+ emailVerification: email_verification,
959
+ }
960
+
961
+ headers = {
962
+ "content-type": 'application/json',
963
+ }
479
964
  if user_id.nil?
480
965
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
481
966
  end
@@ -484,16 +969,44 @@ module Appwrite
484
969
  raise Appwrite::Exception.new('Missing required parameter: "emailVerification"')
485
970
  end
486
971
 
487
- path = '/users/{userId}/verification'
488
972
  .gsub('{userId}', user_id)
489
973
 
974
+ @client.call(
975
+ method: 'PATCH',
976
+ path: path,
977
+ headers: headers,
978
+ params: params,
979
+ response_type: Models::User
980
+ )
981
+ end
982
+
983
+
984
+ # Update the user phone verification status by its unique ID.
985
+ #
986
+ # @param [String] user_id User ID.
987
+ # @param [] phone_verification User phone verification status.
988
+ #
989
+ # @return [User]
990
+ def update_phone_verification(user_id:, phone_verification:)
991
+
992
+ path = '/users/{userId}/verification/phone'
993
+
490
994
  params = {
491
- emailVerification: email_verification,
995
+ phoneVerification: phone_verification,
492
996
  }
493
-
997
+
494
998
  headers = {
495
999
  "content-type": 'application/json',
496
1000
  }
1001
+ if user_id.nil?
1002
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
1003
+ end
1004
+
1005
+ if phone_verification.nil?
1006
+ raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"')
1007
+ end
1008
+
1009
+ .gsub('{userId}', user_id)
497
1010
 
498
1011
  @client.call(
499
1012
  method: 'PATCH',
@@ -504,5 +1017,6 @@ module Appwrite
504
1017
  )
505
1018
  end
506
1019
 
1020
+
507
1021
  end
508
1022
  end