use of com.applozic.mobicomkit.feed.AlResponse 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.AlResponse 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.AlResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createGroupOfTwoWithResponse.
/**
* Internal. Group-of-two channels are implemented in the UI. You will not need them.
*
* <p>Create a {@link Channel.GroupType#GROUPOFTWO} channel.</p>
*
* <p>A group-of-two type channel is implemented in the UI to look like a 1-to-1 chat.
* It is meant to have two members only.</p>
*
* @param channelInfo the channel info that will be used to create the channel
* @return the {@link AlResponse} from the server
*/
public AlResponse createGroupOfTwoWithResponse(ChannelInfo channelInfo) {
if (channelInfo == null) {
return null;
}
AlResponse alResponse = new AlResponse();
if (!TextUtils.isEmpty(channelInfo.getClientGroupId())) {
Channel channel = channelDatabaseService.getChannelByClientGroupId(channelInfo.getClientGroupId());
if (channel != null) {
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(channel);
} else {
ChannelFeedApiResponse channelFeedApiResponse = channelClientService.createChannelWithResponse(channelInfo);
if (channelFeedApiResponse == null) {
alResponse.setStatus(AlResponse.ERROR);
} else {
if (channelFeedApiResponse.isSuccess()) {
ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, true);
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(getChannel(channelFeed));
}
} else {
ChannelFeed channelFeed = channelClientService.getChannelInfo(channelInfo.getClientGroupId());
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, false);
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(getChannel(channelFeed));
}
}
}
}
}
return alResponse;
}
use of com.applozic.mobicomkit.feed.AlResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createChannel.
/**
* @deprecated {@link AlResponse} is not longer used. It will be replaced by {@link ApiResponse}.
*
* Use {@link ChannelService#createChannelWithResponse(ChannelInfo)} instead.
*/
@Deprecated
public synchronized AlResponse createChannel(final ChannelInfo channelInfo) {
if (channelInfo == null) {
return null;
}
AlResponse alResponse = new AlResponse();
ChannelFeedApiResponse channelFeedResponse = null;
try {
channelFeedResponse = channelClientService.createChannelWithResponse(channelInfo);
if (channelFeedResponse == null) {
return null;
}
if (channelFeedResponse.isSuccess()) {
alResponse.setStatus(AlResponse.SUCCESS);
ChannelFeed channelFeed = channelFeedResponse.getResponse();
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, true);
alResponse.setResponse(getChannel(channelFeed));
}
} else {
alResponse.setStatus(AlResponse.ERROR);
alResponse.setResponse(channelFeedResponse.getErrorResponse());
}
} catch (Exception e) {
alResponse.setStatus(AlResponse.ERROR);
alResponse.setException(e);
}
return alResponse;
}
use of com.applozic.mobicomkit.feed.AlResponse in project Applozic-Android-SDK by AppLozic.
the class ApplozicChannelCreateTask method doInBackground.
@Override
protected Boolean doInBackground() {
try {
if (!TextUtils.isEmpty(groupName) && groupName.trim().length() != 0 && groupMemberList != null && groupMemberList.size() > 0) {
channelInfo = new ChannelInfo(groupName.trim(), groupMemberList, groupImageLink);
if (!TextUtils.isEmpty(clientGroupId)) {
channelInfo.setClientGroupId(clientGroupId);
}
channelInfo.setType(type);
AlResponse alResponse = channelService.createChannel(channelInfo);
channel = (Channel) channelService.createChannel(channelInfo).getResponse();
return channel != null;
}
return false;
} catch (Exception e) {
e.printStackTrace();
exception = e;
return false;
}
}
Aggregations