deleteAccountByPhone static method

Future<AuthResult> deleteAccountByPhone(
  1. String phoneNumber,
  2. String passCode, [
  3. String? phoneCountryCode
])

delete account by phone number and an SMS code.

Implementation

static Future<AuthResult> deleteAccountByPhone(
    String phoneNumber, String passCode,
    [String? phoneCountryCode]) async {
  Map map = {};
  map.putIfAbsent('phoneNumber', () => phoneNumber);
  map.putIfAbsent('passCode', () => passCode);
  if (phoneCountryCode != null) {
    map.putIfAbsent('phoneCountryCode', () => phoneCountryCode);
  }
  var body = {'verifyMethod': 'PHONE_PASSCODE', 'phonePassCodePayload': map};
  final Result tokenResult =
      await post('/api/v3/verify-delete-account-request', jsonEncode(body));
  if (tokenResult.statusCode == 200) {
    var resultBody = {
      'deleteAccountToken': tokenResult.data['deleteAccountToken'],
    };
    final Result result =
        await post('/api/v3/delete-account', jsonEncode(resultBody));
    AuthResult authResult = AuthResult(result);
    return authResult;
  } else {
    return AuthResult(tokenResult);
  }
}