6.6 Add Group Member
The addGroupMember
method is used to add a new member to the Group. The member to be added in the group may belong to a different company, provided that the company and the member must already be registered with Bayun. Any existing member of the group can add a new member. The developer can enforce stricter access-mechanisms on top if desired (e.g. only group-owner or group-admin is allowed to add new members).
Method parameters :
- parameters : Hashmap mapping groupId and the companyEmployeeId, companyName of the employee you want to remove from the group.
- success: Success block to be executed after member is added to the group.
- failure: Failure block to be executed if member could not be added to the group, returns BayunError.
Java
Kotlin
String companyEmployeeId = "companyEmployeeId";
String companyName = "companyName";
String groupId = "groupId";
HashMap<String, String> parameters = new HashMap<>();
parameters.put("companyEmployeeId", companyEmployeeId);
parameters.put("companyName", companyName);
parameters.put("groupId", groupId);
// Callbacks to adding a new member to a group.
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
Log.d(TAG, "Member added successfully.");
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_MEMBER_EXISTS_IN_GROUP)) {
}
return false;
}
};
bayunCore.addGroupMember(parameters, success, failure);
val companyEmployeeId = "companyEmployeeId"
val companyName = "companyName"
val groupId = "groupId"
val parameters = HashMap<String, String>()
parameters["companyEmployeeId"] = companyEmployeeId
parameters["companyName"] = companyName
parameters["groupId"] = groupId
// Callbacks to adding a new member to a group.
val success = Handler.Callback {
Log.d(TAG, "Member added successfully.")
false
}
val failure = Handler.Callback {
val error: String = it.data.getString("BayunError", "")
if (error == BayunError.ERROR_INTERNET_CONNECTION) {
} else if (error == BayunError.ERROR_MEMBER_EXISTS_IN_GROUP) {
}
false
}
bayunCore.addGroupMember(parameters, success, failure)