bindPhone static method

Future<AuthResult> bindPhone(
  1. String phone,
  2. String code, {
  3. String? phoneCountryCode,
})

bind phone to current user.

Implementation

static Future<AuthResult> bindPhone(String phone, String code,
    {String? phoneCountryCode}) async {
  Map map = {};
  map.putIfAbsent('phone', () => phone);
  map.putIfAbsent('code', () => code);
  if (phoneCountryCode != null) {
    map.putIfAbsent('phoneCountryCode', () => phoneCountryCode);
  }
  final Result result =
      await post('/api/v2/users/phone/bind', jsonEncode(map));
  AuthResult authResult = AuthResult(result);
  if (result.code == 200) {
    authResult.user = await createUser(result);
  }
  return authResult;
}