Search in sources :

Example 51 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ChannelClientService method muteNotification.

/**
 * Send a mute notification request for a channel to the server.
 *
 * <p>Request parameters can be passed inside the {@link MuteNotificationRequest} object.
 * Pass non-null/non-zero values for either {@link MuteNotificationRequest#setClientGroupId(String)}
 * or {@link MuteNotificationRequest#setId(Integer)}.
 * See {@link MuteNotificationRequest} for more details.</p>
 *
 * @param muteNotificationRequest the mute notification parameter object
 * @return the {@link ApiResponse} for the request
 */
public ApiResponse muteNotification(@NonNull MuteNotificationRequest muteNotificationRequest) {
    ApiResponse apiResponse = null;
    try {
        if (muteNotificationRequest.isRequestValid()) {
            String requestJson = GsonUtils.getJsonFromObject(muteNotificationRequest, MuteNotificationRequest.class);
            String response = httpRequestUtils.postData(getMuteChannelUrl(), "application/json", "application/json", requestJson);
            apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
            if (apiResponse != null) {
                Utils.printLog(context, TAG, "Mute notification response: " + apiResponse.getStatus());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return apiResponse;
}
Also used : MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) JSONException(org.json.JSONException)

Example 52 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ChannelService method addMemberToChannelWithResponseProcess.

/**
 * Adds a given user to a channel.
 *
 * <p>Data for this addition is updated both remotely and locally.</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
 */
@Nullable
public ApiResponse addMemberToChannelWithResponseProcess(@Nullable Integer channelKey, @Nullable 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) Nullable(androidx.annotation.Nullable)

Example 53 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ChannelService method deleteChannel.

// deprecated >>>
/**
 * @deprecated Use {@link #processChannelDeleteConversation(Channel, Context)} instead.
 *
 * @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 success (ignore case) or failure (ignore case)
 */
@Deprecated
public String deleteChannel(Integer channelKey, boolean updateClientGroupId, boolean resetCount) {
    ApiResponse apiResponse = channelClientService.deleteChannel(channelKey, updateClientGroupId, resetCount);
    if (apiResponse != null && apiResponse.isSuccess()) {
        channelDatabaseService.deleteChannel(channelKey);
        channelDatabaseService.deleteChannelUserMappers(channelKey);
        BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), null, channelKey, apiResponse.getStatus());
        return apiResponse.getStatus();
    } else {
        return null;
    }
}
Also used : ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Example 54 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ChannelService method addMemberToChannelProcess.

/**
 * @deprecated Use {@link #addMemberToChannelWithResponseProcess(Integer, String)} instead.
 */
@Deprecated
public String addMemberToChannelProcess(Integer channelKey, String userId) {
    if (channelKey == null && TextUtils.isEmpty(userId)) {
        return "";
    }
    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.getStatus();
}
Also used : ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

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