Search in sources :

Example 1 with SIQDepartment

use of com.zoho.livechat.android.SIQDepartment 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);
                }
            });
        }
    });
}
Also used : SIQDepartment(com.zoho.livechat.android.SIQDepartment) WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) DepartmentListener(com.zoho.livechat.android.listeners.DepartmentListener) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

Handler (android.os.Handler)1 ReactMethod (com.facebook.react.bridge.ReactMethod)1 WritableArray (com.facebook.react.bridge.WritableArray)1 WritableMap (com.facebook.react.bridge.WritableMap)1 WritableNativeArray (com.facebook.react.bridge.WritableNativeArray)1 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)1 SIQDepartment (com.zoho.livechat.android.SIQDepartment)1 DepartmentListener (com.zoho.livechat.android.listeners.DepartmentListener)1 ArrayList (java.util.ArrayList)1