use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserServiceTest method updateUserDisplayNameSuccess.
@Test
public void updateUserDisplayNameSuccess() {
// Note: return value from userService.updateUserDisplayName() is not used
ApiResponse apiResponse = new ApiResponse();
apiResponse.setStatus("success");
Mockito.when(userClientService.updateUserDisplayName(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(apiResponse);
ApiResponse actualApiResponse = userService.updateUserDisplayName(testUserId, "Display Name");
Mockito.verify(appContactService, Mockito.times(1)).updateMetadataKeyValueForUserId(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
Truth.assertThat(apiResponse).isEqualTo(actualApiResponse);
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserServiceTest method processUserBlockFailureNull.
@Test
public void processUserBlockFailureNull() {
Mockito.when(userClientService.userBlock(testUserId, true)).thenReturn(null);
ApiResponse actualFailureApiResponse = userService.processUserBlock(testUserId, true);
Truth.assertThat(actualFailureApiResponse).isNull();
Mockito.verify(appContactService, Mockito.never()).updateUserBlocked(ArgumentMatchers.anyString(), ArgumentMatchers.anyBoolean());
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationService method getConversationSearchList.
// Cleanup: private
public List<Message> getConversationSearchList(String searchString) throws Exception {
String response = messageClientService.getMessageSearchResult(searchString);
ApiResponse<AlConversationResponse> apiResponse = (ApiResponse<AlConversationResponse>) GsonUtils.getObjectFromJson(response, new TypeToken<ApiResponse<AlConversationResponse>>() {
}.getType());
if (apiResponse != null) {
if (apiResponse.isSuccess()) {
processMessageSearchResult(apiResponse.getResponse());
return Arrays.asList(apiResponse.getResponse().getMessage());
} else if (apiResponse.getErrorResponse() != null) {
throw new ApplozicException(GsonUtils.getJsonFromObject(apiResponse.getErrorResponse(), List.class));
}
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method addMemberToChannelProcessWithResponse.
/**
* @deprecated Duplicate. Use {@link #addMemberToChannelWithResponseProcess(Integer, String)} instead.
*
* <p>Adds a given user to a channel.</p>
*
* <p>The local database is also updated.</p>
*
* @param channelKey the channel key (to identify the channel)
* @param userId the id of the user to add to the channel
* @return the {@link ApiResponse} for the request
*/
@Deprecated
public ApiResponse addMemberToChannelProcessWithResponse(Integer channelKey, String userId) {
if (channelKey == null && TextUtils.isEmpty(userId)) {
return null;
}
ApiResponse apiResponse = channelClientService.addMemberToChannel(channelKey, userId);
if (apiResponse == null) {
return null;
}
if (apiResponse.isSuccess()) {
ChannelUserMapper channelUserMapper = new ChannelUserMapper(channelKey, userId);
channelDatabaseService.addChannelUserMapper(channelUserMapper);
}
return apiResponse;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method deleteChannel.
/**
* Sends a request to the server to delete the channel with the given channel key.
*
* @param channelKey the channel key
* @param updateClientGroupId pass true if you want the client group id to be updated
* @param resetCount pass true if you want to reset the unread count for the channel
* @return the {@link ApiResponse} for the request
*/
public synchronized ApiResponse deleteChannel(Integer channelKey, boolean updateClientGroupId, boolean resetCount) {
try {
if (channelKey != null) {
StringBuilder urlBuilder = new StringBuilder(getChannelDeleteUrl());
urlBuilder.append("?").append(GROUP_ID).append("=").append(URLEncoder.encode(String.valueOf(channelKey), "UTF-8"));
if (updateClientGroupId) {
urlBuilder.append("&").append(UPDATE_CLIENT_GROUP_ID).append("=").append("true");
}
if (resetCount) {
urlBuilder.append("&").append(RESET_UNREAD_COUNT).append("=").append("true");
}
String response = httpRequestUtils.getResponse(urlBuilder.toString(), "application/json", "application/json");
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null) {
Utils.printLog(context, TAG, "Channel delete call response: " + apiResponse.getStatus());
}
return apiResponse;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations