requestOtp method

Creates an OTP authentication challenge.

Implementation

@override
Future<InappifySdkResult<InappifyOtpChallenge>> requestOtp(
  InappifyOtpRequest request,
) async {
  final cancelled = _preCancelled<InappifyOtpChallenge>(
    'requestOtp',
    request.cancellation,
  );
  if (cancelled != null) return cancelled;
  return _run<InappifyOtpChallenge>(
    'requestOtp',
    action: () async {
      final raw = await _bridge.call(
        'requestOtp',
        positionalArguments: <Object?>[
          <String, Object?>{
            'phone': request.phone,
            if (request.captchaKey != null) 'captchaKey': request.captchaKey,
            if (request.captchaAnswer != null)
              'captchaAnswer': request.captchaAnswer,
          },
          if (request.cancellation != null) const <String, Object?>{},
        ],
        cancellation: request.cancellation,
        injectAbortSignal: request.cancellation != null,
      );
      return InappifyWebPayloadCodec.otpChallenge(raw);
    },
    cancellation: request.cancellation,
    mutationMayHaveCommitted: true,
  );
}