private void GetModelsResponse(RESTConnector.Request req, RESTConnector.Response resp)
        {
            TranslationModels models = new TranslationModels();

            if (resp.Success)
            {
                try
                {
                    fsData   data = null;
                    fsResult r    = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    object obj = models;
                    r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Natural Language Classifier", "GetModels Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (((GetModelsReq)req).Callback != null)
            {
                ((GetModelsReq)req).Callback(resp.Success ? models : null);
            }
        }
        private void GetModelsResponse(RESTConnector.Request req, RESTConnector.Response resp)
        {
            TranslationModels           result     = new TranslationModels();
            fsData                      data       = null;
            Dictionary <string, object> customData = ((GetModelsReq)req).CustomData;

            if (resp.Success)
            {
                try
                {
                    fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    object obj = result;
                    r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    customData.Add("json", data);
                }
                catch (Exception e)
                {
                    Log.Error("LanguageTranslation.GetModelsResponse()", "GetModels Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (resp.Success)
            {
                if (((GetModelsReq)req).SuccessCallback != null)
                {
                    ((GetModelsReq)req).SuccessCallback(result, customData);
                }
            }
            else
            {
                if (((GetModelsReq)req).FailCallback != null)
                {
                    ((GetModelsReq)req).FailCallback(resp.Error, customData);
                }
            }
        }