List Conferences
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 conferences associated with the account can be initiated. Additional filtering criteria such as Alias
, Status
, DateCreated
, and DateUpdated
are possible if provided. Successful invocation of the get
method will return the first page of conferences which has the nextPageUri
. Sequential iteration through the entire list of conferences can be done using the nextPageUri
.
Create your package.json file and save in the root directory of your project:
{
"name": "node-list-conferences-how-to-guide",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@freeclimb/sdk": "^3.8.0",
"dotenv": "^16.4.5"
}
}
Install the package by running the following in the command line/terminal:
yarn install
Example code:
require('dotenv').config()
const freeclimbSDK = require('@freeclimb/sdk')
// your freeclimb API key (available in the Dashboard) - be sure to set up environment variables to store these values
const accountId = process.env.ACCOUNT_ID
const apiKey = process.env.API_KEY
const configuration = freeclimbSDK.createConfiguration({ accountId, apiKey })
const freeclimb = new freeclimbSDK.DefaultApi(configuration)
getConferences().then(conferences => {
console.log('got conferences')
console.log(conferences)
// Use conferences
}).catch(err => {
console.errer(err)
// Catch Errors
})
async function getConferences() {
// Create array to store all conferences
const conferences = []
// Invoke GET method to retrieve initial list of conferences information
let response = await freeclimb.listConferences()
conferences.push(...response.conferences)
// Retrieve entire conferences list
while (response.nextPageUri) {
response = await freeclimb.getNextPage(response)
conferences.push(...nextPage.conferences)
}
return conferences
}
Java
Using the ConferencesRequester
created upon successful creation of the FreeClimbClient
a synchronous request for all conferences associated with the account can be initiated. Additional filtering criteria such as Alias
, Status
, DateCreated
, and DateUpdated
are possible if provided. Successful invocation of the get
method will return a ConferenceList
object which will allow for the sequential iteration through the entire list for conferences.
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']
}
}
}
Build the file by running the following in your terminal/command line:
gradle build
Example code:
import com.vailsys.freeclimb.api.FreeClimbClient;
import com.vailsys.freeclimb.api.FreeClimbException;
import com.vailsys.freeclimb.api.conference.Conference;
import com.vailsys.freeclimb.api.conference.ConferenceStatus;
import com.vailsys.freeclimb.api.conference.ConferenceList;
import com.vailsys.freeclimb.api.conference.ConferencesSearchFilters;
import java.util.ArrayList;
public ArrayList listConferences() {
//Create a filter object to retrieve the list of conferences with a matching alias and status
ConferencesSearchFilters filters = new ConferencesSearchFilters();
filters.setAlias("Tutorial Conference");
filters.setStatus(ConferenceStatus.TERMINATED); // statuses include EMPTY, IN_PROGRESS, POPULATED, TERMINATED
try {
//Create FreeClimbClient object
// accountId & apiKey can be found under API credentials on the FreeClimb Dashboard
FreeClimbClient client = new FreeClimbClient(accountId, apiKey);
//Invoke get method to retrieve the first page of conferences with a matching alias
ConferenceList conferenceList = client.conferences.get(filters);
//Check if the list is empty by checking its total size
if(conferenceList.getTotalSize() > 0){
//Retrieve all pages of results
while (conferenceList.getLocalSize() < conferenceList.getTotalSize()){
conferenceList.loadNextPage();
}
//Retrieve the inner ArrayList of conferences to process
ArrayList<Conference> conferences = conferenceList.export();
for (Conference conference:conferences) {
//Process conference element in some way
}
return conferences;
}
} catch (FreeClimbException pe){
// Exception throw upon failure
System.out.println(pe.getMessage());
}
return null;
}
C#
Using the ConferencesRequester
, obtained from the getConferencesRequester
method in FreeClimbClient
, a synchronous request for all conferences associated with the account can be initiated.
Additional filtering criteria such as Alias
, Status
, DateCreated
, and DateUpdated
are possible if provided. Successful invocation of the get
method will return a ConferenceList
object which will allow for the sequential iteration through the entire list for conferences.
In this how-to guide we read through all pages of conferences and place into one list that is returned.
The guide is implemented in one method that returns a list of Conference
instances for the account whose accountId
is passed. This can be used in a web app, console app, etc.
Imports used:
using com.freeclimb.api;
using com.freeclimb.api.conference;
using System.Collections.Generic;
using System;
Example code:
public static IList<Conference> GetConferencesList()
{
string acctId = getAcctId();
string apiKey = getApiKey();
IList<Conference> conferences = new List<Conference>();
FreeClimbClient client = new FreeClimbClient(acctId, apiKey);
// you can pass an option ConferenceSearchFilters class to the getConferences method to filter by certain criteria (e.g. alias, create date)
ConferenceList conferenceList = client.getConferencesRequester.getConferences();
if (conferenceList.getTotalSize > 0)
{
// Retrieve all pages of results
while (conferenceList.getLocalSize < conferenceList.getTotalSize)
{
conferenceList.loadNextPage();
}
foreach (IFreeClimbCommon item in conferenceList.export())
{
Conference conf = item as Conference;
// do whatever you need to do with conferene object which contains all the conference properties
conferences.Add(conf);
}
}
return conferences;
}
Updated about 1 month ago