resetPassword method

Future<ResetPasswordResponse> resetPassword(
  1. ResetPasswordRequest resetPasswordRequest
)

Implementation

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

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