searchGroupMembers static method

Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMembers({
  1. required V2TimGroupMemberSearchParam searchParam,
})

Implementation

static Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMembers({
  required V2TimGroupMemberSearchParam searchParam,
}) async {
  String userData = Tools.generateUserData();

  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  List<int> fild = List.empty(growable: true);
  if (searchParam.isSearchMemberUserID) {
    fild.add(0x01);
  }
  if (searchParam.isSearchMemberNickName) {
    fild.add(0x01 << 1);
  }
  if (searchParam.isSearchMemberRemark) {
    fild.add(0x01 << 2);
  }
  if (searchParam.isSearchMemberNameCard) {
    fild.add(0x01 << 3);
  }
  String param = json.encode({
    "group_search_member_params_keyword_list": searchParam.keywordList,
    "group_search_member_params_groupid_list": searchParam.groupIDList,
    "group_search_member_params_field_list": fild,
  });

  Pointer<Uint8> json_group_search_group_members_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMGroupSearchGroupMembers(json_group_search_group_members_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2GroupMemberInfoSearchResult>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> nativeList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));

    Map<String, dynamic> itemMap = Map<String, dynamic>.from({});

    for (var element in nativeList) {
      List<Map<String, dynamic>> list = List.from(element["group_search_member_result_member_info_list"]);
      List<Map<String, dynamic>> reslist = List.empty(growable: true);
      for (var el in list) {
        // todo
        reslist.add(Tools.groupMemberInfo2dartGroupMemberInfo(el).toJson());
      }
      itemMap.addAll({element["group_search_member_result_groupid"]: reslist});
    }

    return V2TimValueCallback<V2GroupMemberInfoSearchResult>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": itemMap,
    });
  }
}