1
1
part of flutter_parse_sdk;
2
2
3
3
class ParseUser extends ParseBase {
4
- ParseHTTPClient _client;
5
4
static final String className = '_User' ;
6
- String path = "/classes/$className " ;
5
+ static final String path = "/classes/$className " ;
7
6
bool _debug;
7
+ ParseHTTPClient _client;
8
8
9
9
String acl;
10
10
String username;
@@ -21,9 +21,7 @@ class ParseUser extends ParseBase {
21
21
/// Requires [String] username, [String] password. [String] email address
22
22
/// is required as well to create a full new user object on ParseServer. Only
23
23
/// 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 () {
27
25
client == null ? _client = ParseHTTPClient () : _client = client;
28
26
_debug = isDebugEnabled (client, objectLevelDebug: debug);
29
27
}
@@ -222,12 +220,23 @@ class ParseUser extends ParseBase {
222
220
}
223
221
224
222
/// Gets a list of all users (limited return)
225
- all () async {
223
+ static all () async {
224
+
225
+ var emptyUser = ParseUser (null , null , null );
226
+
226
227
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;
229
238
} on Exception catch (e) {
230
- return _handleException (e, ParseApiRQ .all );
239
+ return ParseResponse . handleException (emptyUser, e );
231
240
}
232
241
}
233
242
@@ -267,17 +276,22 @@ class ParseUser extends ParseBase {
267
276
268
277
/// Handles all the response data for this class
269
278
_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
- }
275
279
276
280
ParseResponse parseResponse = ParseResponse .handleResponse (this , response);
277
281
if (_debug) {
278
282
logger (ParseCoreData ().appName, className, type.toString (), parseResponse);
279
283
}
280
284
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
+ }
282
296
}
283
297
}
0 commit comments