public void GetRecordingListTest() { try { RecordingsRequester recordingsRequester = new RecordingsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(recordingsRequester, "http://GetRecordingListTest:3000"); } WebRequest.RegisterPrefix("http://GetRecordingListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings&cursor=492dc883a811bd0204204ea9047122f93a2788a2\",\"recordings\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings/REb1eecfce410141ad1749c0fc84dfbb6fc4c2a810\",\"revision\":1,\"dateCreated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"dateUpdated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"recordingId\":\"REb1eecfce410141ad1749c0fc84dfbb6fc4c2a810\",\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9\",\"duration\":9},{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings/RE9cae4798ca0803cbd52209c1bfe99d25027cc2cf\",\"revision\":1,\"dateCreated\":\"Mon, 27 Jun 2016 20:38:16 GMT\",\"dateUpdated\":\"Mon, 27 Jun 2016 20:38:16 GMT\",\"recordingId\":\"RE9cae4798ca0803cbd52209c1bfe99d25027cc2cf\",\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CFa32e912be62fff5d0b1bcd99610a69281918800a\",\"duration\":9}]}"); RecordingList recordingList = recordingsRequester.getMeta(); Assert.IsNotNull(recordingList); Assert.AreEqual(recordingList.getLocalSize, 2); Assert.AreEqual((recordingList.export()).Count, 2); Recording recording = recordingList.get(0) as Recording; Assert.IsNotNull(recording); Assert.AreEqual(recording.getRecordingId, "REb1eecfce410141ad1749c0fc84dfbb6fc4c2a810"); type = typeof(APIRequester); fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(recordingList, "http://GetRecordingListTest:3000"); } TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null,\"recordings\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings/REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"revision\":1,\"dateCreated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"dateUpdated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"recordingId\":\"REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9\",\"duration\":9}]}"); recordingList.loadNextPage(); Assert.IsNotNull(recordingList); Assert.AreEqual(recordingList.getLocalSize, 3); Assert.AreEqual((recordingList.export()).Count, 3); recording = recordingList.get(2) as Recording; Assert.IsNotNull(recording); Assert.AreEqual(recording.getRecordingId, "REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
static void Main(string[] args) { // Create FreeClimbClient object FreeClimbClient client = new FreeClimbClient(getFreeClimbAccountId(), getFreeClimbApiKeys()); // Invoke get method to retrieve initial list of recording information RecordingList recordingList = client.getRecordingsRequester.getMeta(); // Check if list is empty by checking total size of the list if (recordingList.getTotalSize > 0) { // retrieve all recording for server while (recordingList.getLocalSize < recordingList.getTotalSize) { recordingList.loadNextPage(); } // Convert current pages recording information to a linked list LinkedList <IFreeClimbCommon> commonList = recordingList.export(); // Loop through linked list to process recording information foreach (IFreeClimbCommon element in commonList) { // Cast each element to the Recording element for processing Recording recording = element as Recording; // Process recording element Console.Write(recording.getRecordingId); } } }
public void GetRecordingListByCallIdTest() { try { RecordingsRequester recordingsRequester = new RecordingsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(recordingsRequester, "http://GetRecordingListTest:3000"); } WebRequest.RegisterPrefix("http://GetRecordingListTest:3000/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Recordings?callId=CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":1,\"start\":0,\"end\":0,\"page\":1,\"numPages\":1,\"pageSize\":20,\"nextPageUri\":null,\"recordings\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings/REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"revision\":1,\"dateCreated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"dateUpdated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"recordingId\":\"REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9\",\"duration\":9}]}"); RecordingsSearchFilters filters = new RecordingsSearchFilters(); filters.setCallId("CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9"); RecordingList recordingList = recordingsRequester.getMeta(filters); Assert.IsNotNull(recordingList); Assert.AreEqual(recordingList.getLocalSize, 1); Assert.AreEqual((recordingList.export()).Count, 1); Recording recording = recordingList.get(0) as Recording; Assert.IsNotNull(recording); Assert.AreEqual(recording.getRecordingId, "REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }