InappifyCaptchaChallenge.fromMap constructor

InappifyCaptchaChallenge.fromMap(
  1. Map<String, dynamic> map
)

Decodes the documented Web SDK challenge shape.

Implementation

factory InappifyCaptchaChallenge.fromMap(Map<String, dynamic> map) {
  final key = map['captchaKey'] ?? map['captcha_key'];
  final image = map['captchaImage'] ?? map['captcha_image'];
  final expires = map['expiresIn'] ?? map['expires_in'];
  if (key is! String ||
      key.isEmpty ||
      image is! String ||
      image.isEmpty ||
      expires is! num ||
      !expires.isFinite ||
      expires != expires.toInt()) {
    throw const FormatException('OTP CAPTCHA challenge is malformed.');
  }
  return InappifyCaptchaChallenge(
    captchaKey: key,
    captchaImage: image,
    expiresIn: expires.toInt(),
  );
}