Search in sources :

Example 1 with FAQCategoryListener

use of com.zoho.livechat.android.listeners.FAQCategoryListener in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getCategories.

@ReactMethod
public void getCategories(@NonNull final Callback categoryCallback) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        public void run() {
            ZohoSalesIQ.FAQ.getCategories(new FAQCategoryListener() {

                @Override
                public void onSuccess(ArrayList<SalesIQArticleCategory> categoryList) {
                    if (categoryList != null) {
                        WritableArray array = new WritableNativeArray();
                        for (int i = 0; i < categoryList.size(); i++) {
                            SalesIQArticleCategory category = categoryList.get(i);
                            WritableMap categoryMap = new WritableNativeMap();
                            // No I18N
                            categoryMap.putString("id", category.getCategoryid());
                            // No I18N
                            categoryMap.putString("name", category.getCategoryname());
                            // No I18N
                            categoryMap.putInt("articleCount", category.getCount());
                            array.pushMap(categoryMap);
                        }
                        categoryCallback.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);
                    categoryCallback.invoke(errorMap, null);
                }
            });
        }
    });
}
Also used : FAQCategoryListener(com.zoho.livechat.android.listeners.FAQCategoryListener) WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) SalesIQArticleCategory(com.zoho.livechat.android.models.SalesIQArticleCategory) 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 FAQCategoryListener (com.zoho.livechat.android.listeners.FAQCategoryListener)1 SalesIQArticleCategory (com.zoho.livechat.android.models.SalesIQArticleCategory)1 ArrayList (java.util.ArrayList)1