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); }
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 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); }
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); }
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); }
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); }