Пример #1
0
        public void GetLogListTest()
        {
            try
            {
                LogsRequester requester = new LogsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

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

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

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Applications&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"logs\" : [{\"hostname\":\"spv07vcs10\",\"subsystem\":\"vcsserver\",\"timestamp\":1485450179059490,\"scope\":\"public\",\"level\":\"info\",\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"requestId\":\"RQ5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"message\":\"Customer Response 200 : POST http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/CallStatus\",\"metadata\":{}},{\"hostname\":\"spv07vcs10\",\"subsystem\":\"vcsserver\",\"timestamp\":1485450178755768,\"scope\":\"public\",\"level\":\"info\",\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"requestId\":\"RQ5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"message\":\"Customer Request : POST http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/CallStatus\",\"metadata\":{\"requestBody\":{\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"callDuration\":7,\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"callStatus\":\"completed\",\"conferenceId\":null,\"direction\":\"inbound\",\"from\":\"+13038472859\",\"parentCallId\":null,\"queueId\":null,\"requestType\":\"callStatus\",\"to\":\"+13124881429\"},\"requestHeaders\":{\"X-Pulse-Signature\":\"a80fc8c501a7b46a1864d16572882ff86712317a\",\"X-Pulse-Timestamp\":1485450178,\"url\":\"http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/CallStatus\"}}}]}");

                LogList logList = requester.get();

                Assert.IsNotNull(logList);

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

                Log log = logList.get(0) as Log;

                Assert.IsNotNull(log);
                Assert.AreEqual(log.getCallId, "CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f");
                Assert.AreEqual(log.getRequestId, "RQ5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f");

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

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null, \"logs\" : [ {\"hostname\":\"spv07vcs10\",\"subsystem\":\"vcsserver\",\"timestamp\":1485450178603416,\"scope\":\"public\",\"level\":\"info\",\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"requestId\":null,\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"message\":\"Customer Response 200 : POST http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/NextQuestion\",\"metadata\":[{\"GetSpeech\":{\"actionUrl\":\"http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/HandleQuestionResponse\",\"grammarFile\":\"http://172.29.11.10/FreeClimbSurvey/Grammars/969d88d2-8edb-4ad9-8436-aa0c4d268f56.grxml\",\"grammarRule\":\"Choices\",\"grammarType\":\"URL\",\"noInputTimeoutMs\":4000,\"prompts\":[{\"Say\":{\"text\":\"what is your favorite color\"}}],\"recognitionTimeoutMs\":5000}}]}]}");

                logList.loadNextPage();

                Assert.IsNotNull(logList);

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

                log = logList.get(2) as Log;
                Assert.IsNotNull(log);
                Assert.AreEqual(log.getCallId, "CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f");
                Assert.IsNull(log.getRequestId);
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
Пример #2
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);
        }
Пример #3
0
        public void GetLogListUsingPqlTest()
        {
            try
            {
                LogsRequester requester = new LogsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

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

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

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":1,\"start\":0,\"end\":0,\"page\":0,\"numPages\":1,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Applications&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"logs\" : [{\"hostname\":\"spv07vcs10\",\"subsystem\":\"vcsserver\",\"timestamp\":1485450178603416,\"scope\":\"public\",\"level\":\"info\",\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"requestId\":null,\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"message\":\"Customer Response 200 : POST http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/NextQuestion\",\"metadata\":[{\"GetSpeech\":{\"actionUrl\":\"http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/HandleQuestionResponse\",\"grammarFile\":\"http://172.29.11.10/FreeClimbSurvey/Grammars/969d88d2-8edb-4ad9-8436-aa0c4d268f56.grxml\",\"grammarRule\":\"Choices\",\"grammarType\":\"URL\",\"noInputTimeoutMs\":4000,\"prompts\":[{\"Say\":{\"text\":\"what is your favorite color\"}}],\"recognitionTimeoutMs\":5000}}]}]}");
                LogSearchFilters filters = new LogSearchFilters();
                string           pql     = "level=\"info\"";
                filters.setPql(pql);
                LogList logList = requester.get(filters);

                Assert.IsNotNull(logList);

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

                Log log = logList.get(0) as Log;

                Assert.IsNotNull(log);
                Assert.AreEqual(log.getLevel, ELogLevel.Info);
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }