use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method addMemberToContactGroup.
/**
* Sends a request to add a user/s to a contact group with the given id.
*
* <p>Contacts for a user can be grouped together. Such a group is called a contact group.</p>
*
* @param contactGroupId the id of the contact
* @param contactGroupMemberList list of userIds of contacts to add in group
* @return the {@link ApiResponse} for the request
*/
public ApiResponse addMemberToContactGroup(String contactGroupId, List<String> contactGroupMemberList) {
String response;
if (!TextUtils.isEmpty(contactGroupId) && contactGroupMemberList != null) {
String url = String.format(addMembersToContactGroupUrl(), contactGroupId);
Utils.printLog(context, TAG, url);
String jsonFromObject = GsonUtils.getJsonFromObject(contactGroupMemberList, List.class);
Utils.printLog(context, TAG, "Sending json:" + jsonFromObject);
try {
response = httpRequestUtils.postData(url, "application/json", "application/json", jsonFromObject);
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Add Member To Contact Group Response: " + apiResponse.getStatus());
return apiResponse;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method leaveMemberFromChannel.
// Cleanup: private
public synchronized ApiResponse leaveMemberFromChannel(String clientGroupId, Integer channelKey) {
ApiResponse apiResponse = null;
try {
String parameters = "";
if (!TextUtils.isEmpty(clientGroupId)) {
parameters = CLIENT_GROUPID + "=" + URLEncoder.encode(clientGroupId, "UTF-8");
} else {
parameters = GROUP_ID + "=" + channelKey;
}
if (!TextUtils.isEmpty(clientGroupId) || (channelKey != null && channelKey != 0)) {
String url = getChannelLeftUrl() + "?" + parameters;
String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Channel leave member call response: " + apiResponse.getStatus());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method updateChannel.
/**
* Sends a request to the server to update channel details.
*
* <p>See {@link GroupInfoUpdate} for details on parameters.</p>
*
* @param groupInfoUpdate the object used to store data to update
* @return the {@link ApiResponse} for the request
*/
@Nullable
public synchronized ApiResponse updateChannel(@Nullable GroupInfoUpdate groupInfoUpdate) {
ApiResponse apiResponse = null;
try {
if (groupInfoUpdate != null) {
String channelNameUpdateJson = GsonUtils.getJsonFromObject(groupInfoUpdate, GroupInfoUpdate.class);
String response = httpRequestUtils.postData(getChannelUpdateUrl(), "application/json", "application/json", channelNameUpdateJson);
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Update Channel response: " + apiResponse.getStatus());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method removeMembersFromMultipleChannels.
private ApiResponse removeMembersFromMultipleChannels(Set<String> clientGroupIds, Set<Integer> channelKeys, Set<String> userIds) {
ApiResponse apiResponse = null;
try {
if (userIds != null && userIds.size() > 0) {
String parameters = "";
if (clientGroupIds != null && clientGroupIds.size() > 0) {
for (String clientGroupId : clientGroupIds) {
parameters += CLIENT_GROUPIDs + "=" + URLEncoder.encode(clientGroupId, "UTF-8") + "&";
}
} else if (channelKeys != null && channelKeys.size() > 0) {
for (Integer channelKey : channelKeys) {
parameters += GROUPIDS + "=" + channelKey + "&";
}
}
for (String userId : userIds) {
parameters += USER_ID + "=" + URLEncoder.encode(userId, "UTF-8") + "&";
}
String url = getRemoveMembersFromMultipChannels() + "?" + parameters;
String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Channel remove members from channels response: " + "" + apiResponse.getStatus());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method addMemberToChannel.
// Cleanup: private
public synchronized ApiResponse addMemberToChannel(@Nullable String clientGroupId, @Nullable Integer channelKey, @Nullable String userId) {
try {
String parameters = "";
if (!TextUtils.isEmpty(clientGroupId)) {
parameters = CLIENT_GROUPID + "=" + URLEncoder.encode(clientGroupId, "UTF-8");
} else {
parameters = GROUP_ID + "=" + channelKey;
}
if (!TextUtils.isEmpty(parameters) && !TextUtils.isEmpty(userId)) {
String url = getAddMemberToGroup() + "?" + parameters + "&" + USER_ID + "=" + URLEncoder.encode(userId, "UTF-8");
String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Channel add member call response: " + apiResponse.getStatus());
}
return apiResponse;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations