6.5 Get Group By Id

The getGroupById returns details of a group. Any existing member of the group can retrieve details of the group, including the list of all the group members. The data is returned as a HashMap through success Callback. The keys for this HashMap are - id, name, type, groupMembers. Here, groupMembers is an ArrayList of HashMap, where each map represents a member with keys - companyEmployeeId, companyId, and companyName.

Method parameters :
  • groupId: Group Id of the Group.
  • success: Success block to be executed after group details are successfully retrieved.
  • failure: Failure block to be executed if group details could not be retrieved, returns BayunError.

Java
Kotlin
String groupId = "groupId";
HashMap<String, Object> groupDetails;

// Callbacks to get group info by its id
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Get group by id call successful.");
        groupDetails = (HashMap<String, Object>)message.getData().getSerializable("BayunGetGroup");

        Log.d(TAG, "group id: " + groupDetails.get("id"));
        Log.d(TAG, "group name: " + groupDetails.get("name"));
        Log.d(TAG, "group type: " + groupDetails.get("type"));
        ArrayList<HashMap<String, String>> groupMembers = (ArrayList<HashMap<String, String>>)groupDetails.get("groupMembers");

        for (HashMap<String, String> member: groupMembers) {
            Log.d(TAG, "companyEmployeeId: " + member.get("companyEmployeeId"));
            Log.d(TAG, "companyId: " + member.get("companyId"));
            Log.d(TAG, "companyName: " + member.get("companyName"));
        }
        return false;
    }
};

Handler.Callback failure = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String error = message.getData().getString("BayunError", "");
        if (error.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) {

        } else if (error.equalsIgnoreCase(BayunError.ERROR_REQUEST_TIMEOUT)) {

        }
        return false; 
    }
};

bayunCore.getGroupById(groupId, success, failure);
var groupId = "groupId"
var groupDetails: HashMap<String, Any>

// Callbacks to get group info by its id
val success = Handler.Callback {
    Log.d(TAG, "Get group by id call successful.")
    groupDetails = it.data.getSerializable("BayunGetGroup") as HashMap<String, Any>
    Log.d(TAG, "group id: " + groupDetails["id"])
    Log.d(TAG, "group name: " + groupDetails["name"])
    Log.d(TAG, "group type: "+ groupDetails["type"])

    val groupMembers = groupDetails.get("groupMembers")
                as ArrayList<HashMap<String, String>>

    for (member in groupMembers) {
        Log.d(TAG, "companyEmployeeId: " + member["companyEmployeeId"])
        Log.d(TAG, "companyId: " + member["companyId"])
        Log.d(TAG, "companyName: " + member["companyName"])
    }
    false
}

val failure = Handler.Callback {
    val error: String = it.data.getString("BayunError", "")
    if (error == BayunError.ERROR_INTERNET_CONNECTION){

    } else if (error == BayunError.ERROR_REQUEST_TIMEOUT) {

    }
    false
}

bayunCore.getGroupById(groupId, success, failure)

results matching ""

    No results matching ""