List Recordings
You're ready for this how-to guide if you've got the following:
A FreeClimb account
A registered application
A configured FreeClimb Number
Your tools and language installed
Node.js
Using the FreeClimb SDK, an asynchronous request for all recordings associated with the account can be initiated. Additional filtering criteria such as date
and/or call
are possible, but not demonstrated in this sample. Successful invocation will return the first page of recordings. This object will allow for sequential iteration through the pages which allows one to retrieve the entire list of recordings using the nextPageUri
.
Create your package.json file and save in the root directory of your project:
{
"name": "node-list-recordings-how-to-guide",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@freeclimb/sdk": "^3.8.0",
"dotenv": "^8.1.0"
}
}
Install the package by running the following in the command line/terminal:
yarn install
Example code:
require('dotenv').config()
const freeclimbSDK = require('@freeclimb/sdk')
const accountId = process.env.ACCOUNT_ID
const apiKey = process.env.API_KEY
const configuration = freeclimbSDK.createConfiguration({ accountId, apiKey })
const freeclimb = new freeclimbSDK.DefaultApi(configuration)
getRecordings().then(recordings => {
console.log('got recordings', recordings)
}).catch(err => {
console.log(err)
})
async function getRecordings() {
const recordings = []
let response = await freeclimb.listRecordings()
recordings.push(...response.recordings)
while (response.nextPageUri) {
response = await freeclimb.getNextPage(response)
recordings.push(...response.recordings)
}
return recordings
}
Java
To initiate any interaction with FreeClimb a FreeClimbClient
object must be created. Using the RecordingsRequester
created upon successful creation of the FreeClimbClient
a synchronous request for all recordings associated with the account can be initiated. Additional filtering criteria such as date
and/or call
are possible, but not demonstrated in this sample. Successful invocation of the getMeta
method will return the RecordingList
object which represents the paginated list of recordings returned by FreeClimb. This object will allow for sequential iteration through the pages and allow one to retrieve the entire list of recordings.
Create your build.gradle file and save it to the root directory in your project:
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/
buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
//Add the dependency
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile "org.springframework.boot:spring-boot-starter-web"
testCompile "junit:junit"
compile 'com.github.FreeClimbAPI:FreeClimb-Java-SDK:3.0.0'
}
sourceSets {
main {
java {
srcDirs = ['src'] // changed line
}
}
}
Build the file by running the following in your terminal/command line:
gradle build
Example code:
/*
* FreeClimb Java packages documentation:
* https://javadoc.jitpack.io/com/github/freeclimbapi/java-sdk/1.0.0/javadoc/index.html
*/
import com.vailsys.freeclimb.api.FreeClimbClient;
import com.vailsys.freeclimb.api.FreeClimbException;
import com.vailsys.freeclimb.api.recording.Recording;
import com.vailsys.freeclimb.api.recording.RecordingList;
import java.util.ArrayList;
public ArrayList listRecordings() {
FreeClimbClient client;
RecordingList recordingsList;
try {
client = new FreeClimbClient(accountId, apiKey); // Create FreeClimbClient object
// Your account ID & api key can be found under API credentials on the FreeClimb Dashboard
recordingsList = client.recordings.getMeta(); //Retrieve the paginated list of recordings
//Don't bother trying to grab more pages if there is only one or zero
//pages of results
if(recordingsList.getTotalSize() > recordingsList.getPageSize()) {
//Load in all the recordings returned.
while(recordingsList.getLocalSize() < recordingsList.getTotalSize()) {
recordingsList.loadNextPage(); //Load in the next page of recordings.
}
}
ArrayList<Recording> allRecordings = recordingsList.export(); //Extract the array from the RecordingList
for(Recording r : allRecordings) {
// do something with each recording
}
return allRecordings;
}
catch(FreeClimbException pe) {
System.out.println(pe.getMessage());
}
return null;
}
C#
To initiate any interaction with FreeClimb a FreeClimbClient
object must be created. Using the RecordingsRequester
created upon successful creation of the FreeClimbClient
a synchronous request for all recordings associated with the account can be initiated. Additional filtering criteria such as date
and/or call
are possible but not demonstrated in this sample. Successful invocation of the get
method will return the RecordingList
object which will allow for the sequential iteration through the entire list for recordings.
Example code:
static void Main (string[] args) {
// Create FreeClimbClient object
FreeClimbClient client = new FreeClimbClient (getFreeClimbAccountId (), getFreeClimbApiKey ());
// 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);
}
}
}
Updated 2 months ago