Last active
June 27, 2019 19:07
-
-
Save VB10/eb2accab456bd58e96bdeb539906acc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// The service responsible for networking requests | |
class Api { | |
final _client = new http.Client(); | |
Future signin_user(LoginRequest login) { | |
Completer _completer = new Completer(); | |
_client | |
.post( | |
'${ApiHelper.AUTH_END_POINT}/verifyPassword?key=${ApiHelper.API_KEY}', | |
body: login.toJson()) | |
.then((val) { | |
final body = json.decode(val.body); | |
switch (val.statusCode) { | |
case 200: | |
_completer.complete(LoginResponse.fromJson(body)); | |
return; | |
case 400: | |
_completer.completeError(ErrorFirebaseModel.fromJson(body)); | |
return; | |
} | |
}); | |
return _completer.future; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment