Search in sources :

Example 1 with SalesIQArticle

use of com.zoho.livechat.android.models.SalesIQArticle in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getArticles.

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

        public void run() {
            ZohoSalesIQ.FAQ.getArticles(new FAQListener() {

                @Override
                public void onSuccess(ArrayList<SalesIQArticle> articlesList) {
                    if (articlesList != null) {
                        WritableArray array = new WritableNativeArray();
                        for (int i = 0; i < articlesList.size(); i++) {
                            SalesIQArticle article = articlesList.get(i);
                            WritableMap articleMap = getArticleMapObject(article);
                            array.pushMap(articleMap);
                        }
                        articlesCallback.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);
                    articlesCallback.invoke(errorMap, null);
                }
            });
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) FAQListener(com.zoho.livechat.android.listeners.FAQListener) SalesIQFAQListener(com.zoho.livechat.android.listeners.SalesIQFAQListener) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) SalesIQArticle(com.zoho.livechat.android.models.SalesIQArticle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 2 with SalesIQArticle

use of com.zoho.livechat.android.models.SalesIQArticle in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getArticlesWithCategoryID.

@ReactMethod
public void getArticlesWithCategoryID(@NonNull final String categoryId, @NonNull final Callback articlesCallback) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        public void run() {
            ZohoSalesIQ.FAQ.getArticles(categoryId, new FAQListener() {

                @Override
                public void onSuccess(ArrayList<SalesIQArticle> articlesList) {
                    if (articlesList != null) {
                        WritableArray array = new WritableNativeArray();
                        for (int i = 0; i < articlesList.size(); i++) {
                            SalesIQArticle article = articlesList.get(i);
                            WritableMap articleMap = getArticleMapObject(article);
                            array.pushMap(articleMap);
                        }
                        articlesCallback.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);
                    articlesCallback.invoke(errorMap, null);
                }
            });
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) FAQListener(com.zoho.livechat.android.listeners.FAQListener) SalesIQFAQListener(com.zoho.livechat.android.listeners.SalesIQFAQListener) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) SalesIQArticle(com.zoho.livechat.android.models.SalesIQArticle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

Handler (android.os.Handler)2 ReactMethod (com.facebook.react.bridge.ReactMethod)2 WritableArray (com.facebook.react.bridge.WritableArray)2 WritableMap (com.facebook.react.bridge.WritableMap)2 WritableNativeArray (com.facebook.react.bridge.WritableNativeArray)2 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)2 FAQListener (com.zoho.livechat.android.listeners.FAQListener)2 SalesIQFAQListener (com.zoho.livechat.android.listeners.SalesIQFAQListener)2 SalesIQArticle (com.zoho.livechat.android.models.SalesIQArticle)2 ArrayList (java.util.ArrayList)2