Dequeue a Member

1600

👍

You're ready for this tutorial if you've got the following:

A FreeClimb account
A registered application
A configured FreeClimb Number
Your tools and language installed


Node.js

In addition to retrieving a queued Call's metadata, the getQueuesRequester provides a means to dequeue the Call associated with a callId and queueId. The queueId and callId are not provided in this example.

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

{
  "name": "node-dequeue-member-tutorial",
  "version": "1.0.0",
  "dependencies": {
    "@freeclimb/sdk": "^1.0.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')
// 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 freeclimb = freeclimbSDK(accountId, apiKey)

// Invoke dequeue queued call
freeclimb.api.queues.members(queueId).dequeue(callId).then(member => {
  // Use the queue member
}).catch(err => {/** Catch Errors */ })

Java

In addition to retrieving a queued Call's metadata, the getQueuesRequester provides a means to dequeue the Call associated with a callId and queueId. The queueId and callId are not provided in this example.

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:

/* 
 * 1. RUN PROJECT WITH COMMAND: 
 *    `gradle build && java -Dserver.port=0080 -jar build/libs/gs-spring-boot-0.1.0.jar`
 * 2. RUN CURL COMMAND TO GET LIST OF QUEUES:
      `curl {baseUrl}/dequeueQueueMember  -d 'queueId={queueId}&callId={callId}'`
 * 3. EXPECT JSON TO BE RETURNED:
 *    {"uri":"/Accounts/{accountId}/Queues/{queueId}/Members/{callId}",
        "callId":"{callId}",
        "waitTime":{waitTime},
        "position":{position},
        "dateEnqueued":"{dateEnqueued}"}
*/

package main.java.dequeue_member;

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;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.vailsys.freeclimb.percl.Dequeue;
import com.vailsys.freeclimb.webhooks.queue.QueueActionCallback;

import java.util.LinkedList;

import com.vailsys.freeclimb.api.queue.QueueList;

import java.util.ArrayList;
import com.vailsys.freeclimb.api.queue.member.Member;
import com.vailsys.freeclimb.api.queue.member.MemberList;
@RestController
public class DequeueMemberController {
  // Get base URL, accountID, and apiKey from environment variables
  private String baseUrl = System.getenv("HOST");
  private String accountId = System.getenv("ACCOUNT_ID");
  private String apiKey = System.getenv("API_KEY");

	@RequestMapping("/dequeueQueueMember")
  public Member dequeueQueueMember(String queueId, String callId) {
    try {
      FreeClimbClient client = new FreeClimbClient(accountId, apiKey); // Create FreeClimbClient object

      // Invoke update method to dequeue queued call
      Member member = client.queues.getMembersRequester(queueId).dequeue(callId);

      // Can examine CallId, DateEnqueued, Position, URI, and WaitTime for this member
      return member;
    } catch (FreeClimbException pe) {
      System.out.println(pe.getMessage());
    }
    return null;
  }
}

C#

In addition to retrieving a queued Call's metadata, the getQueuesRequester provides a means to dequeue the Call associated with a callId and queueId. The queueId and callId are not provided in this example.

Imports used:

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

Example code:

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

// Invoke method to update the QueueMeber to dequeue it from the queue
QueueMember queueMember = client.getQueuesRequester.updateQueueMember(queueId, callId);