11part of flutter_parse_sdk;
22
33class ParseUser extends ParseBase {
4- ParseHTTPClient _client;
54 static final String className = '_User' ;
6- String path = "/classes/$className " ;
5+ static final String path = "/classes/$className " ;
76 bool _debug;
7+ ParseHTTPClient _client;
88
99 String acl;
1010 String username;
@@ -21,9 +21,7 @@ class ParseUser extends ParseBase {
2121 /// Requires [String] username, [String] password. [String] email address
2222 /// is required as well to create a full new user object on ParseServer. Only
2323 /// username and password is required to login
24- ParseUser (this .username, this .password, this .emailAddress,
25- {bool debug, ParseHTTPClient client})
26- : super () {
24+ ParseUser (this .username, this .password, this .emailAddress, {bool debug, ParseHTTPClient client}) : super () {
2725 client == null ? _client = ParseHTTPClient () : _client = client;
2826 _debug = isDebugEnabled (client, objectLevelDebug: debug);
2927 }
@@ -222,12 +220,23 @@ class ParseUser extends ParseBase {
222220 }
223221
224222 /// Gets a list of all users (limited return)
225- all () async {
223+ static all () async {
224+
225+ var emptyUser = ParseUser (null , null , null );
226+
226227 try {
227- final response = await _client.get (_client.data.serverUrl + "$path " );
228- return _handleResponse (response, ParseApiRQ .all);
228+ final response = await ParseHTTPClient ().get (
229+ "${ParseCoreData ().serverUrl }/$path " );
230+
231+ ParseResponse parseResponse = ParseResponse .handleResponse (emptyUser, response);
232+
233+ if (ParseCoreData ().debug) {
234+ logger (ParseCoreData ().appName, className, ParseApiRQ .getAll.toString (), parseResponse);
235+ }
236+
237+ return parseResponse;
229238 } on Exception catch (e) {
230- return _handleException (e, ParseApiRQ .all );
239+ return ParseResponse . handleException (emptyUser, e );
231240 }
232241 }
233242
@@ -267,17 +276,22 @@ class ParseUser extends ParseBase {
267276
268277 /// Handles all the response data for this class
269278 _handleResponse (Response response, ParseApiRQ type) {
270- Map <String , dynamic > responseData = JsonDecoder ().convert (response.body);
271- if (responseData.containsKey ('sessionToken' )) {
272- fromJson (responseData);
273- _client.data.sessionId = responseData['sessionToken' ];
274- }
275279
276280 ParseResponse parseResponse = ParseResponse .handleResponse (this , response);
277281 if (_debug) {
278282 logger (ParseCoreData ().appName, className, type.toString (), parseResponse);
279283 }
280284
281- return this ;
285+ Map <String , dynamic > responseData = JsonDecoder ().convert (response.body);
286+ if (responseData.containsKey ('objectId' )) {
287+ fromJson (responseData);
288+ _client.data.sessionId = responseData['sessionToken' ];
289+ }
290+
291+ if (type == ParseApiRQ .getAll) {
292+ return parseResponse;
293+ } else {
294+ return this ;
295+ }
282296 }
283297}
0 commit comments