getUser method

Future<Map> getUser(
  1. dynamic user_id, {
  2. required int clientId,
  3. bool? isUseCache,
  4. Duration? durationCacheExpire,
  5. String? extra,
})

getUser return result;

{
  "ok": true
  "result": {
  }
}

Implementation

Future<Map> getUser(
  dynamic user_id, {
  required int clientId,
  bool? isUseCache,
  Duration? durationCacheExpire,
  String? extra,
}) async {
  var get_user = await invoke(
    "getUser",
    parameters: {
      "user_id": user_id,
    },
    isUseCache: isUseCache,
    durationCacheExpire: durationCacheExpire,
    clientId: clientId,
    extra: extra,
  );
  if (RegExp(r"^user$", caseSensitive: false).hashData(get_user["@type"])) {
    var json = {};
    json["id"] = get_user["id"];
    try {
      if (RegExp(r"^userTypeBot$", caseSensitive: false)
          .hashData(get_user["type"]["@type"])) {
        json["is_bot"] = true;
      } else {
        json["is_bot"] = false;
      }
    } catch (e) {
      json["is_bot"] = false;
    }
    json["first_name"] = get_user["first_name"];
    if (TgUtils.getBoolean(get_user["last_name"])) {
      json["last_name"] = get_user["last_name"];
    }
    if (TgUtils.getBoolean(get_user["username"])) {
      json["username"] = get_user["username"];
    }

    if (get_user["usernames"] is Map) {
      Map get_user_usernames = (get_user["usernames"] as Map);
      json["usernames"] = get_user["usernames"];
      if (get_user_usernames["active_usernames"] is List) {
        if ((get_user_usernames["active_usernames"] as List).isNotEmpty) {
          json["username"] =
              (get_user_usernames["active_usernames"] as List).first;
        }
      }
    }
    if (TgUtils.getBoolean(get_user["phone_number"])) {
      json["phone_number"] = get_user["phone_number"];
    }
    if (TgUtils.getBoolean(get_user["language_code"])) {
      json["language_code"] = get_user["language_code"];
    }
    json["type"] = "private";
    json["detail"] = {
      "has_protected_content": false,
      "is_marked_as_unread": false,
      "is_blocked": false,
      "has_scheduled_messages": false,
      "can_be_deleted_only_for_self": false,
      "can_be_deleted_for_all_users": false,
      "can_be_reported": false,
      "default_disable_notification": false,
      "unread_count": 0,
      "last_read_inbox_message_id": 0,
      "last_read_outbox_message_id": 0,
      "unread_mention_count": 0,
      "is_contact": get_user["is_contact"],
      "is_mutual_contact": get_user["is_mutual_contact"],
      "is_verified": get_user["is_verified"],
      "is_support": get_user["is_support"],
      "is_scam": get_user["is_scam"],
      "is_fake": get_user["is_fake"],
      "have_acces": get_user["have_access"]
    };
    return {"ok": true, "result": json};
  }
  get_user["ok"] = false;
  get_user["result"] = {"id": user_id};
  return get_user;
}