use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method addMemberToMultipleChannels.
// Cleanup: private
public synchronized ApiResponse addMemberToMultipleChannels(Set<String> clientGroupIds, Set<Integer> channelKeys, String userId) {
ApiResponse apiResponse = null;
try {
if (!TextUtils.isEmpty(userId)) {
String parameters = "";
if (clientGroupIds != null && clientGroupIds.size() > 0) {
for (String clientGroupId : clientGroupIds) {
parameters += CLIENT_GROUPIDs + "=" + URLEncoder.encode(clientGroupId, "UTF-8") + "&";
}
} else {
for (Integer channelKey : channelKeys) {
parameters += GROUPIDS + "=" + channelKey + "&";
}
}
String url = getAddMemberToMultipleChannelsUrl() + "?" + parameters + USER_ID + "=" + URLEncoder.encode(userId, "UTF-8");
String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Channel add 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 removeMemberFromContactGroupOfType.
/**
* Sends a request to remove a user from a contact group with the given group type and group id.
*
* <p>Contacts for a user can be grouped together. Such a group is called a contact group.
* Groups can have group types.</p>
*
* @param groupName the id of the contact group. apologies for the bad naming
* @param groupType the group type
* @param userId id of contact to remove
* @return the {@link ApiResponse} for the request
*/
@Nullable
public ApiResponse removeMemberFromContactGroupOfType(@Nullable String groupName, @Nullable String groupType, @Nullable String userId) {
String response;
String parameters;
String url;
if (!TextUtils.isEmpty(groupName) && !TextUtils.isEmpty(userId)) {
if (!TextUtils.isEmpty(groupType)) {
parameters = "?" + USER_ID + "=" + userId + "&" + GROUPTYPE + "=" + groupType;
} else {
parameters = "?" + USER_ID + "=" + userId;
}
url = String.format(getRemoveMemberFromGroupTypeUrl() + parameters, groupName);
try {
response = httpRequestUtils.getResponse(url, "application/json", "application/json");
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Remove memeber from Group of Type 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 removeMemberFromChannel.
// Cleanup: private
public synchronized ApiResponse removeMemberFromChannel(String clientGroupId, Integer channelKey, String userId) {
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(parameters) && !TextUtils.isEmpty(userId)) {
String url = getRemoveMemberUrl() + "?" + parameters + "&" + USER_ID + "=" + URLEncoder.encode(userId, "UTF-8");
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 member 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 addMemberToContactGroupOfType.
/**
* Sends a request to add a user/s to a contact group with the given group type and given id.
*
* <p>Contacts for a user can be grouped together. Such a group is called a contact group.
* Groups can have group types.</p>
*
* @param contactGroupId the id of the contact
* @param groupType the group type
* @param contactGroupMemberList list of userIds of contacts to add in group
* @return the {@link ApiResponse} for the request
*/
@Nullable
public ApiResponse addMemberToContactGroupOfType(@Nullable String contactGroupId, @Nullable String groupType, @Nullable List<String> contactGroupMemberList) {
String response;
if (!TextUtils.isEmpty(contactGroupId) && !TextUtils.isEmpty(groupType) && contactGroupMemberList != null) {
String url = String.format(addMembersToContactGroupOfTypeUrl(), contactGroupId);
ApplozicAddMemberOfGroupType applozicAddMemberOfGroupType = new ApplozicAddMemberOfGroupType();
applozicAddMemberOfGroupType.setGroupMemberList(contactGroupMemberList);
applozicAddMemberOfGroupType.setType(groupType);
String jsonFromObject = GsonUtils.getJsonFromObject(applozicAddMemberOfGroupType, ApplozicAddMemberOfGroupType.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 MessageClientService method updateMessageMetadata.
// Cleanup: default
public ApiResponse updateMessageMetadata(String key, Map<String, String> metadata) {
MessageMetadataUpdate metadataUpdate = new MessageMetadataUpdate();
metadataUpdate.setKey(key);
metadataUpdate.setMetadata(metadata);
final String jsonFromObject = GsonUtils.getJsonFromObject(metadataUpdate, MessageMetadataUpdate.class);
Utils.printLog(context, TAG, "Sending message to server: " + jsonFromObject);
try {
String response = httpRequestUtils.postData(getMessageMetadataUpdateUrl(), "application/json", "application/json", jsonFromObject);
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Message metadata update response : " + apiResponse.toString());
return apiResponse;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations