verifyEmail method

Future<VerifyEmailResponse> verifyEmail(
  1. VerifyEmailRequest verifyEmailRequest
)

Implementation

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

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