public void UpdateAccountTest() { try { AccountsRequester accountRequester = new AccountsRequester("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747", "e1b6406c8db5369912234f006ce1cbaa267561da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(accountRequester, "http://CreateAccountTest:3000"); } WebRequest.RegisterPrefix("http://CreateAccountTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"revision\" : 3, \"dateCreated\" : \"Mon, 30 Jan 2017 16:30:49 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 17:31:47 GMT\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"authToken\" : \"e1b6406c8db5369912234f006ce1cbaa267561da\", \"alias\" : \"new test account 1\", \"label\" : \"test account 1 label\", \"type\" : \"trial\", \"status\" : \"active\", \"subresourceUris\" : {\"applications\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications\", \"calls\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Calls\", \"availablePhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/AvailablePhoneNumbers\", \"conferences\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Conferences\", \"incomingPhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/IncomingPhoneNumbers\", \"logs\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Logs\", \"callingNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/CallingNumbers\", \"recordings\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Recordings\", \"queues\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Queues\"}}"); AccountOptions options = new AccountOptions(); options.setAlias("new test account 1"); options.setLabel("test account 1 label"); Account account = accountRequester.update("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747"); Assert.IsNotNull(account); Assert.AreEqual(account.getAlias, "new test account 1"); Assert.AreEqual(account.getLabel, "test account 1 label"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void GetAccountTest() { try { AccountsRequester accountRequester = new AccountsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(accountRequester, "http://GetAccountTest:3000"); } WebRequest.RegisterPrefix("http://GetAccountTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"revision\" : 3, \"dateCreated\" : \"Mon, 30 Jan 2017 16:30:49 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 17:31:47 GMT\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"authToken\" : \"e1b6406c8db5369912234f006ce1cbaa267561da\", \"alias\" : \"new test account 1\", \"label\" : \"test account 1 label\", \"type\" : \"trial\", \"status\" : \"active\", \"subresourceUris\" : {\"applications\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications\", \"calls\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Calls\", \"availablePhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/AvailablePhoneNumbers\", \"conferences\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Conferences\", \"incomingPhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/IncomingPhoneNumbers\", \"logs\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Logs\", \"callingNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/CallingNumbers\", \"recordings\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Recordings\", \"queues\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Queues\"}}"); Account account = accountRequester.get("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747"); Assert.IsNotNull(account); Assert.AreEqual(account.getAccountId, "AC66c1bebe590a6389f60efa0ee9ce74d44bc29747"); } 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 DeleteAccountTest() { try { AccountsRequester accountRequester = new AccountsRequester("ACabe7063197551fe51671f9ac3a9708e9dad51c4d", "204c15aae7a486c42776aea4dbafe8c68a773071"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(accountRequester, "http://DeleteAccountTest:3000"); } WebRequest.RegisterPrefix("http://DeleteAccountTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); accountRequester.delete("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }