예제 #1
0
        public void CreateIncomingNumberTest()
        {
            try
            {
                IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(requester, "http://CreateIncomingTest:3000");
                }

                WebRequest.RegisterPrefix("http://CreateIncomingTest:3000", new TestWebRequestCreate());

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{ \"phoneNumber\" : \"+13122290330\", \"alias\" : \"incoming number 1\", \"revision\" : 2, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:25 GMT\", \"dateUpdated\" : \"Wed, 01 Feb 2017 19:33:00 GMT\", \"phoneNumberId\" : \"PN3816047eda7b012ea2cf6d5e0697a2474363dcd6\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : \"APbd38defccbf9a1db844551aa8ae0531a876bc84b\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PN3816047eda7b012ea2cf6d5e0697a2474363dcd6\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"} ");
                IncomingPhoneNumberOptions options = new IncomingPhoneNumberOptions();
                options.setAlias("incoming number 1");
                options.setApplicationId("APbd38defccbf9a1db844551aa8ae0531a876bc84b");
                IncomingPhoneNumber num = requester.create("+13122290330", options);

                Assert.IsNotNull(num);
                Assert.AreEqual(num.getAlias, "incoming number 1");
                Assert.AreEqual(num.getPhoneNumber, "+13122290330");
                Assert.IsNotNull(num.getPhoneNumberId);
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
예제 #2
0
        public void GetIncomingNumberTest()
        {
            try
            {
                IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(requester, "http://GetIncomingTest:3000");
                }

                WebRequest.RegisterPrefix("http://GetIncomingTest:3000", new TestWebRequestCreate());

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"phoneNumber\" : \"+13126516046\", \"alias\" : \"312-651-6046\", \"revision\" : 2, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:22 GMT\", \"dateUpdated\" : \"Thu, 08 Dec 2016 20:41:18 GMT\", \"phoneNumberId\" : \"PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : \"APbd38defccbf9a1db844551aa8ae0531a876bc84b\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}");


                IncomingPhoneNumber num = requester.get("PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701");

                Assert.IsNotNull(num);
                Assert.AreEqual(num.getPhoneNumberId, "PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
예제 #3
0
        public void GetIncomingNumberListTest()
        {
            try
            {
                IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(requester, "http://GetIncomingListTest:3000");
                }

                WebRequest.RegisterPrefix("http://GetIncomingListTest: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\", \"incomingPhoneNumbers\" : [{\"phoneNumber\" : \"+13126516046\", \"alias\" : \"312-651-6046\", \"revision\" : 2, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:22 GMT\", \"dateUpdated\" : \"Thu, 08 Dec 2016 20:41:18 GMT\", \"phoneNumberId\" : \"PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : \"APbd38defccbf9a1db844551aa8ae0531a876bc84b\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}, {\"phoneNumber\" : \"+13124881429\", \"alias\" : \"312-488-1429\", \"revision\" : 2, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:24 GMT\", \"dateUpdated\" : \"Sun, 15 Jan 2017 18:37:53 GMT\", \"phoneNumberId\" : \"PN5b881cc45548df1d015b7450fa9e3f1e301e1b97\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : \"APabfb2706f416285399ae6bdd96d07b3416f6d4ce\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PN5b881cc45548df1d015b7450fa9e3f1e301e1b97\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}");


                IncomingPhoneNumberList list = requester.get();

                Assert.IsNotNull(list);

                Assert.AreEqual(list.getLocalSize, 2);
                Assert.AreEqual((list.export()).Count, 2);

                IncomingPhoneNumber num = list.get(0) as IncomingPhoneNumber;

                Assert.IsNotNull(num);
                Assert.AreEqual(num.getPhoneNumberId, "PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701");

                type      = typeof(APIRequester);
                fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(list, "http://GetIncomingListTest:3000");
                }

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null, \"incomingPhoneNumbers\" : [{\"phoneNumber\" : \"+13129975947\", \"alias\" : \"312-997-5947\", \"revision\" : 1, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:24 GMT\", \"dateUpdated\" : \"Thu, 26 Jan 2017 16:37:43 GMT\", \"phoneNumberId\" : \"PNeced5e8f2764adcc0cd0637bc52e6f45583458a6\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : null, \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PNeced5e8f2764adcc0cd0637bc52e6f45583458a6\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}");

                list.loadNextPage();

                Assert.IsNotNull(list);

                Assert.AreEqual(list.getLocalSize, 3);
                Assert.AreEqual((list.export()).Count, 3);

                num = list.get(2) as IncomingPhoneNumber;
                Assert.IsNotNull(num);
                Assert.AreEqual(num.getPhoneNumberId, "PNeced5e8f2764adcc0cd0637bc52e6f45583458a6");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        public void GetIncomingNumberListUsingFilterTest()
        {
            try
            {
                IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("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\" : 100, \"nextPageUri\" : null, \"incomingPhoneNumbers\" : [{\"phoneNumber\" : \"+13126516046\", \"alias\" : \"312-651-6046\", \"revision\" : 2, \"dateCreated\" : \"Fri, 11 Nov 2016 13:42:22 GMT\", \"dateUpdated\" : \"Thu, 08 Dec 2016 20:41:18 GMT\", \"phoneNumberId\" : \"PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"region\" : \"Illinois\", \"country\" : \"US\", \"voiceEnabled\" : true, \"smsEnabled\" : true, \"applicationId\" : \"APbd38defccbf9a1db844551aa8ae0531a876bc84b\", \"uri\" : \"/Accounts/AC907d7e328b3a5b402fa908857e047a243a8949b1/IncomingPhoneNumbers/PN5fdc25a5db02d03aa1da1f85f18d6bfa6e45a701\", \"accountId\" : \"AC907d7e328b3a5b402fa908857e047a243a8949b1\"}]}");

                IncomingPhoneNumbersSearchFilter filter = new IncomingPhoneNumbersSearchFilter();
                filter.setPhoneNumber("^\\+1[0-9]{10}$");
                filter.setAlias("312-651-6046");
                IncomingPhoneNumberList list = requester.get(filter);

                Assert.IsNotNull(list);

                Assert.AreEqual(list.getLocalSize, 1);
                Assert.AreEqual((list.export()).Count, 1);

                IncomingPhoneNumber num = list.get(0) as IncomingPhoneNumber;

                Assert.IsNotNull(num);
                Assert.AreEqual(num.getPhoneNumber, "+13126516046");
                Assert.AreEqual(num.getAlias, "312-651-6046");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
예제 #6
0
        public void DeleteIncomingNumberTest()
        {
            try
            {
                IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(requester, "http://DeleteIncomingTest:3000");
                }

                WebRequest.RegisterPrefix("http://DeleteIncomingTest:3000", new TestWebRequestCreate());

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK);

                requester.delete("PN3816047eda7b012ea2cf6d5e0697a2474363dcd6");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }