Search in sources :

Example 1 with ChannelFeedApiResponse

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;
}
Also used : SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) Nullable(androidx.annotation.Nullable)

Example 2 with ChannelFeedApiResponse

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;
}
Also used : SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) JSONException(org.json.JSONException)

Example 3 with ChannelFeedApiResponse

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();
    }
}
Also used : ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo) AlResponse(com.applozic.mobicomkit.feed.AlResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) Test(org.junit.Test)

Example 4 with ChannelFeedApiResponse

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();
    }
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo) AlResponse(com.applozic.mobicomkit.feed.AlResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) Test(org.junit.Test)

Example 5 with ChannelFeedApiResponse

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;
}
Also used : HttpRequestUtils(com.applozic.mobicomkit.api.HttpRequestUtils) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse)

Aggregations

ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)13 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)9 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)8 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)4 AlResponse (com.applozic.mobicomkit.feed.AlResponse)4 Channel (com.applozic.mobicommons.people.channel.Channel)4 Nullable (androidx.annotation.Nullable)3 ChannelInfo (com.applozic.mobicomkit.api.people.ChannelInfo)3 JSONException (org.json.JSONException)2 Test (org.junit.Test)2 SuppressLint (android.annotation.SuppressLint)1 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SpannableString (android.text.SpannableString)1 HttpRequestUtils (com.applozic.mobicomkit.api.HttpRequestUtils)1 ErrorResponseFeed (com.applozic.mobicomkit.feed.ErrorResponseFeed)1 AlChannelCreateAsyncTask (com.applozic.mobicomkit.uiwidgets.async.AlChannelCreateAsyncTask)1 Contact (com.applozic.mobicommons.people.contact.Contact)1