Create a Queue

👍

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, invoke an asynchronous request to create a Queue. Optional Queue parameters such as alias or maxSize can be specified during the creation of the Queue. Successful invocation returns the Queue's metadata.

Create your package.json file and save in the root directory of your project:

{
  "name": "node-make-a-queue-how-to-guide",
  "version": "1.0.0",
  "license":"MIT",
  "scripts": {
    "start": "node makeAQueue.js"
  },
  "dependencies": {
    "@freeclimb/sdk": "^3.4.0",
    "dotenv": "^16.3.1"
  }
}

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 freeclimbConfig = new freeclimbSDK.createConfiguration({ accountId, apiKey })
const apiInstance = new freeclimbSDK.DefaultApi(freeclimbConfig)

apiInstance.createAQueue({
  alias: 'Tutorial Queue',
  maxSize: 25
}).then(({ queueId }) => {
  // Get the queue and log details
  apiInstance.getAQueue(queueId).then((queue) => console.log(queue))
}).catch(console.log)

Java

After successfully creating the FreeClimbClient, you can invoke QueuesRequester to send a synchronous request to create a Queue. Optional Queue parameters such as alias or maxSize can be specified during the creation of the Queue. Successful invocation returns the Queue's metadata.

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:

import com.vailsys.freeclimb.api.FreeClimbClient;
import com.vailsys.freeclimb.api.FreeClimbException;
import com.vailsys.freeclimb.api.queue.Queue;
import com.vailsys.freeclimb.api.queue.QueueCreateOptions;
public void makeQueue() {
    //Options payload to set alias and maximum size when creating the queue
    QueueCreateOptions options = new QueueCreateOptions();
    options.setAlias("Tutorial Queue");
    options.setMaxSize(25);
    try {
        //Create FreeClimbClient object
        // accountId & api key can be found under API credentials on the FreeClimb Dashboard
        FreeClimbClient client = new FreeClimbClient(accountId, apiKey);
 
        //Invoke method to create a queue with the options provided
        Queue queue = client.queues.create(options);
    } catch (FreeClimbException ex) {
        // Exception throw upon failure
    }
}

C#

After successfully creating the FreeClimbClient, you can invoke getQueuesRequester to send a synchronous request to create a queue. Optional Queue parameters such as alias or maxSize can be specified during the creation of the Queue. In this sample the optional alias is included. Successful invocation returns the Queue's metadata.

Imports used:

using com.freeclimb.api;
using com.freeclimb.api.queue;

Example code:

string alias = "My_First_Queue";

QueueOptions options = new QueueOptions();
options.setAlias(alias); // Set the optional alias

// Create FreeClimbClient object
FreeClimbClient client = new FreeClimbClient(getFreeClimbAccountId(),
                                             getFreeClimbApiKey());

// Invoke method to create queue metadata
Queue queue = client.getQueuesRequester.create(options);