Beispiel #1
0
        internal static PNUpdateSpaceResult GetObject(List <object> listObject)
        {
            PNUpdateSpaceResult         result            = null;
            Dictionary <string, object> updateSpaceDicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]);

            if (updateSpaceDicObj != null && updateSpaceDicObj.ContainsKey("data"))
            {
                result = new PNUpdateSpaceResult();

                Dictionary <string, object> getCreateSpaceDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(updateSpaceDicObj["data"]);
                if (getCreateSpaceDataDic != null && getCreateSpaceDataDic.Count > 0)
                {
                    result.Id          = getCreateSpaceDataDic.ContainsKey("id") && getCreateSpaceDataDic["id"] != null ? getCreateSpaceDataDic["id"].ToString() : null;
                    result.Name        = getCreateSpaceDataDic.ContainsKey("name") && getCreateSpaceDataDic["name"] != null ? getCreateSpaceDataDic["name"].ToString() : null;
                    result.Description = getCreateSpaceDataDic.ContainsKey("description") && getCreateSpaceDataDic["description"] != null ? getCreateSpaceDataDic["description"].ToString() : null;
                    result.Created     = getCreateSpaceDataDic.ContainsKey("created") && getCreateSpaceDataDic["created"] != null ? getCreateSpaceDataDic["created"].ToString() : null;
                    result.Updated     = getCreateSpaceDataDic.ContainsKey("updated") && getCreateSpaceDataDic["updated"] != null ? getCreateSpaceDataDic["updated"].ToString() : null;
                    if (getCreateSpaceDataDic.ContainsKey("custom"))
                    {
                        result.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getCreateSpaceDataDic["custom"]);
                    }
                }
            }

            return(result);
        }
        internal static PNSetChannelMetadataResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> setChannelMetadataDicObj = (listObject != null && listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;
            PNSetChannelMetadataResult  result = null;

            if (setChannelMetadataDicObj != null && setChannelMetadataDicObj.ContainsKey("data"))
            {
                result = new PNSetChannelMetadataResult();

                Dictionary <string, object> getSetChMetadataDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(setChannelMetadataDicObj["data"]);
                if (getSetChMetadataDataDic != null && getSetChMetadataDataDic.Count > 0)
                {
                    result.Channel     = getSetChMetadataDataDic.ContainsKey("id") && getSetChMetadataDataDic["id"] != null ? getSetChMetadataDataDic["id"].ToString() : null;
                    result.Name        = getSetChMetadataDataDic.ContainsKey("name") && getSetChMetadataDataDic["name"] != null ? getSetChMetadataDataDic["name"].ToString() : null;
                    result.Description = getSetChMetadataDataDic.ContainsKey("description") && getSetChMetadataDataDic["description"] != null ? getSetChMetadataDataDic["description"].ToString() : null;
                    result.Updated     = getSetChMetadataDataDic.ContainsKey("updated") && getSetChMetadataDataDic["updated"] != null ? getSetChMetadataDataDic["updated"].ToString() : null;
                    if (getSetChMetadataDataDic.ContainsKey("custom"))
                    {
                        result.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getSetChMetadataDataDic["custom"]);
                    }
                }
            }

            return(result);
        }
        internal static PNGetUserResult GetObject(List <object> listObject)
        {
            PNGetUserResult             result        = null;
            Dictionary <string, object> getUserDicObj = (listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;

            if (getUserDicObj != null && getUserDicObj.ContainsKey("data"))
            {
                result = new PNGetUserResult();

                Dictionary <string, object> userDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getUserDicObj["data"]);
                if (userDataDic != null && userDataDic.Count > 0)
                {
                    var usrData = new PNGetUserResult
                    {
                        Id         = (userDataDic.ContainsKey("id") && userDataDic["id"] != null) ? userDataDic["id"].ToString() : null,
                        Name       = (userDataDic.ContainsKey("name") && userDataDic["name"] != null) ? userDataDic["name"].ToString() : null,
                        ExternalId = (userDataDic.ContainsKey("externalId") && userDataDic["externalId"] != null) ? userDataDic["externalId"].ToString() : null,
                        ProfileUrl = (userDataDic.ContainsKey("profileUrl") && userDataDic["profileUrl"] != null) ? userDataDic["profileUrl"].ToString() : null,
                        Email      = (userDataDic.ContainsKey("email") && userDataDic["email"] != null) ? userDataDic["email"].ToString() : null,
                        Created    = (userDataDic.ContainsKey("created") && userDataDic["created"] != null) ? userDataDic["created"].ToString() : null,
                        Updated    = (userDataDic.ContainsKey("updated") && userDataDic["updated"] != null) ? userDataDic["updated"].ToString() : null
                    };

                    if (userDataDic.ContainsKey("custom"))
                    {
                        usrData.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(userDataDic["custom"]);
                    }
                    result = usrData;
                }
            }

            return(result);
        }
        internal static PNCreateUserResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> createUserDicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]);
            PNCreateUserResult          result           = null;

            if (createUserDicObj != null && createUserDicObj.ContainsKey("data"))
            {
                result = new PNCreateUserResult();

                Dictionary <string, object> getCreateUserDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(createUserDicObj["data"]);
                if (getCreateUserDataDic != null && getCreateUserDataDic.Count > 0)
                {
                    result.Id         = getCreateUserDataDic.ContainsKey("id") && getCreateUserDataDic["id"] != null ? getCreateUserDataDic["id"].ToString() : null;
                    result.Name       = getCreateUserDataDic.ContainsKey("name") && getCreateUserDataDic["name"] != null ? getCreateUserDataDic["name"].ToString() : null;
                    result.ExternalId = getCreateUserDataDic.ContainsKey("externalId") && getCreateUserDataDic["externalId"] != null ? getCreateUserDataDic["externalId"].ToString() : null;
                    result.ProfileUrl = getCreateUserDataDic.ContainsKey("profileUrl") && getCreateUserDataDic["profileUrl"] != null ? getCreateUserDataDic["profileUrl"].ToString() : null;
                    result.Email      = getCreateUserDataDic.ContainsKey("email") && getCreateUserDataDic["email"] != null ? getCreateUserDataDic["email"].ToString() : null;
                    result.Created    = getCreateUserDataDic.ContainsKey("created") && getCreateUserDataDic["created"] != null ? getCreateUserDataDic["created"].ToString() : "";
                    result.Updated    = getCreateUserDataDic.ContainsKey("updated") && getCreateUserDataDic["updated"] != null ? getCreateUserDataDic["updated"].ToString() : "";
                    if (getCreateUserDataDic.ContainsKey("custom"))
                    {
                        result.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getCreateUserDataDic["custom"]);
                    }
                }
            }

            return(result);
        }
Beispiel #5
0
        internal static PNSetUuidMetadataResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> setUuidDicObj = (listObject != null && listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;
            PNSetUuidMetadataResult     result        = null;

            if (setUuidDicObj != null && setUuidDicObj.ContainsKey("data"))
            {
                result = new PNSetUuidMetadataResult();

                Dictionary <string, object> setUuidDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(setUuidDicObj["data"]);
                if (setUuidDataDic != null && setUuidDataDic.Count > 0)
                {
                    result.Uuid       = setUuidDataDic.ContainsKey("id") && setUuidDataDic["id"] != null ? setUuidDataDic["id"].ToString() : null;
                    result.Name       = setUuidDataDic.ContainsKey("name") && setUuidDataDic["name"] != null ? setUuidDataDic["name"].ToString() : null;
                    result.ExternalId = setUuidDataDic.ContainsKey("externalId") && setUuidDataDic["externalId"] != null ? setUuidDataDic["externalId"].ToString() : null;
                    result.ProfileUrl = setUuidDataDic.ContainsKey("profileUrl") && setUuidDataDic["profileUrl"] != null ? setUuidDataDic["profileUrl"].ToString() : null;
                    result.Email      = setUuidDataDic.ContainsKey("email") && setUuidDataDic["email"] != null ? setUuidDataDic["email"].ToString() : null;
                    result.Updated    = setUuidDataDic.ContainsKey("updated") && setUuidDataDic["updated"] != null ? setUuidDataDic["updated"].ToString() : "";
                    if (setUuidDataDic.ContainsKey("custom"))
                    {
                        result.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(setUuidDataDic["custom"]);
                    }
                }
            }

            return(result);
        }
        internal static PNGetSpaceResult GetObject(List <object> listObject)
        {
            PNGetSpaceResult            result         = null;
            Dictionary <string, object> getSpaceDicObj = (listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;

            if (getSpaceDicObj != null && getSpaceDicObj.ContainsKey("data"))
            {
                result = new PNGetSpaceResult();

                Dictionary <string, object> getSpaceDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getSpaceDicObj["data"]);
                if (getSpaceDataDic != null && getSpaceDataDic.Count > 0)
                {
                    var user = new PNGetSpaceResult
                    {
                        Id          = (getSpaceDataDic.ContainsKey("id") && getSpaceDataDic["id"] != null) ? getSpaceDataDic["id"].ToString() : null,
                        Name        = (getSpaceDataDic.ContainsKey("name") && getSpaceDataDic["name"] != null) ? getSpaceDataDic["name"].ToString() : null,
                        Description = (getSpaceDataDic.ContainsKey("description") && getSpaceDataDic["description"] != null) ? getSpaceDataDic["description"].ToString() : null,
                        Created     = (getSpaceDataDic.ContainsKey("created") && getSpaceDataDic["created"] != null) ? getSpaceDataDic["created"].ToString() : null,
                        Updated     = (getSpaceDataDic.ContainsKey("updated") && getSpaceDataDic["updated"] != null) ? getSpaceDataDic["updated"].ToString() : null
                    };
                    if (getSpaceDataDic.ContainsKey("custom"))
                    {
                        user.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getSpaceDataDic["custom"]);
                    }
                    result = user;
                }
            }

            return(result);
        }
        internal static PNListFilesResult GetObject(List <object> listObject)
        {
            PNListFilesResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNListFilesResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        object[] fileDataArray = JsonDataParseInternalUtil.ConvertToObjectArray(dicObj["data"]);
                        if (fileDataArray != null && fileDataArray.Length > 0)
                        {
                            result.FilesList = new List <PNFileResult>();
                            for (int index = 0; index < fileDataArray.Length; index++)
                            {
                                Dictionary <string, object> getFileDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(fileDataArray[index]);
                                if (getFileDataDic != null && getFileDataDic.Count > 0)
                                {
                                    int fileSize;
                                    var fileItem = new PNFileResult
                                    {
                                        Name    = (getFileDataDic.ContainsKey("name") && getFileDataDic["name"] != null) ? getFileDataDic["name"].ToString() : null,
                                        Id      = (getFileDataDic.ContainsKey("id") && getFileDataDic["id"] != null) ? getFileDataDic["id"].ToString() : null,
                                        Created = (getFileDataDic.ContainsKey("created") && getFileDataDic["created"] != null) ? getFileDataDic["created"].ToString() : null
                                    };
                                    if (getFileDataDic.ContainsKey("size") && getFileDataDic["size"] != null && Int32.TryParse(getFileDataDic["size"].ToString(), out fileSize))
                                    {
                                        fileItem.Size = fileSize;
                                    }
                                    result.FilesList.Add(fileItem);
                                }
                            }
                        }
                    }

                    int fileCount;
                    if (dicObj.ContainsKey("count") && dicObj["count"] != null && Int32.TryParse(dicObj["count"].ToString(), out fileCount))
                    {
                        result.Count = fileCount;
                    }
                    if (dicObj.ContainsKey("next") && dicObj["next"] != null)
                    {
                        result.Next = dicObj["next"].ToString();
                    }
                }
            }
            return(result);
        }
Beispiel #8
0
        internal static PNRemoveMessageActionResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> removeMsgActionDicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[0]);
            PNRemoveMessageActionResult result = null;

            if (removeMsgActionDicObj != null && removeMsgActionDicObj.ContainsKey("status"))
            {
                int status;
                int.TryParse(removeMsgActionDicObj["status"].ToString(), out status);
                if (status == 200)
                {
                    result = new PNRemoveMessageActionResult();
                }
            }

            return(result);
        }
Beispiel #9
0
        internal static PNMessageActionEventResult GetObject(List <object> listObject)
        {
            PNMessageActionEventResult result = null;

            Dictionary <string, object> msgActionEventDicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[0]);

            if (msgActionEventDicObj != null)
            {
                result = new PNMessageActionEventResult();

                if (msgActionEventDicObj.ContainsKey("event") && msgActionEventDicObj["event"] != null)
                {
                    result.Event = msgActionEventDicObj["event"].ToString();
                }

                if (msgActionEventDicObj.ContainsKey("data") && msgActionEventDicObj["data"] != null)
                {
                    Dictionary <string, object> dataDic = msgActionEventDicObj["data"] as Dictionary <string, object>;
                    if (dataDic != null)
                    {
                        long messageTimetoken;
                        if (dataDic.ContainsKey("messageTimetoken") && Int64.TryParse(dataDic["messageTimetoken"].ToString(), out messageTimetoken))
                        {
                            result.MessageTimetoken = messageTimetoken;
                        }

                        long actionTimetoken;
                        if (dataDic.ContainsKey("actionTimetoken") && Int64.TryParse(dataDic["actionTimetoken"].ToString(), out actionTimetoken))
                        {
                            result.ActionTimetoken = actionTimetoken;
                        }

                        result.Action = new PNMessageAction
                        {
                            Type  = dataDic.ContainsKey("type") && dataDic["type"] != null ? dataDic["type"].ToString() : null,
                            Value = dataDic.ContainsKey("value") && dataDic["value"] != null ? dataDic["value"].ToString() : null
                        };
                    }
                }
                result.Uuid    = listObject[3].ToString();
                result.Channel = listObject[4].ToString();
            }

            return(result);
        }
        internal static PNGenerateFileUploadUrlResult GetObject(List <object> listObject)
        {
            PNGenerateFileUploadUrlResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNGenerateFileUploadUrlResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        Dictionary <string, object> generateFileUploadUrlDicData = JsonDataParseInternalUtil.ConvertToDictionaryObject(dicObj["data"]);
                        if (generateFileUploadUrlDicData != null && generateFileUploadUrlDicData.Count > 0)
                        {
                            result.FileId   = generateFileUploadUrlDicData.ContainsKey("id") && generateFileUploadUrlDicData["id"] != null ? generateFileUploadUrlDicData["id"].ToString() : null;
                            result.FileName = generateFileUploadUrlDicData.ContainsKey("name") && generateFileUploadUrlDicData["name"] != null ? generateFileUploadUrlDicData["name"].ToString() : null;
                        }
                    }
                    else if (dicObj.ContainsKey("file_upload_request") && dicObj["file_upload_request"] != null)
                    {
                        Dictionary <string, object> generateFileUploadUrlDicUploadReq = JsonDataParseInternalUtil.ConvertToDictionaryObject(dicObj["file_upload_request"]);
                        if (generateFileUploadUrlDicUploadReq != null && generateFileUploadUrlDicUploadReq.Count > 0)
                        {
                            result.FileUploadRequest = new PNGenerateFileUploadUrlData
                            {
                                Url            = generateFileUploadUrlDicUploadReq.ContainsKey("url") && generateFileUploadUrlDicUploadReq["url"] != null ? generateFileUploadUrlDicUploadReq["url"].ToString() : null,
                                Method         = generateFileUploadUrlDicUploadReq.ContainsKey("method") && generateFileUploadUrlDicUploadReq["method"] != null ? generateFileUploadUrlDicUploadReq["method"].ToString() : null,
                                ExpirationDate = generateFileUploadUrlDicUploadReq.ContainsKey("expiration_date") && generateFileUploadUrlDicUploadReq["expiration_date"] != null ? generateFileUploadUrlDicUploadReq["expiration_date"].ToString() : null,
                                FormFields     = generateFileUploadUrlDicUploadReq.ContainsKey("form_fields") && generateFileUploadUrlDicUploadReq["form_fields"] != null?JsonDataParseInternalUtil.ConvertToDictionaryObject(generateFileUploadUrlDicUploadReq["form_fields"]) : null
                            };
                        }
                    }
                }
            }

            return(result);
        }
        internal static PNAddMessageActionResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> addMsgActionDicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]);
            PNAddMessageActionResult    result             = null;

            if (addMsgActionDicObj != null && addMsgActionDicObj.ContainsKey("data"))
            {
                result = new PNAddMessageActionResult();

                Dictionary <string, object> addMsgActionDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(addMsgActionDicObj["data"]);
                if (addMsgActionDataDic != null && addMsgActionDataDic.Count > 0)
                {
                    long messageTimetoken;
                    if (addMsgActionDataDic.ContainsKey("messageTimetoken") && Int64.TryParse(addMsgActionDataDic["messageTimetoken"].ToString(), out messageTimetoken))
                    {
                        result.MessageTimetoken = messageTimetoken;
                    }

                    long actionTimetoken;
                    if (addMsgActionDataDic.ContainsKey("actionTimetoken") && Int64.TryParse(addMsgActionDataDic["actionTimetoken"].ToString(), out actionTimetoken))
                    {
                        result.ActionTimetoken = actionTimetoken;
                    }

                    result.Action = new PNMessageAction
                    {
                        Type  = addMsgActionDataDic.ContainsKey("type") && addMsgActionDataDic["type"] != null ? addMsgActionDataDic["type"].ToString() : null,
                        Value = addMsgActionDataDic.ContainsKey("value") && addMsgActionDataDic["value"] != null ? addMsgActionDataDic["value"].ToString() : null
                    };

                    result.Uuid = addMsgActionDataDic.ContainsKey("uuid") && addMsgActionDataDic["uuid"] != null ? addMsgActionDataDic["uuid"].ToString() : null;
                }
            }

            return(result);
        }
        internal static PNMembersResult GetObject(List <object> listObject)
        {
            PNMembersResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNMembersResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        result.Members = new List <PNMembersItemResult>();

                        object[] userArray = JsonDataParseInternalUtil.ConvertToObjectArray(dicObj["data"]);
                        if (userArray != null && userArray.Length > 0)
                        {
                            for (int index = 0; index < userArray.Length; index++)
                            {
                                Dictionary <string, object> getMbrItemDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(userArray[index]);
                                if (getMbrItemDataDic != null && getMbrItemDataDic.Count > 0)
                                {
                                    var mbrItem = new PNMembersItemResult
                                    {
                                        UserId  = (getMbrItemDataDic.ContainsKey("id") && getMbrItemDataDic["id"] != null) ? getMbrItemDataDic["id"].ToString() : "",
                                        Created = (getMbrItemDataDic.ContainsKey("created") && getMbrItemDataDic["created"] != null) ? getMbrItemDataDic["created"].ToString() : "",
                                        Updated = (getMbrItemDataDic.ContainsKey("updated") && getMbrItemDataDic["updated"] != null) ? getMbrItemDataDic["updated"].ToString() : ""
                                    };
                                    if (getMbrItemDataDic.ContainsKey("custom"))
                                    {
                                        mbrItem.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMbrItemDataDic["custom"]);
                                    }
                                    if (getMbrItemDataDic.ContainsKey("user"))
                                    {
                                        Dictionary <string, object> userDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMbrItemDataDic["space"]);
                                        if (userDic != null && userDic.Count > 0)
                                        {
                                            var userResult = new PNUserResult
                                            {
                                                Id         = (userDic.ContainsKey("id") && userDic["id"] != null) ? userDic["id"].ToString() : "",
                                                Name       = (userDic.ContainsKey("name") && userDic["name"] != null) ? userDic["name"].ToString() : "",
                                                ExternalId = (userDic.ContainsKey("externalId") && userDic["externalId"] != null) ? userDic["externalId"].ToString() : "",
                                                ProfileUrl = (userDic.ContainsKey("profileUrl") && userDic["profileUrl"] != null) ? userDic["profileUrl"].ToString() : "",
                                                Email      = (userDic.ContainsKey("email") && userDic["email"] != null) ? userDic["email"].ToString() : "",
                                                Created    = (userDic.ContainsKey("created") && userDic["created"] != null) ? userDic["created"].ToString() : "",
                                                Updated    = (userDic.ContainsKey("updated") && userDic["updated"] != null) ? userDic["updated"].ToString() : ""
                                            };
                                            if (userDic.ContainsKey("custom"))
                                            {
                                                userResult.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(userDic["custom"]);
                                            }

                                            mbrItem.User = userResult;
                                        }
                                    }
                                    result.Members.Add(mbrItem);
                                }
                            }
                        }
                    }
                    else if (dicObj.ContainsKey("totalCount") && dicObj["totalCount"] != null)
                    {
                        int usersCount;
                        Int32.TryParse(dicObj["totalCount"].ToString(), out usersCount);
                        result.TotalCount = usersCount;
                    }
                    else if (dicObj.ContainsKey("next") && dicObj["next"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPage();
                        }
                        result.Page.Next = dicObj["next"].ToString();
                    }
                    else if (dicObj.ContainsKey("prev") && dicObj["prev"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPage();
                        }
                        result.Page.Prev = dicObj["prev"].ToString();
                    }
                }
            }
            return(result);
        }
        internal static PNGetAllChannelMetadataResult GetObject(List <object> listObject)
        {
            PNGetAllChannelMetadataResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNGetAllChannelMetadataResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        result.Channels = new List <PNChannelMetadataResult>();

                        Dictionary <string, object> getChMetadataDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(dicObj["data"]);
                        if (getChMetadataDataDic != null && getChMetadataDataDic.Count > 0)
                        {
                            var chMetadata = new PNChannelMetadataResult
                            {
                                Channel     = (getChMetadataDataDic.ContainsKey("id") && getChMetadataDataDic["id"] != null) ? getChMetadataDataDic["id"].ToString() : null,
                                Name        = (getChMetadataDataDic.ContainsKey("name") && getChMetadataDataDic["name"] != null) ? getChMetadataDataDic["name"].ToString() : null,
                                Description = (getChMetadataDataDic.ContainsKey("description") && getChMetadataDataDic["description"] != null) ? getChMetadataDataDic["description"].ToString() : null,
                                Updated     = (getChMetadataDataDic.ContainsKey("updated") && getChMetadataDataDic["updated"] != null) ? getChMetadataDataDic["updated"].ToString() : null
                            };
                            if (getChMetadataDataDic.ContainsKey("custom"))
                            {
                                chMetadata.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getChMetadataDataDic["custom"]);
                            }
                            result.Channels.Add(chMetadata);
                        }
                        else
                        {
                            object[] chMetadataDataArray = JsonDataParseInternalUtil.ConvertToObjectArray(dicObj["data"]);
                            if (chMetadataDataArray != null && chMetadataDataArray.Length > 0)
                            {
                                for (int index = 0; index < chMetadataDataArray.Length; index++)
                                {
                                    Dictionary <string, object> chMetadataDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(chMetadataDataArray[index]);
                                    if (chMetadataDataDic != null && chMetadataDataDic.Count > 0)
                                    {
                                        var chMetadataData = new PNChannelMetadataResult
                                        {
                                            Channel     = (chMetadataDataDic.ContainsKey("id") && chMetadataDataDic["id"] != null) ? chMetadataDataDic["id"].ToString() : null,
                                            Name        = (chMetadataDataDic.ContainsKey("name") && chMetadataDataDic["name"] != null) ? chMetadataDataDic["name"].ToString() : null,
                                            Description = (chMetadataDataDic.ContainsKey("description") && chMetadataDataDic["description"] != null) ? chMetadataDataDic["description"].ToString() : null,
                                            Updated     = (chMetadataDataDic.ContainsKey("updated") && chMetadataDataDic["updated"] != null) ? chMetadataDataDic["updated"].ToString() : null
                                        };

                                        if (chMetadataDataDic.ContainsKey("custom"))
                                        {
                                            chMetadataData.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(chMetadataDataDic["custom"]);
                                        }
                                        result.Channels.Add(chMetadataData);
                                    }
                                }
                            }
                        }
                    }
                    else if (dicObj.ContainsKey("totalCount") && dicObj["totalCount"] != null)
                    {
                        int chMetadataCount;
                        Int32.TryParse(dicObj["totalCount"].ToString(), out chMetadataCount);
                        result.TotalCount = chMetadataCount;
                    }
                    else if (dicObj.ContainsKey("next") && dicObj["next"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPageObject();
                        }
                        result.Page.Next = dicObj["next"].ToString();
                    }
                    else if (dicObj.ContainsKey("prev") && dicObj["prev"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPageObject();
                        }
                        result.Page.Prev = dicObj["prev"].ToString();
                    }
                }
            }

            return(result);
        }
Beispiel #14
0
        internal static PNGetMessageActionsResult GetObject(List <object> listObject)
        {
            Dictionary <string, object> getMsgActionsDicObj = (listObject != null && listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;
            PNGetMessageActionsResult   result = null;

            if (getMsgActionsDicObj != null && getMsgActionsDicObj.ContainsKey("data"))
            {
                result = new PNGetMessageActionsResult();

                object[] getMsgActionsDataList = JsonDataParseInternalUtil.ConvertToObjectArray(getMsgActionsDicObj["data"]);
                if (getMsgActionsDataList != null && getMsgActionsDataList.Length > 0)
                {
                    result.MessageActions = new List <PNMessageActionItem>();

                    foreach (object getMsgActionObj in getMsgActionsDataList)
                    {
                        Dictionary <string, object> getMsgActionItemDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMsgActionObj);
                        if (getMsgActionItemDic != null && getMsgActionItemDic.Count > 0)
                        {
                            PNMessageActionItem actionItem = new PNMessageActionItem();

                            long messageTimetoken;
                            if (getMsgActionItemDic.ContainsKey("messageTimetoken") && Int64.TryParse(getMsgActionItemDic["messageTimetoken"].ToString(), out messageTimetoken))
                            {
                                actionItem.MessageTimetoken = messageTimetoken;
                            }

                            long actionTimetoken;
                            if (getMsgActionItemDic.ContainsKey("actionTimetoken") && Int64.TryParse(getMsgActionItemDic["actionTimetoken"].ToString(), out actionTimetoken))
                            {
                                actionItem.ActionTimetoken = actionTimetoken;
                            }

                            actionItem.Action = new PNMessageAction
                            {
                                Type  = getMsgActionItemDic.ContainsKey("type") && getMsgActionItemDic["type"] != null ? getMsgActionItemDic["type"].ToString() : null,
                                Value = getMsgActionItemDic.ContainsKey("value") && getMsgActionItemDic["value"] != null ? getMsgActionItemDic["value"].ToString() : null
                            };

                            actionItem.Uuid = getMsgActionItemDic.ContainsKey("uuid") && getMsgActionItemDic["uuid"] != null ? getMsgActionItemDic["uuid"].ToString() : null;

                            result.MessageActions.Add(actionItem);
                        }
                    }
                }

                if (getMsgActionsDicObj.ContainsKey("more"))
                {
                    Dictionary <string, object> getMsgActionsMoreDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMsgActionsDicObj["more"]);
                    if (getMsgActionsMoreDic != null && getMsgActionsMoreDic.Count > 0)
                    {
                        result.More = new PNGetMessageActionsResult.MoreInfo();
                        long moreStart;
                        if (getMsgActionsMoreDic.ContainsKey("start") && Int64.TryParse(getMsgActionsMoreDic["start"].ToString(), out moreStart))
                        {
                            result.More.Start = moreStart;
                        }

                        long moreEnd;
                        if (getMsgActionsMoreDic.ContainsKey("end") && Int64.TryParse(getMsgActionsMoreDic["end"].ToString(), out moreEnd))
                        {
                            result.More.End = moreEnd;
                        }

                        int moreLimit;
                        if (getMsgActionsMoreDic.ContainsKey("limit") && Int32.TryParse(getMsgActionsMoreDic["limit"].ToString(), out moreLimit))
                        {
                            result.More.Limit = moreLimit;
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #15
0
        internal static PNGetAllUuidMetadataResult GetObject(List <object> listObject)
        {
            PNGetAllUuidMetadataResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNGetAllUuidMetadataResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        result.Uuids = new List <PNUuidMetadataResult>();

                        Dictionary <string, object> getUserDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(dicObj["data"]);
                        if (getUserDataDic != null && getUserDataDic.Count > 0)
                        {
                            var uuidMetaData = new PNUuidMetadataResult
                            {
                                Uuid       = (getUserDataDic.ContainsKey("id") && getUserDataDic["id"] != null) ? getUserDataDic["id"].ToString() : null,
                                Name       = (getUserDataDic.ContainsKey("name") && getUserDataDic["name"] != null) ? getUserDataDic["name"].ToString() : null,
                                ExternalId = (getUserDataDic.ContainsKey("externalId") && getUserDataDic["externalId"] != null) ? getUserDataDic["externalId"].ToString() : null,
                                ProfileUrl = (getUserDataDic.ContainsKey("profileUrl") && getUserDataDic["profileUrl"] != null) ? getUserDataDic["profileUrl"].ToString() : null,
                                Email      = (getUserDataDic.ContainsKey("email") && getUserDataDic["email"] != null) ? getUserDataDic["email"].ToString() : null,
                                Updated    = (getUserDataDic.ContainsKey("updated") && getUserDataDic["updated"] != null) ? getUserDataDic["updated"].ToString() : null
                            };
                            if (getUserDataDic.ContainsKey("custom"))
                            {
                                uuidMetaData.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getUserDataDic["custom"]);
                            }
                            result.Uuids.Add(uuidMetaData);
                        }
                        else
                        {
                            object[] userDataArray = JsonDataParseInternalUtil.ConvertToObjectArray(dicObj["data"]);
                            if (userDataArray != null && userDataArray.Length > 0)
                            {
                                for (int index = 0; index < userDataArray.Length; index++)
                                {
                                    Dictionary <string, object> userDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(userDataArray[index]);
                                    if (userDataDic != null && userDataDic.Count > 0)
                                    {
                                        var uuidMetadata = new PNUuidMetadataResult
                                        {
                                            Uuid       = (userDataDic.ContainsKey("id") && userDataDic["id"] != null) ? userDataDic["id"].ToString() : null,
                                            Name       = (userDataDic.ContainsKey("name") && userDataDic["name"] != null) ? userDataDic["name"].ToString() : null,
                                            ExternalId = (userDataDic.ContainsKey("externalId") && userDataDic["externalId"] != null) ? userDataDic["externalId"].ToString() : null,
                                            ProfileUrl = (userDataDic.ContainsKey("profileUrl") && userDataDic["profileUrl"] != null) ? userDataDic["profileUrl"].ToString() : null,
                                            Email      = (userDataDic.ContainsKey("email") && userDataDic["email"] != null) ? userDataDic["email"].ToString() : null,
                                            Updated    = (userDataDic.ContainsKey("updated") && userDataDic["updated"] != null) ? userDataDic["updated"].ToString() : null
                                        };

                                        if (userDataDic.ContainsKey("custom"))
                                        {
                                            uuidMetadata.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(userDataDic["custom"]);
                                        }
                                        result.Uuids.Add(uuidMetadata);
                                    }
                                }
                            }
                        }
                    }
                    else if (dicObj.ContainsKey("totalCount") && dicObj["totalCount"] != null)
                    {
                        int usersCount;
                        Int32.TryParse(dicObj["totalCount"].ToString(), out usersCount);
                        result.TotalCount = usersCount;
                    }
                    else if (dicObj.ContainsKey("next") && dicObj["next"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPageObject();
                        }
                        result.Page.Next = dicObj["next"].ToString();
                    }
                    else if (dicObj.ContainsKey("prev") && dicObj["prev"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPageObject();
                        }
                        result.Page.Prev = dicObj["prev"].ToString();
                    }
                }
            }

            return(result);
        }
Beispiel #16
0
        internal static PNFetchHistoryResult GetObject(List <object> listObject)
        {
            PNFetchHistoryResult ack = new PNFetchHistoryResult();

            Dictionary <string, List <object> > channelMessagesContainer = null;

            for (int index = 0; index < listObject.Count; index++)
            {
                if (listObject[index].GetType() == typeof(List <object>))
                {
                    List <object> channelMessagesList = listObject[index] as List <object>;
                    if (channelMessagesList.Count >= 1)
                    {
                        channelMessagesContainer = channelMessagesList[0] as Dictionary <string, List <object> >;
                    }
                    if (channelMessagesContainer != null)
                    {
                        ack.Messages = new Dictionary <string, List <PNHistoryItemResult> >();
                        foreach (var channelKVP in channelMessagesContainer)
                        {
                            string channel = channelKVP.Key;
                            List <PNHistoryItemResult> resultList = new List <PNHistoryItemResult>();
                            object[] channelValArray = channelKVP.Value != null?JsonDataParseInternalUtil.ConvertToObjectArray(channelKVP.Value) : new object[0];

                            foreach (object msgContainerObj in channelValArray)
                            {
                                Dictionary <string, object> messagesContainer = JsonDataParseInternalUtil.ConvertToDictionaryObject(msgContainerObj);
                                if (messagesContainer != null)
                                {
                                    PNHistoryItemResult result = new PNHistoryItemResult();
                                    if (messagesContainer.ContainsKey("message") &&
                                        (messagesContainer.ContainsKey("timetoken") || messagesContainer.ContainsKey("meta") || messagesContainer.ContainsKey("actions")))
                                    {
                                        result.Entry = messagesContainer["message"];

                                        long messageTimetoken;
                                        if (messagesContainer.ContainsKey("timetoken") && Int64.TryParse(messagesContainer["timetoken"].ToString(), out messageTimetoken))
                                        {
                                            result.Timetoken = messageTimetoken;
                                        }

                                        if (messagesContainer.ContainsKey("meta"))
                                        {
                                            result.Meta = messagesContainer["meta"];
                                        }

                                        if (messagesContainer.ContainsKey("actions"))
                                        {
                                            result.Actions = messagesContainer["actions"];
                                        }
                                    }
                                    resultList.Add(result);
                                }
                            }
                            ack.Messages.Add(channel, resultList);
                        }
                    }
                }
                else if (listObject[index].GetType() == typeof(Dictionary <string, object>))
                {
                    Dictionary <string, object> moreContainer = listObject[index] as Dictionary <string, object>;
                    if (moreContainer != null && moreContainer.ContainsKey("more"))
                    {
                        Dictionary <string, object> moreDic = moreContainer["more"] as Dictionary <string, object>;
                        if (moreDic != null)
                        {
                            ack.More = new PNFetchHistoryResult.MoreInfo();
                            if (moreDic.ContainsKey("start"))
                            {
                                long moreStart;
                                if (moreDic.ContainsKey("start") && Int64.TryParse(moreDic["start"].ToString(), out moreStart))
                                {
                                    ack.More.Start = moreStart;
                                }

                                long moreEnd;
                                if (moreDic.ContainsKey("end") && Int64.TryParse(moreDic["end"].ToString(), out moreEnd))
                                {
                                    ack.More.End = moreEnd;
                                }

                                int moreMax;
                                if (moreDic.ContainsKey("max") && Int32.TryParse(moreDic["max"].ToString(), out moreMax))
                                {
                                    ack.More.Max = moreMax;
                                }
                            }
                        }
                    }
                }
            }

            return(ack);
        }
Beispiel #17
0
        internal static PNObjectEventResult GetObject(List <object> listObject)
        {
            PNObjectEventResult result = null;

            Dictionary <string, object> objectEventDicObj = (listObject != null && listObject.Count > 0) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[0]) : null;

            if (objectEventDicObj != null)
            {
                if (result == null)
                {
                    result = new PNObjectEventResult();
                }

                if (objectEventDicObj.ContainsKey("event") && objectEventDicObj["event"] != null)
                {
                    result.Event = objectEventDicObj["event"].ToString();
                }

                if (listObject.Count > 2)
                {
                    long objectEventTimeStamp;
                    if (Int64.TryParse(listObject[2].ToString(), out objectEventTimeStamp))
                    {
                        result.Timestamp = objectEventTimeStamp;
                    }
                }

                if (objectEventDicObj.ContainsKey("type") && objectEventDicObj["type"] != null)
                {
                    result.Type = objectEventDicObj["type"].ToString();
                }

                if (objectEventDicObj.ContainsKey("data") && objectEventDicObj["data"] != null)
                {
                    Dictionary <string, object> dataDic = objectEventDicObj["data"] as Dictionary <string, object>;
                    if (dataDic != null)
                    {
                        if (result.Type.ToLowerInvariant() == "uuid" && dataDic.ContainsKey("id"))
                        {
                            result.UuidMetadata = new PNUuidMetadataResult
                            {
                                Uuid       = dataDic["id"] != null ? dataDic["id"].ToString() : null,
                                Name       = (dataDic.ContainsKey("name") && dataDic["name"] != null) ? dataDic["name"].ToString() : null,
                                ExternalId = (dataDic.ContainsKey("externalId") && dataDic["externalId"] != null) ? dataDic["externalId"].ToString() : null,
                                ProfileUrl = (dataDic.ContainsKey("profileUrl") && dataDic["profileUrl"] != null) ? dataDic["profileUrl"].ToString() : null,
                                Email      = (dataDic.ContainsKey("email") && dataDic["email"] != null) ? dataDic["email"].ToString() : null,
                                Custom     = (dataDic.ContainsKey("custom") && dataDic["custom"] != null) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(dataDic["custom"]) : null,
                                Updated    = (dataDic.ContainsKey("updated") && dataDic["updated"] != null) ? dataDic["updated"].ToString() : null
                            };
                        }
                        else if (result.Type.ToLowerInvariant() == "channel" && dataDic.ContainsKey("id"))
                        {
                            result.ChannelMetadata = new PNChannelMetadataResult
                            {
                                Channel     = dataDic["id"] != null ? dataDic["id"].ToString() : null,
                                Name        = (dataDic.ContainsKey("name") && dataDic["name"] != null) ? dataDic["name"].ToString() : null,
                                Description = (dataDic.ContainsKey("description") && dataDic["description"] != null) ? dataDic["description"].ToString() : null,
                                Custom      = (dataDic.ContainsKey("custom") && dataDic["custom"] != null) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(dataDic["custom"]) : null,
                                Updated     = (dataDic.ContainsKey("updated") && dataDic["updated"] != null) ? dataDic["updated"].ToString() : null
                            };
                        }
                        else if (result.Type.ToLowerInvariant() == "membership" && dataDic.ContainsKey("uuid") && dataDic.ContainsKey("channel"))
                        {
                            Dictionary <string, object> uuidMetadataIdDic = dataDic["uuid"] as Dictionary <string, object>;
                            if (uuidMetadataIdDic != null && uuidMetadataIdDic.ContainsKey("id"))
                            {
                                result.UuidMetadata = new PNUuidMetadataResult
                                {
                                    Uuid = uuidMetadataIdDic["id"] != null ? uuidMetadataIdDic["id"].ToString() : null
                                };
                            }

                            Dictionary <string, object> channelMetadataIdDic = dataDic["channel"] as Dictionary <string, object>;
                            if (channelMetadataIdDic != null && channelMetadataIdDic.ContainsKey("id"))
                            {
                                result.ChannelMetadata = new PNChannelMetadataResult
                                {
                                    Channel = channelMetadataIdDic["id"] != null ? channelMetadataIdDic["id"].ToString() : null
                                };
                            }
                        }
                    }
                }

                result.Channel = (listObject.Count == 6) ? listObject[5].ToString() : listObject[4].ToString();
            }

            return(result);
        }
        internal static PNHistoryResult GetObject(List <object> listObject)
        {
            PNHistoryResult ack = new PNHistoryResult();

            if (listObject == null || listObject.Count == 0)
            {
                return(ack);
            }

            long historyStartTime;
            long historyEndTime;

            if (listObject.Count >= 2 && Int64.TryParse(listObject[1].ToString(), out historyStartTime))
            {
                ack.StartTimeToken = historyStartTime;
            }
            if (listObject.Count >= 2 && Int64.TryParse(listObject[2].ToString(), out historyEndTime))
            {
                ack.EndTimeToken = historyEndTime;
            }
            List <object> messagesContainer = listObject[0] as List <object>;

            if (messagesContainer == null)
            {
                object[] messagesCollection = listObject[0] as object[];
                if (messagesCollection != null && messagesCollection.Length > 0)
                {
                    messagesContainer = messagesCollection.ToList();
                }
            }
            if (messagesContainer != null)
            {
                ack.Messages = new List <PNHistoryItemResult>();
                foreach (var message in messagesContainer)
                {
                    PNHistoryItemResult         result = new PNHistoryItemResult();
                    Dictionary <string, object> dicMessageTimetoken = JsonDataParseInternalUtil.ConvertToDictionaryObject(message);
                    if (dicMessageTimetoken != null)
                    {
                        if (dicMessageTimetoken.ContainsKey("message") &&
                            (dicMessageTimetoken.ContainsKey("timetoken") || dicMessageTimetoken.ContainsKey("meta")))
                        {
                            result.Entry = dicMessageTimetoken["message"];

                            long messageTimetoken;
                            if (dicMessageTimetoken.ContainsKey("timetoken") && Int64.TryParse(dicMessageTimetoken["timetoken"].ToString(), out messageTimetoken))
                            {
                                result.Timetoken = messageTimetoken;
                            }

                            if (dicMessageTimetoken.ContainsKey("meta"))
                            {
                                result.Meta = dicMessageTimetoken["meta"];
                            }
                        }
                        else
                        {
                            result.Entry = dicMessageTimetoken;
                        }
                    }
                    else
                    {
                        result.Entry = message;
                    }

                    ack.Messages.Add(result);
                }
            }

            return(ack);
        }
        internal static PNGetMembershipsResult GetObject(List <object> listObject)
        {
            PNGetMembershipsResult result = null;

            for (int listIndex = 0; listIndex < listObject.Count; listIndex++)
            {
                Dictionary <string, object> dicObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[listIndex]);
                if (dicObj != null && dicObj.Count > 0)
                {
                    if (result == null)
                    {
                        result = new PNGetMembershipsResult();
                    }
                    if (dicObj.ContainsKey("data") && dicObj["data"] != null)
                    {
                        result.Memberships = new List <PNMembershipsItemResult>();

                        object[] spaceArray = JsonDataParseInternalUtil.ConvertToObjectArray(dicObj["data"]);
                        if (spaceArray != null && spaceArray.Length > 0)
                        {
                            for (int index = 0; index < spaceArray.Length; index++)
                            {
                                Dictionary <string, object> getMbrshipItemDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(spaceArray[index]);
                                if (getMbrshipItemDataDic != null && getMbrshipItemDataDic.Count > 0)
                                {
                                    var mbrshipItem = new PNMembershipsItemResult
                                    {
                                        SpaceId = (getMbrshipItemDataDic.ContainsKey("id") && getMbrshipItemDataDic["id"] != null) ? getMbrshipItemDataDic["id"].ToString() : null,
                                        Created = (getMbrshipItemDataDic.ContainsKey("created") && getMbrshipItemDataDic["created"] != null) ? getMbrshipItemDataDic["created"].ToString() : null,
                                        Updated = (getMbrshipItemDataDic.ContainsKey("updated") && getMbrshipItemDataDic["updated"] != null) ? getMbrshipItemDataDic["updated"].ToString() : null
                                    };
                                    if (getMbrshipItemDataDic.ContainsKey("custom"))
                                    {
                                        mbrshipItem.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMbrshipItemDataDic["custom"]);
                                    }
                                    if (getMbrshipItemDataDic.ContainsKey("space") && getMbrshipItemDataDic["space"] != null)
                                    {
                                        Dictionary <string, object> spaceDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getMbrshipItemDataDic["space"]);
                                        if (spaceDic != null && spaceDic.Count > 0)
                                        {
                                            var spaceResult = new PNGetSpaceResult
                                            {
                                                Id          = (spaceDic.ContainsKey("id") && spaceDic["id"] != null) ? spaceDic["id"].ToString() : null,
                                                Name        = (spaceDic.ContainsKey("name") && spaceDic["name"] != null) ? spaceDic["name"].ToString() : null,
                                                Description = (spaceDic.ContainsKey("description") && spaceDic["description"] != null) ? spaceDic["description"].ToString() : null,
                                                Created     = (spaceDic.ContainsKey("created") && spaceDic["created"] != null) ? spaceDic["created"].ToString() : null,
                                                Updated     = (spaceDic.ContainsKey("updated") && spaceDic["updated"] != null) ? spaceDic["updated"].ToString() : null
                                            };
                                            if (spaceDic.ContainsKey("custom"))
                                            {
                                                spaceResult.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(spaceDic["custom"]);
                                            }

                                            mbrshipItem.Space = spaceResult;
                                        }
                                    }
                                    result.Memberships.Add(mbrshipItem);
                                }
                            }
                        }
                    }
                    else if (dicObj.ContainsKey("totalCount") && dicObj["totalCount"] != null)
                    {
                        int usersCount;
                        Int32.TryParse(dicObj["totalCount"].ToString(), out usersCount);
                        result.TotalCount = usersCount;
                    }
                    else if (dicObj.ContainsKey("next") && dicObj["next"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPage();
                        }
                        result.Page.Next = dicObj["next"].ToString();
                    }
                    else if (dicObj.ContainsKey("prev") && dicObj["prev"] != null)
                    {
                        if (result.Page == null)
                        {
                            result.Page = new PNPage();
                        }
                        result.Page.Prev = dicObj["prev"].ToString();
                    }
                }
            }
            return(result);
        }
        internal static PNAccessManagerGrantResult GetObject(List <object> listObject)
        {
            PNAccessManagerGrantResult ack = null;

            Dictionary <string, object> grantDictObj = JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[0]);

            if (grantDictObj != null)
            {
                ack = new PNAccessManagerGrantResult();

                if (grantDictObj.ContainsKey("payload"))
                {
                    Dictionary <string, object> grantAckPayloadDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantDictObj["payload"]);
                    if (grantAckPayloadDict != null && grantAckPayloadDict.Count > 0)
                    {
                        if (grantAckPayloadDict.ContainsKey("level"))
                        {
                            ack.Level = grantAckPayloadDict["level"].ToString();
                        }

                        if (grantAckPayloadDict.ContainsKey("subscribe_key"))
                        {
                            ack.SubscribeKey = grantAckPayloadDict["subscribe_key"].ToString();
                        }

                        if (grantAckPayloadDict.ContainsKey("ttl"))
                        {
                            int grantTtl;
                            if (Int32.TryParse(grantAckPayloadDict["ttl"].ToString(), out grantTtl))
                            {
                                ack.Ttl = grantTtl;
                            }
                        }

                        if (!string.IsNullOrEmpty(ack.Level) && ack.Level == "subkey")
                        {
                            //Placeholder for subkey level
                        }
                        else
                        {
                            if (grantAckPayloadDict.ContainsKey("channels"))
                            {
                                ack.Channels = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                Dictionary <string, object> grantAckChannelListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["channels"]);
                                if (grantAckChannelListDict != null && grantAckChannelListDict.Count > 0)
                                {
                                    foreach (string channel in grantAckChannelListDict.Keys)
                                    {
                                        Dictionary <string, object> grantAckChannelDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelListDict[channel]);
                                        if (grantAckChannelDataDict != null && grantAckChannelDataDict.Count > 0)
                                        {
                                            if (grantAckChannelDataDict.ContainsKey("auths"))
                                            {
                                                Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                                Dictionary <string, object> grantAckChannelAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelDataDict["auths"]);
                                                if (grantAckChannelAuthListDict != null && grantAckChannelAuthListDict.Count > 0)
                                                {
                                                    foreach (string authKey in grantAckChannelAuthListDict.Keys)
                                                    {
                                                        Dictionary <string, object> grantAckChannelAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelAuthListDict[authKey]);

                                                        if (grantAckChannelAuthDataDict != null && grantAckChannelAuthDataDict.Count > 0)
                                                        {
                                                            PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckChannelAuthDataDict);
                                                            authKeyDataDict.Add(authKey, authData);
                                                        }
                                                    }

                                                    ack.Channels.Add(channel, authKeyDataDict);
                                                }
                                            }
                                        }
                                    }
                                }
                            }//end of if channels
                            else if (grantAckPayloadDict.ContainsKey("channel"))
                            {
                                ack.Channels = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                string channelName = grantAckPayloadDict["channel"].ToString();
                                if (grantAckPayloadDict.ContainsKey("auths"))
                                {
                                    Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                    Dictionary <string, object> grantAckChannelAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["auths"]);

                                    if (grantAckChannelAuthListDict != null && grantAckChannelAuthListDict.Count > 0)
                                    {
                                        foreach (string authKey in grantAckChannelAuthListDict.Keys)
                                        {
                                            Dictionary <string, object> grantAckChannelAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelAuthListDict[authKey]);
                                            if (grantAckChannelAuthDataDict != null && grantAckChannelAuthDataDict.Count > 0)
                                            {
                                                PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckChannelAuthDataDict);
                                                authKeyDataDict.Add(authKey, authData);
                                            }
                                        }

                                        ack.Channels.Add(channelName, authKeyDataDict);
                                    }
                                }
                            } //end of if channel

                            if (grantAckPayloadDict.ContainsKey("channel-groups"))
                            {
                                ack.ChannelGroups = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                Dictionary <string, object> grantAckCgListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["channel-groups"]);
                                if (grantAckCgListDict != null && grantAckCgListDict.Count > 0)
                                {
                                    foreach (string channelgroup in grantAckCgListDict.Keys)
                                    {
                                        Dictionary <string, object> grantAckCgDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckCgListDict[channelgroup]);
                                        if (grantAckCgDataDict != null && grantAckCgDataDict.Count > 0)
                                        {
                                            if (grantAckCgDataDict.ContainsKey("auths"))
                                            {
                                                Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                                Dictionary <string, object> grantAckCgAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckCgDataDict["auths"]);
                                                if (grantAckCgAuthListDict != null && grantAckCgAuthListDict.Count > 0)
                                                {
                                                    foreach (string authKey in grantAckCgAuthListDict.Keys)
                                                    {
                                                        Dictionary <string, object> grantAckCgAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckCgAuthListDict[authKey]);
                                                        if (grantAckCgAuthDataDict != null && grantAckCgAuthDataDict.Count > 0)
                                                        {
                                                            PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckCgAuthDataDict);
                                                            authKeyDataDict.Add(authKey, authData);
                                                        }
                                                    }

                                                    ack.ChannelGroups.Add(channelgroup, authKeyDataDict);
                                                }
                                            }
                                        }
                                    }
                                }// if no dictionary due to REST bug
                                else
                                {
                                    string channelGroupName = grantAckPayloadDict["channel-groups"].ToString();
                                    if (grantAckPayloadDict.ContainsKey("auths"))
                                    {
                                        Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                        Dictionary <string, object> grantAckChannelAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["auths"]);

                                        if (grantAckChannelAuthListDict != null && grantAckChannelAuthListDict.Count > 0)
                                        {
                                            foreach (string authKey in grantAckChannelAuthListDict.Keys)
                                            {
                                                Dictionary <string, object> grantAckChannelAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelAuthListDict[authKey]);
                                                if (grantAckChannelAuthDataDict != null && grantAckChannelAuthDataDict.Count > 0)
                                                {
                                                    PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckChannelAuthDataDict);
                                                    authKeyDataDict.Add(authKey, authData);
                                                }
                                            }

                                            ack.ChannelGroups.Add(channelGroupName, authKeyDataDict);
                                        }
                                    }
                                } //end of else if for REST bug
                            }     //end of if channel-groups
                            else if (grantAckPayloadDict.ContainsKey("channel-group"))
                            {
                                ack.ChannelGroups = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                string channelGroupName = grantAckPayloadDict["channel-group"].ToString();
                                if (grantAckPayloadDict.ContainsKey("auths"))
                                {
                                    Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                    Dictionary <string, object> grantAckChannelAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["auths"]);

                                    if (grantAckChannelAuthListDict != null && grantAckChannelAuthListDict.Count > 0)
                                    {
                                        foreach (string authKey in grantAckChannelAuthListDict.Keys)
                                        {
                                            Dictionary <string, object> grantAckChannelAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelAuthListDict[authKey]);
                                            if (grantAckChannelAuthDataDict != null && grantAckChannelAuthDataDict.Count > 0)
                                            {
                                                PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckChannelAuthDataDict);
                                                authKeyDataDict.Add(authKey, authData);
                                            }
                                        }

                                        ack.ChannelGroups.Add(channelGroupName, authKeyDataDict);
                                    }
                                }
                            } //end of if channel-group

                            if (grantAckPayloadDict.ContainsKey("uuids"))
                            {
                                ack.Uuids = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                Dictionary <string, object> grantAckCgListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["uuids"]);
                                if (grantAckCgListDict != null && grantAckCgListDict.Count > 0)
                                {
                                    foreach (string uuid in grantAckCgListDict.Keys)
                                    {
                                        Dictionary <string, object> grantAckUuidDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckCgListDict[uuid]);
                                        if (grantAckUuidDataDict != null && grantAckUuidDataDict.Count > 0)
                                        {
                                            if (grantAckUuidDataDict.ContainsKey("auths"))
                                            {
                                                Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                                Dictionary <string, object> grantAckUuidAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckUuidDataDict["auths"]);
                                                if (grantAckUuidAuthListDict != null && grantAckUuidAuthListDict.Count > 0)
                                                {
                                                    foreach (string authKey in grantAckUuidAuthListDict.Keys)
                                                    {
                                                        Dictionary <string, object> grantAckUuidAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckUuidAuthListDict[authKey]);
                                                        if (grantAckUuidAuthDataDict != null && grantAckUuidAuthDataDict.Count > 0)
                                                        {
                                                            PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckUuidAuthDataDict);
                                                            authKeyDataDict.Add(authKey, authData);
                                                        }
                                                    }

                                                    ack.Uuids.Add(uuid, authKeyDataDict);
                                                }
                                            }
                                        }
                                    }
                                }// if no dictionary due to REST bug
                                else
                                {
                                    string targetUuid = grantAckPayloadDict["uuids"].ToString();
                                    if (grantAckPayloadDict.ContainsKey("auths"))
                                    {
                                        Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                        Dictionary <string, object> grantAckUuidAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["auths"]);

                                        if (grantAckUuidAuthListDict != null && grantAckUuidAuthListDict.Count > 0)
                                        {
                                            foreach (string authKey in grantAckUuidAuthListDict.Keys)
                                            {
                                                Dictionary <string, object> grantAckUuidAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckUuidAuthListDict[authKey]);
                                                if (grantAckUuidAuthDataDict != null && grantAckUuidAuthDataDict.Count > 0)
                                                {
                                                    PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckUuidAuthDataDict);
                                                    authKeyDataDict.Add(authKey, authData);
                                                }
                                            }

                                            ack.Uuids.Add(targetUuid, authKeyDataDict);
                                        }
                                    }
                                } //end of else if for REST bug
                            }     //end of if uuids
                            else if (grantAckPayloadDict.ContainsKey("uuid"))
                            {
                                ack.Uuids = new Dictionary <string, Dictionary <string, PNAccessManagerKeyData> >();

                                string uuid = grantAckPayloadDict["uuid"].ToString();
                                if (grantAckPayloadDict.ContainsKey("auths"))
                                {
                                    Dictionary <string, PNAccessManagerKeyData> authKeyDataDict = new Dictionary <string, PNAccessManagerKeyData>();

                                    Dictionary <string, object> grantAckChannelAuthListDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckPayloadDict["auths"]);

                                    if (grantAckChannelAuthListDict != null && grantAckChannelAuthListDict.Count > 0)
                                    {
                                        foreach (string authKey in grantAckChannelAuthListDict.Keys)
                                        {
                                            Dictionary <string, object> grantAckChannelAuthDataDict = JsonDataParseInternalUtil.ConvertToDictionaryObject(grantAckChannelAuthListDict[authKey]);
                                            if (grantAckChannelAuthDataDict != null && grantAckChannelAuthDataDict.Count > 0)
                                            {
                                                PNAccessManagerKeyData authData = GetAccessManagerKeyData(grantAckChannelAuthDataDict);
                                                authKeyDataDict.Add(authKey, authData);
                                            }
                                        }

                                        ack.Uuids.Add(uuid, authKeyDataDict);
                                    }
                                }
                            } //end of if uuid
                        }     //end of else subkey
                    }
                }
            }

            return(ack);
        }