public void SetUp() { var appKey = ""; var appSecret = ""; var password = ""; if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APP_KEY"))) { appKey = Environment.GetEnvironmentVariable("APP_KEY"); } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APP_SECRET"))) { appSecret = Environment.GetEnvironmentVariable("APP_SECRET"); } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("USER_NAME"))) { UserName = Environment.GetEnvironmentVariable("USER_NAME"); ToPhone = UserName; } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PASSWORD"))) { password = Environment.GetEnvironmentVariable("PASSWORD"); } RingCentralClient = new RingCentral.SDK.SDK(appKey, appSecret, ApiEndPoint,"C Sharp Test Suite", "1.0.0"); Platform = RingCentralClient.GetPlatform(); Platform._client = new HttpClient(MockResponseHandler) { BaseAddress = new Uri(ApiEndPoint) }; AuthResult = Platform.Authorize(UserName, Extension, password, true); }
void run(Platform platform,Response response) { System.Console.WriteLine(response.GetBody()); //adding event filters var body = "{\r\n \"eventFilters\": [ \r\n \"/restapi/v1.0/account/~/extension/~/presence\", \r\n \"/restapi/v1.0/account/~/extension/~/message-store\" \r\n ], \r\n \"deliveryMode\": { \r\n \"transportType\": \"PubNub\", \r\n \"encryption\": \"false\" \r\n } \r\n}"; Request request = new Request("/restapi/v1.0/subscription", body); response = platform.Post(request); //getSubscription JToken bodyString = response.GetJson(); string encryptionKey = (string)bodyString.SelectToken("deliveryMode").SelectToken("encryptionKey"); string subscriberKey = (string)bodyString.SelectToken("deliveryMode").SelectToken("subscriberKey"); string address = (string)bodyString.SelectToken("deliveryMode").SelectToken("address"); string secretKey = "<SECRET_KEY>";//deliveryMode.getString("secretKey"); encryptkey = encryptionKey; System.Console.WriteLine(subscriberKey); //Subscribe to Pubnub's subscription channel Pubnub pubnub = new Pubnub("", subscriberKey, secretKey); pubnub.Subscribe<string>(address, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage); System.Console.ReadLine(); }