use of com.zoho.livechat.android.listeners.ConversationListener in project SalesIQ-Mobilisten-ReactNative by zoho.
the class RNZohoSalesIQ method getChatsWithFilter.
@ReactMethod
public void getChatsWithFilter(@NonNull final String filter, @NonNull final Callback listCallback) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
try {
if (isValidFilterName(filter)) {
ConversationType filterName = getFilterName(filter);
ZohoSalesIQ.Chat.getList(filterName, new ConversationListener() {
@Override
public void onSuccess(ArrayList<VisitorChat> arrayList) {
if (arrayList != null) {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < arrayList.size(); i++) {
VisitorChat chat = arrayList.get(i);
WritableMap visitorMap = getChatMapObject(chat);
array.pushMap(visitorMap);
}
listCallback.invoke(null, array);
}
}
@Override
public void onFailure(int code, String message) {
WritableMap errorMap = new WritableNativeMap();
// No I18N
errorMap.putInt("code", code);
// No I18N
errorMap.putString("message", message);
listCallback.invoke(errorMap, null);
}
});
} else {
WritableMap errorMap = new WritableNativeMap();
// No I18N
errorMap.putInt("code", INVALID_FILTER_CODE);
// No I18N
errorMap.putString("message", INVALID_FILTER_TYPE);
listCallback.invoke(errorMap, null);
}
} catch (Exception e) {
LiveChatUtil.log(e);
}
}
});
}
use of com.zoho.livechat.android.listeners.ConversationListener in project SalesIQ-Mobilisten-ReactNative by zoho.
the class RNZohoSalesIQ method getChats.
@ReactMethod
public void getChats(@NonNull final Callback listCallback) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
ZohoSalesIQ.Chat.getList(new ConversationListener() {
@Override
public void onSuccess(ArrayList<VisitorChat> arrayList) {
if (arrayList != null) {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < arrayList.size(); i++) {
VisitorChat chat = arrayList.get(i);
WritableMap visitorMap = getChatMapObject(chat);
array.pushMap(visitorMap);
}
listCallback.invoke(null, array);
}
}
@Override
public void onFailure(int code, String message) {
WritableMap errorMap = new WritableNativeMap();
// No I18N
errorMap.putInt("code", code);
// No I18N
errorMap.putString("message", message);
listCallback.invoke(errorMap, null);
}
});
}
});
}
Aggregations