public void GetCallListTest()
        {
            try
            {
                CallsRequester callsRequester = new CallsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da");

                Type       callsRequesterType = typeof(CallsRequester);
                MethodInfo persyUrlMethodInfo = callsRequesterType.GetMethod("setPersyUrl",
                                                                             BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                                                                             null,
                                                                             new Type[] { typeof(System.String) },
                                                                             null);
                persyUrlMethodInfo.Invoke(callsRequester, new Object[] { "http://GetCallListTest:3000" });

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

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls?cursor=492dc883a811bd0204204ea9047122f93a2788a2\",\"calls\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"callId\":\"CAfe92a5efbaf90f04bbec946a0d74dad520dd883b\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"endTime\":\"Mon, 28 Mar 2016 19:58:30 GMT\",\"duration\":9,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Recordings\"}},{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"callId\":\"CA25c3c744acdedcdb92a44dbae42d486bf20028ab\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"endTime\":\"Mon, 28 Mar 2016 20:03:50 GMT\",\"duration\":8,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab/Recordings\"}}]}");

                CallList callList = callsRequester.get();

                Assert.IsNotNull(callList);

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

                Call call = callList.get(0) as Call;

                Assert.IsNotNull(call);
                Assert.AreEqual(call.getCallId, "CAfe92a5efbaf90f04bbec946a0d74dad520dd883b");

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

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null,\"calls\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd884b\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"callId\":\"CAfe92a5efbaf90f04bbec946a0d74dad520dd884b\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"endTime\":\"Mon, 28 Mar 2016 19:58:30 GMT\",\"duration\":9,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Recordings\"}}]}");

                callList.loadNextPage();

                Assert.IsNotNull(callList);

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

                call = callList.get(2) as Call;
                Assert.IsNotNull(call);
                Assert.AreEqual(call.getCallId, "CAfe92a5efbaf90f04bbec946a0d74dad520dd884b");
            }
            catch (PersyException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            string          freeClimbAccountId = System.Environment.GetEnvironmentVariable("ACCOUNT_ID");
            string          freeClimbApiKey    = System.Environment.GetEnvironmentVariable("API_KEY");
            FreeClimbClient client             = new FreeClimbClient(freeClimbAccountId, freeClimbApiKey);
            CallList        callList           = client.getCallsRequester.get();

            if (callList.getTotalSize > 0)
            {
                while (callList.getLocalSize < callList.getTotalSize)
                {
                    callList.loadNextPage();
                }
                LinkedList <IFreeClimbCommon> commonList = callList.export();
                foreach (IFreeClimbCommon element in commonList)
                {
                    Call call = element as Call;
                    Console.WriteLine(call.getCallId);
                }
            }
        }