Class: Appwrite::Account

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Account

Returns a new instance of Account.



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

def initialize(client)
    @client = client
end

Instance Method Details

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

Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the /account/verfication route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new account session.

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)

    New user password. Must be between 8 and 256 chars.

  • name (String) (defaults to: nil)

    User name. Max length: 128 chars.

Returns:

  • (User)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/appwrite/services/account.rb', line 49

def create(user_id:, email:, password:, name: nil)
    api_path = '/account'

    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 = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_anonymous_sessionSession

Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its email and password or create an OAuth2 session.

Returns:

  • (Session)


1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
# File 'lib/appwrite/services/account.rb', line 1083

def create_anonymous_session()
    api_path = '/account/sessions/anonymous'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_email_password_session(email:, password:) ⇒ Session

Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

Parameters:

  • email (String)

    User email.

  • password (String)

    User password. Must be at least 8 chars.

Returns:

  • (Session)


1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/appwrite/services/account.rb', line 1116

def create_email_password_session(email:, password:)
    api_path = '/account/sessions/email'

    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 = {
        email: email,
        password: password,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_email_token(user_id:, email:, phrase: nil) ⇒ Token

Sends the user an email with a secret key for creating a session. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the POST /v1/account/sessions/token endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.

  • email (String)

    User email.

  • []

    phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.

Returns:

  • (Token)


1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
# File 'lib/appwrite/services/account.rb', line 1422

def create_email_token(user_id:, email:, phrase: nil)
    api_path = '/account/tokens/email'

    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 = {
        userId: user_id,
        email: email,
        phrase: phrase,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_email_verification(url:) ⇒ Token

Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the userId and secret arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the userId and secret parameters. Learn more about how to complete the verification process. The verification link sent to the user's email address is valid for 7 days.

Please note that in order to avoid a Redirect Attack, the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

Parameters:

  • url (String)

    URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

Returns:

  • (Token)


1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
# File 'lib/appwrite/services/account.rb', line 1626

def create_email_verification(url:)
    api_path = '/account/verifications/email'

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

    api_params = {
        url: url,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_magic_url_token(user_id:, email:, url: nil, phrase: nil) ⇒ Token

Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the POST /v1/account/sessions/token endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

Parameters:

  • user_id (String)

    Unique 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.

  • email (String)

    User email.

  • url (String) (defaults to: nil)

    URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

  • []

    phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.

Returns:

  • (Token)


1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
# File 'lib/appwrite/services/account.rb', line 1476

def create_magic_url_token(user_id:, email:, url: nil, phrase: nil)
    api_path = '/account/tokens/magic-url'

    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 = {
        userId: user_id,
        email: email,
        url: url,
        phrase: phrase,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_mfa_authenticator(type:) ⇒ MfaType

Add an authenticator app to be used as an MFA factor. Verify the authenticator using the verify authenticator method.

Parameters:

  • type (AuthenticatorType)

    Type of authenticator. Must be totp

Returns:

  • (MfaType)


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

def create_mfa_authenticator(type:)
    api_path = '/account/mfa/authenticators/{type}'
        .gsub('{type}', type)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_mfa_challenge(factor:) ⇒ MfaChallenge

Begin the process of MFA verification after sign-in. Finish the flow with updateMfaChallenge method.

Parameters:

  • factor (AuthenticationFactor)

    Factor used for verification. Must be one of following: email, phone, totp, recoveryCode, custom.

Returns:

  • (MfaChallenge)


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/account.rb', line 574

def create_mfa_challenge(factor:)
    api_path = '/account/mfa/challenges'

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

    api_params = {
        factor: factor,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_mfa_recovery_codesMfaRecoveryCodes

Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in createMfaChallenge method.

Returns:

  • (MfaRecoveryCodes)


704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/appwrite/services/account.rb', line 704

def create_mfa_recovery_codes()
    api_path = '/account/mfa/recovery-codes'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_o_auth2_token(provider:, success: nil, failure: nil, scopes: nil) ⇒ Object

Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.

If authentication succeeds, userId and secret of a token will be appended to the success URL as query parameters. These can be used to create a new session using the Create session endpoint.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

Parameters:

  • provider (OAuthProvider)

    OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom.

  • success (String) (defaults to: nil)

    URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

  • failure (String) (defaults to: nil)

    URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

  • scopes (Array) (defaults to: nil)

    A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.

Returns:

  • []



1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
# File 'lib/appwrite/services/account.rb', line 1531

def create_o_auth2_token(provider:, success: nil, failure: nil, scopes: nil)
    api_path = '/account/tokens/oauth2/{provider}'
        .gsub('{provider}', provider)

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

    api_params = {
        success: success,
        failure: failure,
        scopes: scopes,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'text/html',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: "location"
    )

end

#create_phone_token(user_id:, phone:) ⇒ Token

Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the POST /v1/account/sessions/token endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

Parameters:

  • user_id (String)

    Unique 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored.

  • phone (String)

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

Returns:

  • (Token)


1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# File 'lib/appwrite/services/account.rb', line 1575

def create_phone_token(user_id:, phone:)
    api_path = '/account/tokens/phone'

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

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

    api_params = {
        userId: user_id,
        phone: phone,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_phone_verificationToken

Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the accountUpdatePhone endpoint. Learn more about how to complete the verification process. The verification code sent to the user's phone number is valid for 15 minutes.

Returns:

  • (Token)


1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
# File 'lib/appwrite/services/account.rb', line 1798

def create_phone_verification()
    api_path = '/account/verifications/phone'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_recovery(email:, url:) ⇒ Token

Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the PUT /account/recovery endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour.

Parameters:

  • email (String)

    User email.

  • url (String)

    URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

Returns:

  • (Token)


937
938
939
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/account.rb', line 937

def create_recovery(email:, url:)
    api_path = '/account/recovery'

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

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

    api_params = {
        email: email,
        url: url,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_session(user_id:, secret:) ⇒ Session

Use this endpoint to create a session from token. Provide the userId and secret parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.

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.

  • secret (String)

    Secret of a token generated by login methods. For example, the createMagicURLToken or createPhoneToken methods.

Returns:

  • (Session)


1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
# File 'lib/appwrite/services/account.rb', line 1242

def create_session(user_id:, secret:)
    api_path = '/account/sessions/token'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#create_verification(url:) ⇒ Token

Deprecated.

This API has been deprecated since 1.8.0. Please use Account.createEmailVerification instead.

Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the userId and secret arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the userId and secret parameters. Learn more about how to complete the verification process. The verification link sent to the user's email address is valid for 7 days.

Please note that in order to avoid a Redirect Attack, the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

Parameters:

  • url (String)

    URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

Returns:

  • (Token)


1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
# File 'lib/appwrite/services/account.rb', line 1675

def create_verification(url:)
    api_path = '/account/verifications/email'

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

    api_params = {
        url: url,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

Delete an OAuth2 consent by its unique ID. All token families issued under the consent are revoked, and the app must ask for consent again to regain access.

Parameters:

  • consent_id (String)

    Consent unique ID.

Returns:

  • []



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/appwrite/services/account.rb', line 156

def delete_consent(consent_id:)
    api_path = '/account/consents/{consentId}'
        .gsub('{consentId}', consent_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

Delete a token family issued under an OAuth2 consent by its unique ID. The access and refresh tokens of the family stop working immediately; other token families and the consent itself are unaffected.

Parameters:

  • consent_id (String)

    Consent unique ID.

  • token_id (String)

    Token unique ID.

Returns:

  • []



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/appwrite/services/account.rb', line 265

def delete_consent_token(consent_id:, token_id:)
    api_path = '/account/consents/{consentId}/tokens/{tokenId}'
        .gsub('{consentId}', consent_id)
        .gsub('{tokenId}', token_id)

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

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": '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:

  • []



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/appwrite/services/account.rb', line 375

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

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

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

end

#delete_mfa_authenticator(type:) ⇒ Object

Delete an authenticator for a user by ID.

Parameters:

  • type (AuthenticatorType)

    Type of authenticator.

Returns:

  • []



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

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

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

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

end

#delete_session(session_id:) ⇒ Object

Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use Delete Sessions instead.

Parameters:

  • session_id (String)

    Session ID. Use the string 'current' to delete the current device session.

Returns:

  • []



1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/appwrite/services/account.rb', line 1349

def delete_session(session_id:)
    api_path = '/account/sessions/{sessionId}'
        .gsub('{sessionId}', session_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

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

end

#delete_sessionsObject

Delete all sessions from the user account and remove any sessions cookies from the end client.

Returns:

  • []



1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
# File 'lib/appwrite/services/account.rb', line 1053

def delete_sessions()
    api_path = '/account/sessions'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

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

end

#getUser

Get the currently logged in user.

Returns:

  • (User)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/appwrite/services/account.rb', line 14

def get()
    api_path = '/account'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

Get an OAuth2 consent the current user has given to a third-party app by its unique ID.

Parameters:

  • consent_id (String)

    Consent unique ID.

Returns:

  • (Oauth2Consent)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/appwrite/services/account.rb', line 123

def get_consent(consent_id:)
    api_path = '/account/consents/{consentId}'
        .gsub('{consentId}', consent_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

Get a token family issued under an OAuth2 consent by its unique ID. The token secrets themselves are never returned.

Parameters:

  • consent_id (String)

    Consent unique ID.

  • token_id (String)

    Token unique ID.

Returns:

  • (Oauth2ConsentToken)


226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/appwrite/services/account.rb', line 226

def get_consent_token(consent_id:, token_id:)
    api_path = '/account/consents/{consentId}/tokens/{tokenId}'
        .gsub('{consentId}', consent_id)
        .gsub('{tokenId}', token_id)

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

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#get_mfa_recovery_codesMfaRecoveryCodes

Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using createMfaRecoveryCodes method. An OTP challenge is required to read recovery codes.

Returns:

  • (MfaRecoveryCodes)


675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
# File 'lib/appwrite/services/account.rb', line 675

def get_mfa_recovery_codes()
    api_path = '/account/mfa/recovery-codes'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#get_prefsPreferences

Get the preferences as a key-value object for the currently logged in user.

Returns:

  • (Preferences)


869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/appwrite/services/account.rb', line 869

def get_prefs()
    api_path = '/account/prefs'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#get_session(session_id:) ⇒ Session

Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.

Parameters:

  • session_id (String)

    Session ID. Use the string 'current' to get the current device session.

Returns:

  • (Session)


1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/appwrite/services/account.rb', line 1280

def get_session(session_id:)
    api_path = '/account/sessions/{sessionId}'
        .gsub('{sessionId}', session_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

Get a list of the token families issued under an OAuth2 consent. Each entry represents one authorized device or session; the token secrets themselves are never returned.

Parameters:

  • consent_id (String)

    Consent unique ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.

  • []

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

Returns:

  • (Oauth2ConsentTokenList)


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/appwrite/services/account.rb', line 191

def list_consent_tokens(consent_id:, queries: nil, total: nil)
    api_path = '/account/consents/{consentId}/tokens'
        .gsub('{consentId}', consent_id)

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

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#list_consents(queries: nil, total: nil) ⇒ Oauth2ConsentList

Get a list of the OAuth2 consents the current user has given to third-party apps.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.

  • []

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

Returns:

  • (Oauth2ConsentList)


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/appwrite/services/account.rb', line 94

def list_consents(queries: nil, total: nil)
    api_path = '/account/consents'

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

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

Get the list of identities for the currently logged in user.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry

  • []

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

Returns:

  • (IdentityList)


347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/appwrite/services/account.rb', line 347

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

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

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

Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about 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)


407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/appwrite/services/account.rb', line 407

def list_logs(queries: nil, total: nil)
    api_path = '/account/logs'

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#list_mfa_factorsMfaFactors

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

Returns:

  • (MfaFactors)


647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/appwrite/services/account.rb', line 647

def list_mfa_factors()
    api_path = '/account/mfa/factors'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#list_sessionsSessionList

Get the list of active sessions across different devices for the currently logged in user.

Returns:

  • (SessionList)


1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/appwrite/services/account.rb', line 1027

def list_sessions()
    api_path = '/account/sessions'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

end

#update_email(email:, password:) ⇒ User

Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.

Parameters:

  • email (String)

    User email.

  • password (String)

    User password. Must be at least 8 chars.

Returns:

  • (User)


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/account.rb', line 309

def update_email(email:, password:)
    api_path = '/account/email'

    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 = {
        email: email,
        password: password,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": '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:, secret:) ⇒ Token

Use this endpoint to complete the user email verification process. Use both the userId and secret parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.

Parameters:

  • user_id (String)

    User ID.

  • secret (String)

    Valid verification token.

Returns:

  • (Token)


1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
# File 'lib/appwrite/services/account.rb', line 1711

def update_email_verification(user_id:, secret:)
    api_path = '/account/verifications/email'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_magic_url_session(user_id:, secret:) ⇒ Session

Deprecated.

This API has been deprecated since 1.6.0. Please use Account.createSession instead.

Use this endpoint to create a session from token. Provide the userId and secret parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.

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.

  • secret (String)

    Valid verification token.

Returns:

  • (Session)


1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
# File 'lib/appwrite/services/account.rb', line 1159

def update_magic_url_session(user_id:, secret:)
    api_path = '/account/sessions/magic-url'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_mfa(mfa:) ⇒ User

Enable or disable MFA on an account.

Parameters:

  • []

    mfa Enable or disable MFA.

Returns:

  • (User)


435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/appwrite/services/account.rb', line 435

def update_mfa(mfa:)
    api_path = '/account/mfa'

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

    api_params = {
        mfa: mfa,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_mfa_authenticator(type:, otp:) ⇒ User

Verify an authenticator app after adding it using the add authenticator method.

Parameters:

  • type (AuthenticatorType)

    Type of authenticator.

  • otp (String)

    Valid verification token.

Returns:

  • (User)


505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/appwrite/services/account.rb', line 505

def update_mfa_authenticator(type:, otp:)
    api_path = '/account/mfa/authenticators/{type}'
        .gsub('{type}', type)

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

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

    api_params = {
        otp: otp,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_mfa_challenge(challenge_id:, otp:) ⇒ Session

Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use createMfaChallenge method.

Parameters:

  • challenge_id (String)

    ID of the challenge.

  • otp (String)

    Valid verification token.

Returns:

  • (Session)


611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
# File 'lib/appwrite/services/account.rb', line 611

def update_mfa_challenge(challenge_id:, otp:)
    api_path = '/account/mfa/challenges'

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

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

    api_params = {
        challengeId: challenge_id,
        otp: otp,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_mfa_recovery_codesMfaRecoveryCodes

Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using createMfaRecoveryCodes method. An OTP challenge is required to regenreate recovery codes.

Returns:

  • (MfaRecoveryCodes)


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

def update_mfa_recovery_codes()
    api_path = '/account/mfa/recovery-codes'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_name(name:) ⇒ User

Update currently logged in user account name.

Parameters:

  • name (String)

    User name. Max length: 128 chars.

Returns:

  • (User)


760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
# File 'lib/appwrite/services/account.rb', line 760

def update_name(name:)
    api_path = '/account/name'

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

    api_params = {
        name: name,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_password(password:, old_password: nil) ⇒ User

Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.

Parameters:

  • password (String)

    New user password. Must be at least 8 chars.

  • old_password (String) (defaults to: nil)

    Current user password. Max length: 256 chars.

Returns:

  • (User)


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

def update_password(password:, old_password: nil)
    api_path = '/account/password'

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

    api_params = {
        password: password,
        oldPassword: old_password,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_phone(phone:, password:) ⇒ User

Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the POST /account/verification/phone endpoint to send a confirmation SMS.

Parameters:

  • phone (String)

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

  • password (String)

    User password. Must be at least 8 chars.

Returns:

  • (User)


833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# File 'lib/appwrite/services/account.rb', line 833

def update_phone(phone:, password:)
    api_path = '/account/phone'

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

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

    api_params = {
        phone: phone,
        password: password,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_phone_session(user_id:, secret:) ⇒ Session

Deprecated.

This API has been deprecated since 1.6.0. Please use Account.createSession instead.

Use this endpoint to create a session from token. Provide the userId and secret parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.

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.

  • secret (String)

    Valid verification token.

Returns:

  • (Session)


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
1229
1230
1231
1232
# File 'lib/appwrite/services/account.rb', line 1202

def update_phone_session(user_id:, secret:)
    api_path = '/account/sessions/phone'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_phone_verification(user_id:, secret:) ⇒ Token

Use this endpoint to complete the user phone verification process. Use the userId and secret that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code.

Parameters:

  • user_id (String)

    User ID.

  • secret (String)

    Valid verification token.

Returns:

  • (Token)


1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
# File 'lib/appwrite/services/account.rb', line 1829

def update_phone_verification(user_id:, secret:)
    api_path = '/account/verifications/phone'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_prefs(prefs:) ⇒ User

Update currently logged in user account preferences. 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:

  • prefs (Hash)

    Prefs key-value JSON object.

Returns:

  • (User)


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
922
# File 'lib/appwrite/services/account.rb', line 897

def update_prefs(prefs:)
    api_path = '/account/prefs'

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

    api_params = {
        prefs: prefs,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_recovery(user_id:, secret:, password:) ⇒ Token

Use this endpoint to complete the user account password reset. Both the userId and secret arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the POST /account/recovery endpoint.

Please note that in order to avoid a Redirect Attack the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

Parameters:

  • user_id (String)

    User ID.

  • secret (String)

    Valid reset token.

  • password (String)

    New user password. Must be between 8 and 256 chars.

Returns:

  • (Token)


985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
# File 'lib/appwrite/services/account.rb', line 985

def update_recovery(user_id:, secret:, password:)
    api_path = '/account/recovery'

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

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

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

    api_params = {
        userId: user_id,
        secret: secret,
        password: password,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_session(session_id:) ⇒ Session

Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider.

Parameters:

  • session_id (String)

    Session ID. Use the string 'current' to update the current device session.

Returns:

  • (Session)


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

def update_session(session_id:)
    api_path = '/account/sessions/{sessionId}'
        .gsub('{sessionId}', session_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_statusUser

Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.

Returns:

  • (User)


1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
# File 'lib/appwrite/services/account.rb', line 1380

def update_status()
    api_path = '/account/status'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end

#update_verification(user_id:, secret:) ⇒ Token

Deprecated.

This API has been deprecated since 1.8.0. Please use Account.updateEmailVerification instead.

Use this endpoint to complete the user email verification process. Use both the userId and secret parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.

Parameters:

  • user_id (String)

    User ID.

  • secret (String)

    Valid verification token.

Returns:

  • (Token)


1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
# File 'lib/appwrite/services/account.rb', line 1755

def update_verification(user_id:, secret:)
    api_path = '/account/verifications/email'

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

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

    api_params = {
        userId: user_id,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

end