1+ import "package:dart_appwrite/service.dart" ;
2+ import "package:dart_appwrite/client.dart" ;
3+ import 'package:dio/dio.dart' ;
4+
5+ class Account extends Service {
6+
7+ Account (Client client): super (client);
8+
9+ /// Get currently logged in user data as JSON object.
10+ Future <Response > get () async {
11+ String path = '/account' ;
12+
13+ Map <String , dynamic > params = {
14+ };
15+
16+ return await this .client.call ('get' , path: path, params: params);
17+ }
18+ /// Delete currently logged in user account.
19+ Future <Response > delete () async {
20+ String path = '/account' ;
21+
22+ Map <String , dynamic > params = {
23+ };
24+
25+ return await this .client.call ('delete' , path: path, params: params);
26+ }
27+ /// Update currently logged in user account email address. After changing user
28+ /// address, user confirmation status is being reset and a new confirmation
29+ /// mail is sent. For security measures, user password is required to complete
30+ /// this request.
31+ Future <Response > updateEmail ({email, password}) async {
32+ String path = '/account/email' ;
33+
34+ Map <String , dynamic > params = {
35+ 'email' : email,
36+ 'password' : password,
37+ };
38+
39+ return await this .client.call ('patch' , path: path, params: params);
40+ }
41+ /// Update currently logged in user account name.
42+ Future <Response > updateName ({name}) async {
43+ String path = '/account/name' ;
44+
45+ Map <String , dynamic > params = {
46+ 'name' : name,
47+ };
48+
49+ return await this .client.call ('patch' , path: path, params: params);
50+ }
51+ /// Update currently logged in user password. For validation, user is required
52+ /// to pass the password twice.
53+ Future <Response > updatePassword ({password, oldPassword}) async {
54+ String path = '/account/password' ;
55+
56+ Map <String , dynamic > params = {
57+ 'password' : password,
58+ 'old-password' : oldPassword,
59+ };
60+
61+ return await this .client.call ('patch' , path: path, params: params);
62+ }
63+ /// Get currently logged in user preferences key-value object.
64+ Future <Response > getPrefs () async {
65+ String path = '/account/prefs' ;
66+
67+ Map <String , dynamic > params = {
68+ };
69+
70+ return await this .client.call ('get' , path: path, params: params);
71+ }
72+ /// Update currently logged in user account preferences. You can pass only the
73+ /// specific settings you wish to update.
74+ Future <Response > updatePrefs ({prefs}) async {
75+ String path = '/account/prefs' ;
76+
77+ Map <String , dynamic > params = {
78+ 'prefs' : prefs,
79+ };
80+
81+ return await this .client.call ('patch' , path: path, params: params);
82+ }
83+ /// Get currently logged in user list of latest security activity logs. Each
84+ /// log returns user IP address, location and date and time of log.
85+ Future <Response > getSecurity () async {
86+ String path = '/account/security' ;
87+
88+ Map <String , dynamic > params = {
89+ };
90+
91+ return await this .client.call ('get' , path: path, params: params);
92+ }
93+ /// Get currently logged in user list of active sessions across different
94+ /// devices.
95+ Future <Response > getSessions () async {
96+ String path = '/account/sessions' ;
97+
98+ Map <String , dynamic > params = {
99+ };
100+
101+ return await this .client.call ('get' , path: path, params: params);
102+ }
103+ }
0 commit comments