6.2 Get My Groups

The getMyGroups method returns all the groups, both public and private, an employee is member of. The Groups are returned as an ArrayList of HashMap through success callback, where each map represents a group with keys - groupKey, id, name, type.

Method parameters :
  • success: Success block to be executed after employee groups are successfully retrieved.
  • failure: Failure block to be executed if employee groups could not be retrieved, returns BayunError.

Java
Kotlin
ArrayList<HashMap<String, String>> myGroupsArray;

// Callbacks to get User's joined Groups
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Get my groups call successful.");
        myGroupsArray = (ArrayList<HashMap<String, String>>)message.getData().getSerializable("BayunMyGroupsArray");
        for (HashMap<String, String> group: myGroupsArray) {
            Log.d(TAG, "groupKey: " + group.get("groupKey"));
            Log.d(TAG, "id: " + group.get("id"));
            Log.d(TAG, "name: " + group.get("name"));
            Log.d(TAG, "type: " + group.get("type"));
        }
        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.getMyGroups(success, failure);

var myGroupsArray: ArrayList<HashMap<String, String>>

// Callbacks to get User's joined Groups
val success = Handler.Callback {
    Log.d(TAG, "Get my groups call successful.")

    myGroupsArray = it.data.getSerializable("BayunMyGroupsArray")
                as ArrayList<HashMap<String, String>>
    for (group in myGroupsArray) {
        Log.d(TAG, "groupKey: " + group["groupKey"])
        Log.d(TAG, "id: " + group["id"])
        Log.d(TAG, "name: " + group["name"])
        Log.d(TAG, "type: " + group["type"])
    }

    false
}

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

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

    }
    false
}

bayunCore.getMyGroups(success, failure)

results matching ""

    No results matching ""