use of com.fanap.podchat.model.ResultRemoveContact in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method removeContact.
/**
* Remove contact with the user id
*
* @param userId id of the user that we want to remove from contact list
*/
@Deprecated
public String removeContact(long userId) {
String uniqueId = generateUniqueId();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("uniqueId", uniqueId);
jsonObject.addProperty("id", userId);
jsonObject.addProperty("tokenIssuer", 1);
showLog("SEND_REMOVE_CONTACT", getJsonForLog(jsonObject));
Observable<Response<ContactRemove>> removeContactObservable;
if (chatReady) {
if (Util.isNullOrEmpty(getTypeCode())) {
removeContactObservable = contactApi.removeContact(getToken(), 1, userId);
} else {
removeContactObservable = contactApi.removeContact(getToken(), 1, userId, getTypeCode());
}
removeContactObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(response -> {
Log.d("MTAG", response.raw().toString());
if (response.body() != null && response.isSuccessful()) {
ContactRemove contactRemove = response.body();
if (!contactRemove.getHasError()) {
ChatResponse<ResultRemoveContact> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(uniqueId);
ResultRemoveContact resultRemoveContact = new ResultRemoveContact();
resultRemoveContact.setResult(contactRemove.isResult());
chatResponse.setResult(resultRemoveContact);
String json = gson.toJson(chatResponse);
if (cache) {
dataSource.deleteContactById(userId);
// messageDatabaseHelper.deleteContactById(userId);
}
listenerManager.callOnRemoveContact(json, chatResponse);
showLog("RECEIVED_REMOVE_CONTACT", json);
} else {
captureError(contactRemove.getErrorMessage(), contactRemove.getErrorCode(), uniqueId);
}
}
}, (Throwable throwable) -> captureError(throwable.getMessage(), ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION, uniqueId, throwable));
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
return uniqueId;
}
use of com.fanap.podchat.model.ResultRemoveContact in project pod-chat-android-sdk by FanapSoft.
the class ContactManager method prepareRemoveContactResponse.
public static ChatResponse<ResultRemoveContact> prepareRemoveContactResponse(ChatMessage chatMessage) {
ChatResponse<ResultRemoveContact> response = new ChatResponse<>();
ResultRemoveContact result = App.getGson().fromJson(chatMessage.getContent(), ResultRemoveContact.class);
response.setResult(result);
response.setUniqueId(chatMessage.getUniqueId());
return response;
}
use of com.fanap.podchat.model.ResultRemoveContact in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method removeContact.
@Test
public void removeContact() {
chatListeners = new ChatListener() {
@Override
public void onRemoveContact(String content, ChatResponse<ResultRemoveContact> response) {
System.out.println("Contact Removed: " + content);
contactContent = content;
resumeProcess();
}
@Override
public void onError(String content, ErrorOutPut error) {
System.out.println("onError: " + content);
contactContent = content;
resumeProcess();
}
};
chat.addListener(chatListeners);
chat.removeContact(18479);
pauseProcess();
System.out.println("Received contact: " + contactContent);
}
Aggregations