signInWithEmailPassword method

Future<SignInResponse> signInWithEmailPassword(
  1. EmailAndPasswordRequest signInRequest
)

Implementation

Future<SignInResponse> signInWithEmailPassword(EmailAndPasswordRequest signInRequest) async {
  final url = Uri.parse('$firebaseUrl/accounts:signInWithPassword?key=$_firebaseKey');
  final jsonRequestBody = jsonEncode(signInRequest.toJson());
  final response = await http.post(
    url,
    headers: {'Content-Type': 'application/json'},
    body: jsonRequestBody,
  );

  if (response.statusCode >= 200 && response.statusCode < 300) {
    return SignInResponse.fromJson(jsonDecode(response.body));
  } else {
    throw WepinError(WepinErrorCode.apiRequestError, 'code: ${response.statusCode} , body: ${response.body}');
  }
}