use of com.zoho.livechat.android.listeners.DepartmentListener in project SalesIQ-Mobilisten-ReactNative by zoho.
the class RNZohoSalesIQ method getDepartments.
@ReactMethod
public void getDepartments(@NonNull final Callback departmentCallback) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
ZohoSalesIQ.Chat.getDepartments(new DepartmentListener() {
@Override
public void onSuccess(ArrayList<SIQDepartment> departmentList) {
if (departmentList != null) {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < departmentList.size(); i++) {
SIQDepartment department = departmentList.get(i);
WritableMap departmentMap = getDepartmentMapObject(department);
array.pushMap(departmentMap);
}
departmentCallback.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);
departmentCallback.invoke(errorMap, null);
}
});
}
});
}
Aggregations