public void TestBuildGetChannelsPushRequestCommon(bool ssl, string authKey, string pushToken, PNPushType pushType, bool sendQueryParams) { string uuid = "customuuid"; Dictionary <string, string> queryParams = new Dictionary <string, string>(); string queryParamString = ""; if (sendQueryParams) { queryParams.Add("d", "f"); queryParamString = "&d=f"; } else { queryParams = null; } PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.Origin = EditorCommon.Origin; pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey; pnConfiguration.PublishKey = EditorCommon.PublishKey; pnConfiguration.Secure = ssl; pnConfiguration.CipherKey = "enigma"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.PresenceTimeout = 60; pnConfiguration.PresenceInterval = 30; pnConfiguration.UUID = uuid; pnConfiguration.AuthKey = authKey; PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null); string authKeyString = ""; if (!string.IsNullOrEmpty(authKey)) { authKeyString = string.Format("&auth={0}", pnConfiguration.AuthKey); } Uri uri = BuildRequests.BuildGetChannelsPushRequest(pushType, pushToken, pnUnity, queryParams); //[1, "Modified Channels"] //["push_channel"] //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0 //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken?type=mpns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0 string expected = string.Format("http{0}://{1}/v1/push/sub-key/{2}/devices/{3}?type={4}&uuid={5}{6}&pnsdk={7}{8}", ssl?"s":"", pnConfiguration.Origin, EditorCommon.SubscribeKey, pushToken, pushType.ToString().ToLower(), uuid, authKeyString, Utility.EncodeUricomponent(pnUnity.Version, PNOperationType.PNPushNotificationEnabledChannelsOperation, false, true), queryParamString ); string received = uri.OriginalString; UnityEngine.Debug.Log("exp:" + expected); UnityEngine.Debug.Log(received); EditorCommon.LogAndCompare(expected, received); }
public static Uri BuildGetChannelsPushRequest(PNPushType pushType, string pushToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNPushNotificationEnabledChannelsOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildRemoveChannelPushRequest(string channel, PNPushType pushType, string pushToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?remove={0}", Utility.EncodeUricomponent(channel, PNOperationType.PNRemoveChannelsFromGroupOperation, true, false)); parameterBuilder.AppendFormat("&type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNRemoveChannelsFromGroupOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildUnregisterDevicePushRequest(PNPushType pushType, string pushToken, PubNubUnity pnInstance) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); url.Add("remove"); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNRemoveAllPushNotificationsOperation, parameterBuilder.ToString(), pnInstance)); }
public static Uri BuildRegisterDevicePushRequest(string channel, PNPushType pushType, string pushToken, PubNubUnity pnInstance) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?add={0}", Utility.EncodeUricomponent(channel, PNOperationType.PNAddPushNotificationsOnChannelsOperation, true, false)); parameterBuilder.AppendFormat("&type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNAddPushNotificationsOnChannelsOperation, parameterBuilder.ToString(), pnInstance)); }
public void BuildUnregisterDevicePushRequestCommon(bool ssl, string authKey, string pushToken, PNPushType pushType) { string uuid = "customuuid"; PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.Origin = EditorCommon.Origin; pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey; pnConfiguration.PublishKey = EditorCommon.PublishKey; pnConfiguration.Secure = ssl; pnConfiguration.CipherKey = "enigma"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.PresenceTimeout = 60; pnConfiguration.PresenceInterval = 30; pnConfiguration.UUID = uuid; pnConfiguration.AuthKey = authKey; PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null); string authKeyString = ""; if (!string.IsNullOrEmpty(authKey)) { authKeyString = string.Format("&auth={0}", pnConfiguration.AuthKey); } Uri uri = BuildRequests.BuildUnregisterDevicePushRequest(pushType, pushToken, pnUnity); //[1, "Removed Device"] //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken/remove?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0 string expected = string.Format("http{0}://{1}/v1/push/sub-key/{2}/devices/{3}/remove?type={4}&uuid={5}{6}&pnsdk={7}", ssl?"s":"", pnConfiguration.Origin, EditorCommon.SubscribeKey, pushToken, pushType.ToString().ToLower(), uuid, authKeyString, Utility.EncodeUricomponent(pnUnity.Version, PNOperationType.PNRemoveAllPushNotificationsOperation, false, true) ); string received = uri.OriginalString; UnityEngine.Debug.Log("exp:" + expected); UnityEngine.Debug.Log(received); EditorCommon.LogAndCompare(expected, received); }
Uri IUrlRequestBuilder.BuildGetChannelsPushRequest(PNPushType pushType, string pushToken) { PNOperationType currentType = PNOperationType.PushGet; List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pubnubConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken.ToString()); Dictionary <string, string> requestQueryStringParams = new Dictionary <string, string>(); requestQueryStringParams.Add("type", pushType.ToString().ToLower()); string queryString = BuildQueryString(currentType, url, requestQueryStringParams); string queryParams = string.Format("?{0}", queryString); return(BuildRestApiRequest <Uri>(url, currentType, queryParams)); }
Uri IUrlRequestBuilder.BuildRemoveChannelPushRequest(string channel, PNPushType pushType, string pushToken) { PNOperationType currentType = PNOperationType.PushRemove; List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pubnubConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken.ToString()); Dictionary <string, string> requestQueryStringParams = new Dictionary <string, string>(); requestQueryStringParams.Add("type", pushType.ToString().ToLower()); requestQueryStringParams.Add("remove", new UriUtil().EncodeUriComponent(channel, currentType, true, false, false)); string queryString = BuildQueryString(currentType, url, requestQueryStringParams); string queryParams = string.Format("?{0}", queryString); return(BuildRestApiRequest <Uri>(url, currentType, queryParams)); }
public void BuildUnregisterDevicePushRequestCommon(bool ssl, string authKey, string pushToken, PNPushType pushType, bool sendQueryParams, bool withAPNS2, bool withEnvProd, bool withTopic) { string uuid = "customuuid"; Dictionary <string, string> queryParams = new Dictionary <string, string>(); string queryParamString = ""; if (sendQueryParams) { queryParams.Add("d", "f"); queryParamString = "&d=f"; } else { queryParams = null; } PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.Origin = EditorCommon.Origin; pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey; pnConfiguration.PublishKey = EditorCommon.PublishKey; pnConfiguration.Secure = ssl; pnConfiguration.CipherKey = "enigma"; pnConfiguration.LogVerbosity = PNLogVerbosity.BODY; pnConfiguration.PresenceTimeout = 60; pnConfiguration.PresenceInterval = 30; pnConfiguration.UUID = uuid; pnConfiguration.AuthKey = authKey; PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null); string authKeyString = ""; if (!string.IsNullOrEmpty(authKey)) { authKeyString = string.Format("&auth={0}", pnConfiguration.AuthKey); } Uri uri = BuildRequests.BuildRemoveAllDevicePushRequest(pushType, pushToken, pnUnity, queryParams); if (withAPNS2) { uri = BuildRequests.BuildRemoveAllDevicePushRequest(pushType, pushToken, pnUnity, queryParams, (withTopic)?"topic":"", (withEnvProd)?PNPushEnvironment.Production: PNPushEnvironment.Development); } //[1, "Removed Device"] //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken/remove?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0 string expected = string.Format("http{0}://{1}/{9}/push/sub-key/{2}/{10}/{3}/remove?type={4}{12}{11}&uuid={5}{6}&pnsdk={7}{8}", ssl?"s":"", pnConfiguration.Origin, EditorCommon.SubscribeKey, pushToken, pushType.ToString().ToLower(), uuid, authKeyString, Utility.EncodeUricomponent(pnUnity.Version, PNOperationType.PNRemoveAllPushNotificationsOperation, false, true), queryParamString, (withAPNS2)?"v2":"v1", (withAPNS2)?"devices-apns2":"devices", (withAPNS2)?((withEnvProd)?"&environment=production":"&environment=development"):"", (withAPNS2)?((withTopic)?"&topic=topic":""):"" ); string received = uri.OriginalString; UnityEngine.Debug.Log("exp:" + expected); UnityEngine.Debug.Log(received); EditorCommon.LogAndCompare(expected, received); }