Knetik.KnetikApiResponse.ValidateResponse C# (CSharp) Метод

ValidateResponse() защищенный Метод

protected ValidateResponse ( KnetikRequest req ) : void
req KnetikRequest
Результат void
        protected virtual void ValidateResponse(KnetikRequest req)
        {
            Status = StatusType.Success;
            if (req.response == null) {
                Log("Knetik Labs SDK - ERROR 1: The response from SAPI is null.");
                                Status = StatusType.Failure;
                                ErrorMessage = "Connection error - No connection";
                return;
            }

            if (req.response.status != 200) {
                LogError("Knetik Labs SDK - ERROR 2: Response returned a status of " + req.response.status);
                                Status = StatusType.Failure;
                                ErrorMessage = "Connection Error - Server problem";
                return;
            }

            try {
                Body = KnetikJSON.Parse(req.response.Text);

                if (Body == null) {
                    LogError("Knetik Labs SDK - ERROR 3: Failed to Properly Parse JSON response");
                                        Status = StatusType.Failure;
                                        ErrorMessage = "Connection error - Invalid format";
                    return;
                }
            } catch(Exception e) {
                LogException(e);
                                Status = StatusType.Failure;
                                ErrorMessage = "Connection error - Unknown exception";
                return;
            }

            if (Body["error"] == null) {
                LogError("Knetik Labs SDK - ERROR 4: JSON Response does NOT contain an error node!");
                Status = StatusType.Failure;
                                ErrorMessage = "Connection error - Malformed response";
                return;
            }

            KnetikJSONNode error = Body["error"];

            if ((error["success"] == null) || (error["success"].AsBool == false)) {
                LogError("Knetik Labs SDK - ERROR 5: Response JSON does NOT report success!");
                Status = StatusType.Error;
                                ErrorMessage = Body["message"];
                return;
            }
        }