import "package:appwrite/service.dart"; import "package:appwrite/client.dart"; import 'package:dio/dio.dart'; class Account extends Service { Account(Client client): super(client); /// Get currently logged in user data as JSON object. Future get() async { String path = '/account'; Map params = { }; return await this.client.call('get', path: path, params: params); } /// Delete a currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. This is done /// to avoid deleted accounts being overtaken by new users with the same email /// address. Any user-related resources like documents or storage files should /// be deleted separately. Future delete() async { String path = '/account'; Map params = { }; return await this.client.call('delete', path: path, params: params); } /// Update currently logged in user account email address. After changing user /// address, user confirmation status is being reset and a new confirmation /// mail is sent. For security measures, user password is required to complete /// this request. Future updateEmail({email, password}) async { String path = '/account/email'; Map params = { 'email': email, 'password': password, }; return await this.client.call('patch', path: path, params: params); } /// Update currently logged in user account name. Future updateName({name}) async { String path = '/account/name'; Map params = { 'name': name, }; return await this.client.call('patch', path: path, params: params); } /// Update currently logged in user password. For validation, user is required /// to pass the password twice. Future updatePassword({password, oldPassword}) async { String path = '/account/password'; Map params = { 'password': password, 'old-password': oldPassword, }; return await this.client.call('patch', path: path, params: params); } /// Get currently logged in user preferences key-value object. Future getPrefs() async { String path = '/account/prefs'; Map params = { }; return await this.client.call('get', path: path, params: params); } /// Update currently logged in user account preferences. You can pass only the /// specific settings you wish to update. Future updatePrefs({prefs}) async { String path = '/account/prefs'; Map params = { 'prefs': prefs, }; return await this.client.call('patch', path: path, params: params); } /// Get currently logged in user list of latest security activity logs. Each /// log returns user IP address, location and date and time of log. Future getSecurity() async { String path = '/account/security'; Map params = { }; return await this.client.call('get', path: path, params: params); } /// Get currently logged in user list of active sessions across different /// devices. Future getSessions() async { String path = '/account/sessions'; Map params = { }; return await this.client.call('get', path: path, params: params); } }