private MundiPaggError ConvertError(string wwwError, string wwwJsonMessage)
        {
            MundiPaggError mundiPaggError = new MundiPaggError();

            //Get error message
            try
            {
                mundiPaggError = JsonConvert.DeserializeObject <MundiPaggError>(wwwJsonMessage);
            }
            catch
            {
                mundiPaggError.Errors = new MundiPaggError.Error[]
                {
                    new MundiPaggError.Error()
                    {
                        Message = "Unknown error.", Property = "Unknown property"
                    }
                };
            }

            if (mundiPaggError == null)
            {
                mundiPaggError = new MundiPaggError();
            }

            //Get error code
            try     { mundiPaggError.ErrorCode = (MundiPaggErrorCode)int.Parse(wwwError.Substring(0, 3)); }
            catch   { mundiPaggError.ErrorCode = MundiPaggErrorCode.UNKOWN_ERROR; }

            return(mundiPaggError);
        }
        private IEnumerator StartRequest(RequestContainer requestContainer)
        {
            byte[] postData = null;
            if (requestContainer.Request.Verb == Request.VERB.POST)
            {
                string body = JsonConvert.SerializeObject(requestContainer.Request.Data);
                postData = System.Text.Encoding.UTF8.GetBytes(body);
            }
            else
            {
                requestContainer.FullUrl += "?";
                string jsonParams = JsonConvert.SerializeObject(requestContainer.Request.Data);
                Dictionary <string, object> urlParams = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonParams);
                bool firstParam = true;
                foreach (var p in urlParams)
                {
                    if (!firstParam)
                    {
                        requestContainer.FullUrl += "&";
                    }
                    requestContainer.FullUrl += p.Key + "=" + p.Value;

                    if (firstParam)
                    {
                        firstParam = false;
                    }
                }
            }

            WWW www = new WWW(requestContainer.FullUrl, postData, requestContainer.Request.Header);

            if (OnRequestStart != null)
            {
                OnRequestStart.Invoke();
            }

            yield return(www);

            //No error?
            if (string.IsNullOrEmpty(www.error))
            {
                requestContainer.JsonResponse = www.text;
                requestContainer.SuccessCallback();
            }
            else
            {
                MundiPaggError error = ConvertError(www.error, www.text);
                //Call error callback
                requestContainer.ErrorCallback(error);
            }

            if (OnRequestEnd != null)
            {
                OnRequestEnd.Invoke();
            }
        }