use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method getMembersFromContactGroup.
/**
* Sends a request to get the contacts for a group, identified by it's contactGroupId.
*
* <p>Contacts for a user can be grouped together. Such a group is called a contact group.</p>
*
* @param contactGroupId the contact group id
* @return {@link ChannelFeed}. User {@link ChannelFeed#getGroupUsers()} to get the contacts.
*/
@Nullable
public ChannelFeed getMembersFromContactGroup(@Nullable String contactGroupId) {
String response;
if (!TextUtils.isEmpty(contactGroupId)) {
String url = String.format(getMembersFromContactGroupUrl(), contactGroupId);
response = httpRequestUtils.getResponse(url, "application/json", "application/json");
ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(response, ChannelFeedApiResponse.class);
if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
return channelFeed;
}
}
return null;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method getChannelInfoByParameters.
// Cleanup: private
public ChannelFeed getChannelInfoByParameters(String parameters) {
String response = "";
try {
response = httpRequestUtils.getResponse(getChannelInfoUrl() + "?" + parameters, "application/json", "application/json");
ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(response, ChannelFeedApiResponse.class);
Utils.printLog(context, TAG, "Channel info response is :" + response);
if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
return channelFeed;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method createChannel_withError.
@Test
public void createChannel_withError() {
ChannelInfo channelInfo = new ChannelInfo();
try {
ChannelFeedApiResponse apiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(MockConstants.channelErrorResponse, ChannelFeedApiResponse.class);
when(channelClientService.createChannelWithResponse(channelInfo)).thenReturn(apiResponse);
AlResponse response = channelService.createChannel(channelInfo);
assertFalse(response.isSuccess());
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method createChannel_withSuccess.
@Test
public void createChannel_withSuccess() {
ChannelInfo channelInfo = new ChannelInfo();
try {
ChannelFeedApiResponse apiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(MockConstants.channelSuccessResponse, ChannelFeedApiResponse.class);
when(channelClientService.createChannelWithResponse(channelInfo)).thenReturn(apiResponse);
AlResponse response = channelService.createChannel(channelInfo);
assertTrue(response.isSuccess() && (response.getResponse() instanceof Channel));
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ALGroupInfoTask method getChannelInfoByParameters.
// Cleanup: private
public ChannelModel getChannelInfoByParameters(String parameters) {
String response = "";
HttpRequestUtils httpRequestUtils = new HttpRequestUtils(context);
ChannelModel model = new ChannelModel();
try {
response = httpRequestUtils.getResponse(getChannelInfoUrl() + "?" + parameters, "application/json", "application/json");
ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(response, ChannelFeedApiResponse.class);
Utils.printLog(context, "ChannelInfoTask", "Channel info response is :" + response);
if (channelFeedApiResponse != null) {
model.setChannelFeedApiResponse(channelFeedApiResponse);
}
} catch (Exception e) {
model.setException(e);
e.printStackTrace();
}
return model;
}
Aggregations