import "package:appwrite/service.dart"; import "package:appwrite/client.dart"; import 'package:dio/dio.dart'; class Users extends Service { Users(Client client): super(client); /// Get a list of all the project users. You can use the query params to filter /// your results. Future listUsers({search = null, limit = 25, offset = null, orderType = 'ASC'}) async { String path = '/users'; Map params = { 'search': search, 'limit': limit, 'offset': offset, 'orderType': orderType, }; return await this.client.call('get', path: path, params: params); } /// Create a new user. Future createUser({email, password, name = null}) async { String path = '/users'; Map params = { 'email': email, 'password': password, 'name': name, }; return await this.client.call('post', path: path, params: params); } /// Get user by its unique ID. Future getUser({userId}) async { String path = '/users/{userId}'.replaceAll(RegExp('{userId}'), userId); Map params = { }; return await this.client.call('get', path: path, params: params); } /// Get user activity logs list by its unique ID. Future getUserLogs({userId}) async { String path = '/users/{userId}/logs'.replaceAll(RegExp('{userId}'), userId); Map params = { }; return await this.client.call('get', path: path, params: params); } /// Get user preferences by its unique ID. Future getUserPrefs({userId}) async { String path = '/users/{userId}/prefs'.replaceAll(RegExp('{userId}'), userId); Map params = { }; return await this.client.call('get', path: path, params: params); } /// Update user preferences by its unique ID. You can pass only the specific /// settings you wish to update. Future updateUserPrefs({userId, prefs}) async { String path = '/users/{userId}/prefs'.replaceAll(RegExp('{userId}'), userId); Map params = { 'prefs': prefs, }; return await this.client.call('patch', path: path, params: params); } /// Get user sessions list by its unique ID. Future getUserSessions({userId}) async { String path = '/users/{userId}/sessions'.replaceAll(RegExp('{userId}'), userId); Map params = { }; return await this.client.call('get', path: path, params: params); } /// Delete all user sessions by its unique ID. Future deleteUserSessions({userId}) async { String path = '/users/{userId}/sessions'.replaceAll(RegExp('{userId}'), userId); Map params = { }; return await this.client.call('delete', path: path, params: params); } /// Delete user sessions by its unique ID. Future deleteUserSession({userId, sessionId}) async { String path = '/users/{userId}/sessions/:session'.replaceAll(RegExp('{userId}'), userId); Map params = { 'sessionId': sessionId, }; return await this.client.call('delete', path: path, params: params); } /// Update user status by its unique ID. Future updateUserStatus({userId, status}) async { String path = '/users/{userId}/status'.replaceAll(RegExp('{userId}'), userId); Map params = { 'status': status, }; return await this.client.call('patch', path: path, params: params); } }