request method

Future<SAFResponse?> request(
  1. String mobile
)

请求风险识别

ip 初始化失败时不允许请求。

Implementation

Future<SAFResponse?> request(String mobile) async {
  assert(mobile.isNotEmpty, 'Cannot request empty mobile.');
  if (_ip == null) {
    await updateIP();
  }
  if (_ip == null) {
    throw AssertionError(
      'Failed to get IP address. Try again or call updateIP() method again.',
    );
  }
  final String? session = await _channel.invokeMethod(_METHOD_GET_SESSION);
  if (session == null) {
    throw NullThrownError();
  }
  final DateTime now = DateTime.now();
  final Map<String, String> params = getParams(
    getServiceParameters(session, mobile, now),
    now,
  );
  final String canonicalizationString = canonicalize(params);
  final String signature = _sign('POST', canonicalizationString);
  return _getData(params, signature);
}