1
0
Fork 0
mirror of synced 2024-08-21 13:11:51 +12:00
appwrite/app/sdks/dart/lib/services/account.dart

107 lines
3.6 KiB
Dart
Raw Normal View History

2019-09-20 18:35:36 +12:00
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
2019-09-20 18:33:11 +12:00
import 'package:dio/dio.dart';
class Account extends Service {
Account(Client client): super(client);
2019-10-09 21:40:02 +13:00
/// Get currently logged in user data as JSON object.
2019-09-20 18:33:11 +12:00
Future<Response> get() async {
String path = '/account';
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
}
2019-12-08 09:32:15 +13:00
/// 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.
2019-09-20 18:33:11 +12:00
Future<Response> delete() async {
String path = '/account';
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// 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.
2019-09-20 18:33:11 +12:00
Future<Response> updateEmail({email, password}) async {
String path = '/account/email';
Map<String, dynamic> params = {
'email': email,
'password': password,
};
return await this.client.call('patch', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Update currently logged in user account name.
2019-09-20 18:33:11 +12:00
Future<Response> updateName({name}) async {
String path = '/account/name';
Map<String, dynamic> params = {
'name': name,
};
return await this.client.call('patch', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Update currently logged in user password. For validation, user is required
/// to pass the password twice.
2019-09-20 18:33:11 +12:00
Future<Response> updatePassword({password, oldPassword}) async {
String path = '/account/password';
Map<String, dynamic> params = {
'password': password,
'old-password': oldPassword,
};
return await this.client.call('patch', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Get currently logged in user preferences key-value object.
2019-09-20 18:33:11 +12:00
Future<Response> getPrefs() async {
String path = '/account/prefs';
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Update currently logged in user account preferences. You can pass only the
/// specific settings you wish to update.
2019-09-20 18:33:11 +12:00
Future<Response> updatePrefs({prefs}) async {
String path = '/account/prefs';
Map<String, dynamic> params = {
'prefs': prefs,
};
return await this.client.call('patch', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Get currently logged in user list of latest security activity logs. Each
/// log returns user IP address, location and date and time of log.
2019-09-20 18:33:11 +12:00
Future<Response> getSecurity() async {
String path = '/account/security';
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
}
2019-10-09 21:40:02 +13:00
/// Get currently logged in user list of active sessions across different
/// devices.
2019-09-20 18:33:11 +12:00
Future<Response> getSessions() async {
String path = '/account/sessions';
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
}
}