Class: Appwrite::Users

Inherits:
Service show all
Defined in:
lib/appwrite/services/users.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Users

Returns a new instance of Users.



6
7
8
# File 'lib/appwrite/services/users.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create(user_id:, email: nil, phone: nil, password: nil, name: nil) ⇒ User

Create a new user.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String) (defaults to: nil)

    User email.

  • phone (String) (defaults to: nil)

    Phone number. Format this number with a leading ‘+’ and a country code, e.g., +16175551212.

  • password (String) (defaults to: nil)

    Plain text user password. Must be at least 8 chars.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


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
# File 'lib/appwrite/services/users.rb', line 48

def create(user_id:, email: nil, phone: nil, password: nil, name: nil)
    path = '/users'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
        userId: user_id,
        email: email,
        phone: phone,
        password: password,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_argon2_user(user_id:, email:, password:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [Argon2](en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using Argon2.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


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
# File 'lib/appwrite/services/users.rb', line 88

def create_argon2_user(user_id:, email:, password:, name: nil)
    path = '/users/argon2'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_bcrypt_user(user_id:, email:, password:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [Bcrypt](en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using Bcrypt.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


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
# File 'lib/appwrite/services/users.rb', line 135

def create_bcrypt_user(user_id:, email:, password:, name: nil)
    path = '/users/bcrypt'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_md5_user(user_id:, email:, password:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [MD5](en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using MD5.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


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
# File 'lib/appwrite/services/users.rb', line 182

def create_md5_user(user_id:, email:, password:, name: nil)
    path = '/users/md5'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_ph_pass_user(user_id:, email:, password:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [PHPass](www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or pass the string ‘ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using PHPass.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/appwrite/services/users.rb', line 229

def create_ph_pass_user(user_id:, email:, password:, name: nil)
    path = '/users/phpass'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_scrypt_modified_user(user_id:, email:, password:, password_salt:, password_salt_separator:, password_signer_key:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [Scrypt Modified](gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using Scrypt Modified.

  • password_salt (String)

    Salt used to hash password.

  • password_salt_separator (String)

    Salt separator used to hash password.

  • password_signer_key (String)

    Signer key used to hash password.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/appwrite/services/users.rb', line 356

def create_scrypt_modified_user(user_id:, email:, password:, password_salt:, password_salt_separator:, password_signer_key:, name: nil)
    path = '/users/scrypt-modified'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    if password_salt.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordSalt"')
    end

    if password_salt_separator.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordSaltSeparator"')
    end

    if password_signer_key.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        passwordSalt: password_salt,
        passwordSaltSeparator: password_salt_separator,
        passwordSignerKey: password_signer_key,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu:, password_memory:, password_parallel:, password_length:, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [Scrypt](github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using Scrypt.

  • password_salt (String)

    Optional salt used to hash password.

  • password_cpu (Integer)

    Optional CPU cost used to hash password.

  • password_memory (Integer)

    Optional memory cost used to hash password.

  • password_parallel (Integer)

    Optional parallelization cost used to hash password.

  • password_length (Integer)

    Optional hash length used to hash password.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/appwrite/services/users.rb', line 281

def create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu:, password_memory:, password_parallel:, password_length:, name: nil)
    path = '/users/scrypt'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    if password_salt.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordSalt"')
    end

    if password_cpu.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordCpu"')
    end

    if password_memory.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordMemory"')
    end

    if password_parallel.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordParallel"')
    end

    if password_length.nil?
      raise Appwrite::Exception.new('Missing required parameter: "passwordLength"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        passwordSalt: password_salt,
        passwordCpu: password_cpu,
        passwordMemory: password_memory,
        passwordParallel: password_parallel,
        passwordLength: password_length,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#create_sha_user(user_id:, email:, password:, password_version: nil, name: nil) ⇒ User

Create a new user. Password provided must be hashed with the [SHA](en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.

Parameters:

  • user_id (String)

    User ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • email (String)

    User email.

  • password (String)

    User password hashed using SHA.

  • password_version (String) (defaults to: nil)

    Optional SHA version used to hash password. Allowed values are: ‘sha1’, ‘sha224’, ‘sha256’, ‘sha384’, ‘sha512/224’, ‘sha512/256’, ‘sha512’, ‘sha3-224’, ‘sha3-256’, ‘sha3-384’, ‘sha3-512’

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/appwrite/services/users.rb', line 419

def create_sha_user(user_id:, email:, password:, password_version: nil, name: nil)
    path = '/users/sha'

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        userId: user_id,
        email: email,
        password: password,
        passwordVersion: password_version,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#delete(user_id:) ⇒ Object

Delete a user by its unique ID, thereby releasing it’s ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) endpoint instead.

Parameters:

  • user_id (String)

    User ID.

Returns:



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/appwrite/services/users.rb', line 495

def delete(user_id:)
    path = '/users/{userId}'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: path,
        headers: headers,
        params: params,
    )
end

#delete_session(user_id:, session_id:) ⇒ Object

Delete a user sessions by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • session_id (String)

    Session ID.

Returns:



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
# File 'lib/appwrite/services/users.rb', line 858

def delete_session(user_id:, session_id:)
    path = '/users/{userId}/sessions/{sessionId}'
        .gsub('{userId}', user_id)
        .gsub('{sessionId}', session_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if session_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: path,
        headers: headers,
        params: params,
    )
end

#delete_sessions(user_id:) ⇒ Object

Delete all user’s sessions by using the user’s unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:



828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
# File 'lib/appwrite/services/users.rb', line 828

def delete_sessions(user_id:)
    path = '/users/{userId}/sessions'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: path,
        headers: headers,
        params: params,
    )
end

#get(user_id:) ⇒ User

Get a user by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (User)


461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/appwrite/services/users.rb', line 461

def get(user_id:)
    path = '/users/{userId}'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#get_prefs(user_id:) ⇒ Preferences

Get the user preferences by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (Preferences)


730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'lib/appwrite/services/users.rb', line 730

def get_prefs(user_id:)
    path = '/users/{userId}/prefs'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::Preferences
    )
end

#list(queries: nil, search: nil) ⇒ UserList

Get a list of all the project’s users. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). 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

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

Returns:

  • (UserList)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/appwrite/services/users.rb', line 17

def list(queries: nil, search: nil)
    path = '/users'

    params = {
        queries: queries,
        search: search,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::UserList
    )
end

#list_logs(user_id:, queries: nil) ⇒ LogList

Get the user activity logs list by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Only supported methods are limit and offset

Returns:

  • (LogList)


561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/appwrite/services/users.rb', line 561

def list_logs(user_id:, queries: nil)
    path = '/users/{userId}/logs'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
        queries: queries,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::LogList
    )
end

#list_memberships(user_id:) ⇒ MembershipList

Get the user membership list by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (MembershipList)


592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/appwrite/services/users.rb', line 592

def list_memberships(user_id:)
    path = '/users/{userId}/memberships'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::MembershipList
    )
end

#list_sessions(user_id:) ⇒ SessionList

Get the user sessions list by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (SessionList)


798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/appwrite/services/users.rb', line 798

def list_sessions(user_id:)
    path = '/users/{userId}/sessions'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    params = {
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::SessionList
    )
end

#update_email(user_id:, email:) ⇒ User

Update the user email by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • email (String)

    User email.

Returns:

  • (User)


525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/appwrite/services/users.rb', line 525

def update_email(user_id:, email:)
    path = '/users/{userId}/email'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email.nil?
      raise Appwrite::Exception.new('Missing required parameter: "email"')
    end

    params = {
        email: email,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_email_verification(user_id:, email_verification:) ⇒ User

Update the user email verification status by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • []

    email_verification User email verification status.

Returns:

  • (User)


930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'lib/appwrite/services/users.rb', line 930

def update_email_verification(user_id:, email_verification:)
    path = '/users/{userId}/verification'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if email_verification.nil?
      raise Appwrite::Exception.new('Missing required parameter: "emailVerification"')
    end

    params = {
        emailVerification: email_verification,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_name(user_id:, name:) ⇒ User

Update the user name by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • name (String)

    User name. Max length: 128 chars.

Returns:

  • (User)


623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/appwrite/services/users.rb', line 623

def update_name(user_id:, name:)
    path = '/users/{userId}/name'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    params = {
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_password(user_id:, password:) ⇒ User

Update the user password by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • password (String)

    New user password. Must be at least 8 chars.

Returns:

  • (User)


659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/appwrite/services/users.rb', line 659

def update_password(user_id:, password:)
    path = '/users/{userId}/password'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if password.nil?
      raise Appwrite::Exception.new('Missing required parameter: "password"')
    end

    params = {
        password: password,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_phone(user_id:, number:) ⇒ User

Update the user phone by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • number (String)

    User phone number.

Returns:

  • (User)


695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
# File 'lib/appwrite/services/users.rb', line 695

def update_phone(user_id:, number:)
    path = '/users/{userId}/phone'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if number.nil?
      raise Appwrite::Exception.new('Missing required parameter: "number"')
    end

    params = {
        number: number,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_phone_verification(user_id:, phone_verification:) ⇒ User

Update the user phone verification status by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • []

    phone_verification User phone verification status.

Returns:

  • (User)


966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
# File 'lib/appwrite/services/users.rb', line 966

def update_phone_verification(user_id:, phone_verification:)
    path = '/users/{userId}/verification/phone'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if phone_verification.nil?
      raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"')
    end

    params = {
        phoneVerification: phone_verification,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end

#update_prefs(user_id:, prefs:) ⇒ Preferences

Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.

Parameters:

  • user_id (String)

    User ID.

  • prefs (Hash)

    Prefs key-value JSON object.

Returns:

  • (Preferences)


763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/appwrite/services/users.rb', line 763

def update_prefs(user_id:, prefs:)
    path = '/users/{userId}/prefs'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if prefs.nil?
      raise Appwrite::Exception.new('Missing required parameter: "prefs"')
    end

    params = {
        prefs: prefs,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::Preferences
    )
end

#update_status(user_id:, status:) ⇒ User

Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user’s ID reserved.

Parameters:

  • user_id (String)

    User ID.

  • []

    status User Status. To activate the user pass ‘true` and to block the user pass `false`.

Returns:

  • (User)


894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
# File 'lib/appwrite/services/users.rb', line 894

def update_status(user_id:, status:)
    path = '/users/{userId}/status'
        .gsub('{userId}', user_id)

    if user_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "userId"')
    end

    if status.nil?
      raise Appwrite::Exception.new('Missing required parameter: "status"')
    end

    params = {
        status: status,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::User
    )
end