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)
    api_path = '/users'

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

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

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_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](appwrite.io/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)


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

def create_argon2_user(user_id:, email:, password:, name: nil)
    api_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

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

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_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](appwrite.io/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)


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

def create_bcrypt_user(user_id:, email:, password:, name: nil)
    api_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

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

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

#create_jwt(user_id:, session_id: nil, duration: nil) ⇒ Jwt

Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted.

Parameters:

  • user_id (String)

    User ID.

  • session_id (String) (defaults to: nil)

    Session ID. Use the string ‘recent’ to use the most recent session. Defaults to the most recent session.

  • duration (Integer) (defaults to: nil)

    Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds.

Returns:

  • (Jwt)


610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/appwrite/services/users.rb', line 610

def create_jwt(user_id:, session_id: nil, duration: nil)
    api_path = '/users/{userId}/jwts'
        .gsub('{userId}', user_id)

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

    api_params = {
        sessionId: session_id,
        duration: duration,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Jwt
    )
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](appwrite.io/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)


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
263
264
265
266
267
268
# File 'lib/appwrite/services/users.rb', line 235

def create_md5_user(user_id:, email:, password:, name: nil)
    api_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

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

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

#create_mfa_recovery_codes(user_id:) ⇒ MfaRecoveryCodes

Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (MfaRecoveryCodes)


910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
# File 'lib/appwrite/services/users.rb', line 910

def create_mfa_recovery_codes(user_id:)
    api_path = '/users/{userId}/mfa/recovery-codes'
        .gsub('{userId}', user_id)

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::MfaRecoveryCodes
    )
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](appwrite.io/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)


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

def create_ph_pass_user(user_id:, email:, password:, name: nil)
    api_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

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

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_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](appwrite.io/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)


407
408
409
410
411
412
413
414
415
416
417
418
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
454
455
# File 'lib/appwrite/services/users.rb', line 407

def create_scrypt_modified_user(user_id:, email:, password:, password_salt:, password_salt_separator:, password_signer_key:, name: nil)
    api_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

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

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_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](appwrite.io/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)


332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
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
# File 'lib/appwrite/services/users.rb', line 332

def create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu:, password_memory:, password_parallel:, password_length:, name: nil)
    api_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

    api_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,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#create_session(user_id:) ⇒ Session

Creates a session for a user. Returns an immediately usable session object.

If you want to generate a token for a custom authentication flow, use the [POST /users/userId/tokens](appwrite.io/docs/server/users#createToken) endpoint.

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.

Returns:

  • (Session)


1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
# File 'lib/appwrite/services/users.rb', line 1144

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

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Session
    )
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](appwrite.io/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 (PasswordHash) (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)


469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/appwrite/services/users.rb', line 469

def create_sha_user(user_id:, email:, password:, password_version: nil, name: nil)
    api_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

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

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

#create_target(user_id:, target_id:, provider_type:, identifier:, provider_id: nil, name: nil) ⇒ Target

Create a messaging target.

Parameters:

  • user_id (String)

    User ID.

  • target_id (String)

    Target 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.

  • provider_type (MessagingProviderType)

    The target provider type. Can be one of the following: ‘email`, `sms` or `push`.

  • identifier (String)

    The target identifier (token, email, phone etc.)

  • provider_id (String) (defaults to: nil)

    Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.

  • name (String) (defaults to: nil)

    Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.

Returns:

  • (Target)


1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
# File 'lib/appwrite/services/users.rb', line 1308

def create_target(user_id:, target_id:, provider_type:, identifier:, provider_id: nil, name: nil)
    api_path = '/users/{userId}/targets'
        .gsub('{userId}', user_id)

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

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

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

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

    api_params = {
        targetId: target_id,
        providerType: provider_type,
        identifier: identifier,
        providerId: provider_id,
        name: name,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Target
    )
end

#create_token(user_id:, length: nil, expire: nil) ⇒ Token

Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process.

Parameters:

  • user_id (String)

    User ID.

  • length (Integer) (defaults to: nil)

    Token length in characters. The default length is 6 characters

  • expire (Integer) (defaults to: nil)

    Token expiration period in seconds. The default expiration is 15 minutes.

Returns:

  • (Token)


1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/appwrite/services/users.rb', line 1469

def create_token(user_id:, length: nil, expire: nil)
    api_path = '/users/{userId}/tokens'
        .gsub('{userId}', user_id)

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

    api_params = {
        length: length,
        expire: expire,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Token
    )
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](appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead.

Parameters:

  • user_id (String)

    User ID.

Returns:



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/appwrite/services/users.rb', line 543

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

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#delete_identity(identity_id:) ⇒ Object

Delete an identity by its unique ID.

Parameters:

  • identity_id (String)

    Identity ID.

Returns:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/appwrite/services/users.rb', line 201

def delete_identity(identity_id:)
    api_path = '/users/identities/{identityId}'
        .gsub('{identityId}', identity_id)

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#delete_mfa_authenticator(user_id:, type:) ⇒ Object

Delete an authenticator app.

Parameters:

  • user_id (String)

    User ID.

  • type (AuthenticatorType)

    Type of authenticator.

Returns:



783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/appwrite/services/users.rb', line 783

def delete_mfa_authenticator(user_id:, type:)
    api_path = '/users/{userId}/mfa/authenticators/{type}'
        .gsub('{userId}', user_id)
        .gsub('{type}', type)

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

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_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:



1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'lib/appwrite/services/users.rb', line 1202

def delete_session(user_id:, session_id:)
    api_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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_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:



1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'lib/appwrite/services/users.rb', line 1173

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

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#delete_target(user_id:, target_id:) ⇒ Object

Delete a messaging target.

Parameters:

  • user_id (String)

    User ID.

  • target_id (String)

    Target ID.

Returns:



1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
# File 'lib/appwrite/services/users.rb', line 1430

def delete_target(user_id:, target_id:)
    api_path = '/users/{userId}/targets/{targetId}'
        .gsub('{userId}', user_id)
        .gsub('{targetId}', target_id)

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

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#get(user_id:) ⇒ User

Get a user by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (User)


510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/appwrite/services/users.rb', line 510

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

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

    api_params = {
    }
    
    api_headers = {
    }

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

#get_mfa_recovery_codes(user_id:) ⇒ MfaRecoveryCodes

Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (MfaRecoveryCodes)


847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
# File 'lib/appwrite/services/users.rb', line 847

def get_mfa_recovery_codes(user_id:)
    api_path = '/users/{userId}/mfa/recovery-codes'
        .gsub('{userId}', user_id)

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

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::MfaRecoveryCodes
    )
end

#get_prefs(user_id:) ⇒ Preferences

Get the user preferences by its unique ID.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (Preferences)


1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
# File 'lib/appwrite/services/users.rb', line 1044

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

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

    api_params = {
    }
    
    api_headers = {
    }

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

#get_target(user_id:, target_id:) ⇒ Target

Get a user’s push notification target by ID.

Parameters:

  • user_id (String)

    User ID.

  • target_id (String)

    Target ID.

Returns:

  • (Target)


1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
# File 'lib/appwrite/services/users.rb', line 1355

def get_target(user_id:, target_id:)
    api_path = '/users/{userId}/targets/{targetId}'
        .gsub('{userId}', user_id)
        .gsub('{targetId}', target_id)

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

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

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Target
    )
end

#list(queries: nil, search: nil, total: 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, labels

  • search (String) (defaults to: nil)

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

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (UserList)


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

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

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
    }

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

#list_identities(queries: nil, search: nil, total: nil) ⇒ IdentityList

Get identities for all users.

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: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry

  • search (String) (defaults to: nil)

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

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (IdentityList)


175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/appwrite/services/users.rb', line 175

def list_identities(queries: nil, search: nil, total: nil)
    api_path = '/users/identities'

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::IdentityList
    )
end

#list_logs(user_id:, queries: nil, total: 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

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (LogList)


683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
# File 'lib/appwrite/services/users.rb', line 683

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

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

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
    }

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

#list_memberships(user_id:, queries: nil, search: nil, total: nil) ⇒ MembershipList

Get the user membership 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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles

  • search (String) (defaults to: nil)

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

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (MembershipList)


716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# File 'lib/appwrite/services/users.rb', line 716

def list_memberships(user_id:, queries: nil, search: nil, total: nil)
    api_path = '/users/{userId}/memberships'
        .gsub('{userId}', user_id)

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

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
    }

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

#list_mfa_factors(user_id:) ⇒ MfaFactors

List the factors available on the account to be used as a MFA challange.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (MfaFactors)


816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
# File 'lib/appwrite/services/users.rb', line 816

def list_mfa_factors(user_id:)
    api_path = '/users/{userId}/mfa/factors'
        .gsub('{userId}', user_id)

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

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::MfaFactors
    )
end

#list_sessions(user_id:, total: nil) ⇒ SessionList

Get the user sessions list by its unique ID.

Parameters:

  • user_id (String)

    User ID.

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (SessionList)


1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/appwrite/services/users.rb', line 1110

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

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

    api_params = {
        total: total,
    }
    
    api_headers = {
    }

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

#list_targets(user_id:, queries: nil, total: nil) ⇒ TargetList

List the messaging targets that are associated with a user.

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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (TargetList)


1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
# File 'lib/appwrite/services/users.rb', line 1273

def list_targets(user_id:, queries: nil, total: nil)
    api_path = '/users/{userId}/targets'
        .gsub('{userId}', user_id)

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

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::TargetList
    )
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)


572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/appwrite/services/users.rb', line 572

def update_email(user_id:, email:)
    api_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

    api_params = {
        email: email,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
# File 'lib/appwrite/services/users.rb', line 1501

def update_email_verification(user_id:, email_verification:)
    api_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

    api_params = {
        emailVerification: email_verification,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#update_labels(user_id:, labels:) ⇒ User

Update the user labels by its unique ID.

Labels can be used to grant access to resources. While teams are a way for user’s to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](appwrite.io/docs/permissions) for more info.

Parameters:

  • user_id (String)

    User ID.

  • labels (Array)

    Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long.

Returns:

  • (User)


647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'lib/appwrite/services/users.rb', line 647

def update_labels(user_id:, labels:)
    api_path = '/users/{userId}/labels'
        .gsub('{userId}', user_id)

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

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

    api_params = {
        labels: labels,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::User
    )
end

#update_mfa(user_id:, mfa:) ⇒ User

Enable or disable MFA on a user account.

Parameters:

  • user_id (String)

    User ID.

  • []

    mfa Enable or disable MFA.

Returns:

  • (User)


748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/appwrite/services/users.rb', line 748

def update_mfa(user_id:, mfa:)
    api_path = '/users/{userId}/mfa'
        .gsub('{userId}', user_id)

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

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

    api_params = {
        mfa: mfa,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#update_mfa_recovery_codes(user_id:) ⇒ MfaRecoveryCodes

Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.

Parameters:

  • user_id (String)

    User ID.

Returns:

  • (MfaRecoveryCodes)


878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
# File 'lib/appwrite/services/users.rb', line 878

def update_mfa_recovery_codes(user_id:)
    api_path = '/users/{userId}/mfa/recovery-codes'
        .gsub('{userId}', user_id)

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

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::MfaRecoveryCodes
    )
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)


940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/appwrite/services/users.rb', line 940

def update_name(user_id:, name:)
    api_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

    api_params = {
        name: name,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/appwrite/services/users.rb', line 975

def update_password(user_id:, password:)
    api_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

    api_params = {
        password: password,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
# File 'lib/appwrite/services/users.rb', line 1010

def update_phone(user_id:, number:)
    api_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

    api_params = {
        number: number,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
# File 'lib/appwrite/services/users.rb', line 1536

def update_phone_verification(user_id:, phone_verification:)
    api_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

    api_params = {
        phoneVerification: phone_verification,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/appwrite/services/users.rb', line 1075

def update_prefs(user_id:, prefs:)
    api_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

    api_params = {
        prefs: prefs,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_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)


1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/appwrite/services/users.rb', line 1237

def update_status(user_id:, status:)
    api_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

    api_params = {
        status: status,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

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

#update_target(user_id:, target_id:, identifier: nil, provider_id: nil, name: nil) ⇒ Target

Update a messaging target.

Parameters:

  • user_id (String)

    User ID.

  • target_id (String)

    Target ID.

  • identifier (String) (defaults to: nil)

    The target identifier (token, email, phone etc.)

  • provider_id (String) (defaults to: nil)

    Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.

  • name (String) (defaults to: nil)

    Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.

Returns:

  • (Target)


1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
# File 'lib/appwrite/services/users.rb', line 1392

def update_target(user_id:, target_id:, identifier: nil, provider_id: nil, name: nil)
    api_path = '/users/{userId}/targets/{targetId}'
        .gsub('{userId}', user_id)
        .gsub('{targetId}', target_id)

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

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

    api_params = {
        identifier: identifier,
        providerId: provider_id,
        name: name,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Target
    )
end