public void CreateCallingNumberTest() { try { CallingNumbersRequester requester = new CallingNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://CreateCallingTest:3000"); } WebRequest.RegisterPrefix("http://CreateCallingTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{ \"phoneNumber\" : \"+13033447438\", \"alias\" : \"Calling number 1\", \"revision\" : 1, \"dateCreated\" : \"Wed, 01 Feb 2017 17:33:27 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 17:33:27 GMT\", \"callingNumberId\" : \"PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/CallingNumbers/PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}"); CallingNumberOptions options = new CallingNumberOptions(); options.setAlias("Calling number 1"); CallingNumber num = requester.create("+13033447438", options); Assert.IsNotNull(num); Assert.AreEqual(num.getAlias, "Calling number 1"); Assert.AreEqual(num.getPhoneNumber, "+13033447438"); Assert.IsNotNull(num.getCallingNumberId); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void GetCallingNumberListTest() { try { CallingNumbersRequester requester = new CallingNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://GetCallingListTest:3000"); } WebRequest.RegisterPrefix("http://GetCallingListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/CallingNumbers&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"callingNumbers\" : [{\"phoneNumber\" : \"+13033447438\", \"alias\" : \"new Calling number 1\", \"revision\" : 2, \"dateCreated\" : \"Wed, 01 Feb 2017 17:33:27 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 17:42:00 GMT\", \"callingNumberId\" : \"PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/CallingNumbers/PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}, {\"phoneNumber\" : \"+13033447440\", \"alias\" : \"Calling number 2\", \"revision\" : 1, \"dateCreated\" : \"Wed, 01 Feb 2017 17:33:43 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 17:33:43 GMT\", \"callingNumberId\" : \"PNef08e0fcf2e37067d3f0a190671c6d0d45cefb63\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/CallingNumbers/PNef08e0fcf2e37067d3f0a190671c6d0d45cefb63\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}"); CallingNumberList list = requester.get(); Assert.IsNotNull(list); Assert.AreEqual(list.getLocalSize, 2); Assert.AreEqual((list.export()).Count, 2); CallingNumber num = list.get(0) as CallingNumber; Assert.IsNotNull(num); Assert.AreEqual(num.getCallingNumberId, "PN7bbef986a434fd30ba006551ed6cc507403b5e87"); type = typeof(APIRequester); fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(list, "http://GetCallingListTest:3000"); } TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null, \"callingNumbers\" : [ {\"phoneNumber\" : \"+13033447440\", \"alias\" : \"Calling number 2\", \"revision\" : 1, \"dateCreated\" : \"Wed, 01 Feb 2017 17:33:43 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 17:33:43 GMT\", \"callingNumberId\" : \"PNef08e0fcf2e37067d3f0a190671c6d0d45cefb63\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/CallingNumbers/PNef08e0fcf2e37067d3f0a190671c6d0d45cefb63\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}"); list.loadNextPage(); Assert.IsNotNull(list); Assert.AreEqual(list.getLocalSize, 3); Assert.AreEqual((list.export()).Count, 3); num = list.get(2) as CallingNumber; Assert.IsNotNull(num); Assert.AreEqual(num.getCallingNumberId, "PNef08e0fcf2e37067d3f0a190671c6d0d45cefb63"); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
/// <summary> /// This constructor allows one to create a PersyClient that authenticates /// with one set of credentials but acts as a second account (i.e. a sub /// account). /// </summary> /// <param name="credAccountId">The Account ID to use in your credentials for the Persephony API.</param> /// <param name="credAuthToken">The Auth Token to use in your credentials for the Persephony API. This should be the matching Auth Token to the credAccountId parameter.</param> /// <param name="accountId">The Account ID of the account you want to act as. This should either be the same Account ID ass credAccountId or the id of a sub-account to the credAccountId's account.</param> /// <exception cref="PersyException">Thrown upon failed request.</exception> public PersyClient(string credAccountId, string credAuthToken, string accountId) { this.credAccountId = credAccountId; this.credAuthToken = credAuthToken; this.accountId = accountId; calls = new CallsRequester(credAccountId, credAuthToken, accountId); recordings = new RecordingsRequester(credAccountId, credAuthToken, accountId); conferences = new ConferencesRequester(credAccountId, credAuthToken, accountId); queues = new QueuesRequester(credAccountId, credAuthToken, accountId); applications = new ApplicationsRequester(credAccountId, credAuthToken, accountId); logs = new LogsRequester(credAccountId, credAuthToken, accountId); availablePhoneNumbers = new AvailablePhoneNumbersRequester(credAccountId, credAuthToken, accountId); incomingPhoneNumbers = new IncomingPhoneNumbersRequester(credAccountId, credAuthToken, accountId); callingNumbers = new CallingNumbersRequester(credAccountId, credAuthToken, accountId); accounts = new AccountsRequester(credAccountId, credAuthToken); }
public void GetCallingNumberListUsingFilterTest() { try { CallingNumbersRequester requester = new CallingNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://GetCallingListTest:3000"); } WebRequest.RegisterPrefix("http://GetCallingListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":1,\"start\":0,\"end\":0,\"page\":0,\"numPages\":1,\"pageSize\":2,\"nextPageUri\":null, \"callingNumbers\" : [{\"phoneNumber\" : \"+13033447438\", \"alias\" : \"Calling number 1\", \"revision\" : 2, \"dateCreated\" : \"Wed, 01 Feb 2017 17:33:27 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 17:42:00 GMT\", \"callingNumberId\" : \"PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/CallingNumbers/PN7bbef986a434fd30ba006551ed6cc507403b5e87\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}"); CallingNumbersSearchFilter filter = new CallingNumbersSearchFilter(); filter.setPhoneNumber("+13033447438"); filter.setAlias("Calling number 1"); CallingNumberList list = requester.get(filter); Assert.IsNotNull(list); Assert.AreEqual(list.getLocalSize, 1); Assert.AreEqual((list.export()).Count, 1); CallingNumber num = list.get(0) as CallingNumber; Assert.IsNotNull(num); Assert.AreEqual(num.getPhoneNumber, "+13033447438"); Assert.AreEqual(num.getAlias, "Calling number 1"); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void DeleteCallingNumberTest() { try { CallingNumbersRequester requester = new CallingNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://DeleteCallingTest:3000"); } WebRequest.RegisterPrefix("http://DeleteCallingTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); requester.delete("PN7bbef986a434fd30ba006551ed6cc507403b5e87"); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }