Search in sources :

Example 11 with ApiResponse

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);
}
Also used : MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Test(org.junit.Test)

Example 12 with ApiResponse

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());
}
Also used : MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Test(org.junit.Test)

Example 13 with ApiResponse

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;
}
Also used : ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException)

Example 14 with ApiResponse

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;
}
Also used : ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Example 15 with 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;
}
Also used : MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) JSONException(org.json.JSONException)

Aggregations

ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)54 SyncBlockUserApiResponse (com.applozic.mobicomkit.feed.SyncBlockUserApiResponse)23 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)22 JSONException (org.json.JSONException)19 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)16 RegisteredUsersApiResponse (com.applozic.mobicomkit.feed.RegisteredUsersApiResponse)16 Test (org.junit.Test)14 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)12 MockedConstants.userDetailsApiResponse (com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 Nullable (androidx.annotation.Nullable)8 Contact (com.applozic.mobicommons.people.contact.Contact)8 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)3 ArrayList (java.util.ArrayList)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ProgressDialog (android.app.ProgressDialog)2 Toast (android.widget.Toast)2 UserBlockTask (com.applozic.mobicomkit.api.account.user.UserBlockTask)2 MuteNotificationAsync (com.applozic.mobicomkit.api.notification.MuteNotificationAsync)2 MuteNotificationRequest (com.applozic.mobicomkit.api.notification.MuteNotificationRequest)2