getUserPasswordState method

Future<PasswordStateResponse> getUserPasswordState(
  1. String email
)

Implementation

Future<PasswordStateResponse> getUserPasswordState(String email) async {
  final url = Uri.parse('${_wepinBaseUrl}user/password-state?email=$email');
  final response = await http.get(url, headers: headers);

  if (response.statusCode >= 200 && response.statusCode < 300) {
    final responseBody = jsonDecode(response.body);
    return PasswordStateResponse.fromJson(responseBody);
  } else {
    if (response.statusCode != 400 || !response.body.contains('not exist')) {
      throw WepinError(WepinErrorCode.apiRequestError, 'code: ${response.statusCode} , body: ${response.body}');
    }
    return PasswordStateResponse(isPasswordResetRequired: true);
  }
}