diff --git a/src/Api/PubnubApi/Builder/UrlParameterConverter.cs b/src/Api/PubnubApi/Builder/UrlParameterConverter.cs index 6b8dc1562..e006be989 100644 --- a/src/Api/PubnubApi/Builder/UrlParameterConverter.cs +++ b/src/Api/PubnubApi/Builder/UrlParameterConverter.cs @@ -28,6 +28,14 @@ public static string MapEnumValueToEndpoint(string enumValue) { endpointParameterName = "uuid.custom"; } + else if (enumValue.ToLowerInvariant() == "status") + { + endpointParameterName = "status"; + } + else if (enumValue.ToLowerInvariant() == "type") + { + endpointParameterName = "type"; + } return endpointParameterName; } diff --git a/src/Api/PubnubApi/EndPoint/Objects/SetMembershipsOperation.cs b/src/Api/PubnubApi/EndPoint/Objects/SetMembershipsOperation.cs index 7d90fc67e..a47a02c56 100644 --- a/src/Api/PubnubApi/EndPoint/Objects/SetMembershipsOperation.cs +++ b/src/Api/PubnubApi/EndPoint/Objects/SetMembershipsOperation.cs @@ -204,13 +204,20 @@ private RequestParameter CreateRequestParameter() Dictionary messageEnvelope = new Dictionary(); if (addMembership != null) { List> setMembershipFormatList = new List>(); - for (int index = 0; index < addMembership.Count; index++) { + foreach (var membership in addMembership) + { Dictionary currentMembershipFormat = new Dictionary { - { "channel", new Dictionary { { "id", addMembership[index].Channel } } } + { "channel", new Dictionary { { "id", membership.Channel } } } }; - if (addMembership[index].Custom != null) { - currentMembershipFormat.Add("custom", addMembership[index].Custom); + if (membership.Custom != null) { + currentMembershipFormat.Add("custom", membership.Custom); + } + if (membership.Status != null) { + currentMembershipFormat.Add("status", membership.Status); + } + if (membership.Type != null) { + currentMembershipFormat.Add("type", membership.Type); } setMembershipFormatList.Add(currentMembershipFormat); } diff --git a/src/Api/PubnubApi/Enum/PNMembershipField.cs b/src/Api/PubnubApi/Enum/PNMembershipField.cs index 1ff35f9bf..89f984453 100644 --- a/src/Api/PubnubApi/Enum/PNMembershipField.cs +++ b/src/Api/PubnubApi/Enum/PNMembershipField.cs @@ -9,6 +9,8 @@ public enum PNMembershipField { CUSTOM, CHANNEL, - CHANNEL_CUSTOM + CHANNEL_CUSTOM, + STATUS, + TYPE } } diff --git a/src/Api/PubnubApi/EventEngine/Common/EventEmitter.cs b/src/Api/PubnubApi/EventEngine/Common/EventEmitter.cs index fac46405b..31aa68c31 100644 --- a/src/Api/PubnubApi/EventEngine/Common/EventEmitter.cs +++ b/src/Api/PubnubApi/EventEngine/Common/EventEmitter.cs @@ -229,6 +229,7 @@ public void EmitEvent(object e) } } } else if (eventData.MessageType == 4) { + payloadContainer.Add(eventData.CustomMessageType); ResponseBuilder responseBuilder = new ResponseBuilder(configuration, jsonLibrary, log); PNMessageResult pnFileResult = responseBuilder.JsonToObject>(payloadContainer, true); if (pnFileResult != null) { diff --git a/src/Api/PubnubApi/JsonDataParse/PNMembershipsJsonDataParse.cs b/src/Api/PubnubApi/JsonDataParse/PNMembershipsJsonDataParse.cs index 6ef03e78c..01a5ac2a7 100644 --- a/src/Api/PubnubApi/JsonDataParse/PNMembershipsJsonDataParse.cs +++ b/src/Api/PubnubApi/JsonDataParse/PNMembershipsJsonDataParse.cs @@ -53,6 +53,17 @@ internal static PNMembershipsResult GetObject(IJsonPluggableLibrary jsonPlug, Li mbrshipItem.ChannelMetadata = channelMetadataResult; } } + + mbrshipItem.Status = + (getMbrshipItemDataDic.ContainsKey("status") && + getMbrshipItemDataDic["status"] != null) + ? getMbrshipItemDataDic["status"]?.ToString() + : null; + mbrshipItem.Type = + (getMbrshipItemDataDic.ContainsKey("type") && + getMbrshipItemDataDic["type"] != null) + ? getMbrshipItemDataDic["type"]?.ToString() + : null; result.Memberships.Add(mbrshipItem); } } diff --git a/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs b/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs index ea2d2824d..1cf47116a 100644 --- a/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs +++ b/src/Api/PubnubApi/JsonDataParse/PNObjectEventJsonDataParse.cs @@ -88,12 +88,8 @@ internal static PNObjectEventResult GetObject(IJsonPluggableLibrary jsonPlug, Li } } } - if (listObject.Count == 6) { - result.Subscription = listObject[4].ToString(); - result.Channel = listObject[5].ToString(); - } else if (listObject.Count == 5) { - result.Channel = listObject[4].ToString(); - } + result.Subscription = listObject[4]?.ToString(); + result.Channel = listObject[5].ToString(); } return result; diff --git a/src/Api/PubnubApi/Model/Consumer/Objects/PNMembership.cs b/src/Api/PubnubApi/Model/Consumer/Objects/PNMembership.cs index a4c122a0f..40fda8f6e 100644 --- a/src/Api/PubnubApi/Model/Consumer/Objects/PNMembership.cs +++ b/src/Api/PubnubApi/Model/Consumer/Objects/PNMembership.cs @@ -13,5 +13,11 @@ public class PNMembership [JsonProperty(PropertyName = "custom", DefaultValueHandling = DefaultValueHandling.Ignore)] public Dictionary Custom { get; set; } + + [JsonProperty(PropertyName = "status", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Status { get; set; } + + [JsonProperty(PropertyName = "type", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Type { get; set; } } } diff --git a/src/Api/PubnubApi/Model/Consumer/Objects/PNMembershipsItemResult.cs b/src/Api/PubnubApi/Model/Consumer/Objects/PNMembershipsItemResult.cs index 296d09c5d..a570519cc 100644 --- a/src/Api/PubnubApi/Model/Consumer/Objects/PNMembershipsItemResult.cs +++ b/src/Api/PubnubApi/Model/Consumer/Objects/PNMembershipsItemResult.cs @@ -9,6 +9,10 @@ public class PNMembershipsItemResult { public PNChannelMetadataResult ChannelMetadata { get; internal set; } public Dictionary Custom { get; internal set; } + + public string Type { get; set; } + + public string Status { get; set; } public string Updated { get; internal set; } } } diff --git a/src/Api/PubnubApi/Model/Consumer/Pubsub/PNFileEventResult.cs b/src/Api/PubnubApi/Model/Consumer/Pubsub/PNFileEventResult.cs index d1689ecaf..de4a00cdb 100644 --- a/src/Api/PubnubApi/Model/Consumer/Pubsub/PNFileEventResult.cs +++ b/src/Api/PubnubApi/Model/Consumer/Pubsub/PNFileEventResult.cs @@ -12,7 +12,7 @@ public class PNFileEventResult public string Publisher { get; internal set; } public long Timetoken { get; internal set; } - public string CustomMessageType { get; set; } + public string CustomMessageType { get; internal set; } public object Message { get; internal set; } public PNFile File { get; internal set; } } diff --git a/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs b/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs index 317603f2e..0f1d91a12 100644 --- a/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs +++ b/src/Api/PubnubApi/Model/Derived/Pubsub/SubscribeCallbackExt.cs @@ -247,6 +247,7 @@ public override void File(Pubnub pubnub, PNFileEventResult fileEvent) message1.Timetoken = fileEvent.Timetoken; message1.Publisher = fileEvent.Publisher; message1.File = fileEvent.File; + message1.CustomMessageType = fileEvent.CustomMessageType; fileAction?.Invoke(pubnub, message1); }