https://github.com/freeclimbapi/nodejs-sdk
NodeJS SDK for the FreeClimb API
https://github.com/freeclimbapi/nodejs-sdk
library sdk
Last synced: 9 months ago
JSON representation
NodeJS SDK for the FreeClimb API
- Host: GitHub
- URL: https://github.com/freeclimbapi/nodejs-sdk
- Owner: FreeClimbAPI
- License: mit
- Created: 2019-10-30T14:48:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T20:29:35.000Z (11 months ago)
- Last Synced: 2025-04-18T04:12:54.434Z (10 months ago)
- Topics: library, sdk
- Homepage:
- Size: 1.64 MB
- Stars: 1
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# @freeclimb/sdk
@freeclimb/sdk - the NodeJS client package for the FreeClimb API
FreeClimb is a cloud-based application programming interface (API) that puts the power of the Vail platform in your hands. FreeClimb simplifies the process of creating applications that can use a full range of telephony features without requiring specialized or on-site telephony equipment. Using the FreeClimb REST API to write applications is easy! You have the option to use the language of your choice or hit the API directly. Your application can execute a command by issuing a RESTful request to the FreeClimb API. The base URL to send HTTP requests to the FreeClimb REST API is: /apiserver. FreeClimb authenticates and processes your request.
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0
- Package version:
- Build package: org.openapitools.codegen.languages.TypeScriptClientCodegen
For more information, please visit [https://www.freeclimb.com/support/](https://www.freeclimb.com/support/)
## Installing
```sh
npm install @freeclimb/sdk@4.1.1
or
yarn add @freeclimb/sdk@4.1.1
```
## Getting Started
```typescript
import freeclimb from "@freeclimb/sdk";
const configuration = freeclimb.createConfiguration({
accountId: "YOUR_ACCOUNT_ID",
apiKey: "YOUR_API_KEY",
});
const apiInstance = new freeclimb.DefaultApi(configuration);
apiInstance
.listApplications()
.then((applications) => console.log("got applications", applications));
```
## Detailed SDK documentation
For more details on how to use the individual methods on the sdk - go [here](https://github.com/FreeClimbAPI/nodejs-sdk/blob/master/DefaultApi.md)
## Using PerCL
The Performance Command Language (PerCL) defines a set of instructions, written in JSON format, that express telephony actions to be performed in response to an event on the FreeClimb platform. FreeClimb communicates with the application server when events associated with the application occur, so the webserver can instruct FreeClimb how to handle such events using PerCL scripts.
PerCL commands are a part of the model schema and can be serialized into JSON like so:
```typescript
import { Say, Play, GetDigits, PerclScript } from "@freeclimb/sdk";
const say = new Say({ text: "Hello, World" });
const play = new Play({ file: "Example File" });
const getDigits = new GetDigits({
actionUrl: "Example Action URL",
prompts: [say, play],
});
const perclScript = new PerclScript({ commands: [getDigits] });
console.log(perclScript.toJSON());
```
## Documentation for verifying request signature
- To verify the request signature, we will need to use the verifyRequestSignature method within the Request Verifier class
RequestVerifier.verifyRequestSignature(requestBody, requestHeader, signingSecret, tolerance)
This is a method that you can call directly from the request verifier class, it will throw exceptions depending on whether all parts of the request signature is valid otherwise it will throw a specific error message depending on which request signature part is causing issues
This method requires a requestBody of type string, a requestHeader of type string, a signingSecret of type string, and a tolerance value of type number
Example code down below
```typescript
import { RequestVerifier } from "./utils/RequestVerifier";
export function RequestVerifierExample() {
const tolerance: number = 5 * 60;
const requestBody: string =
'{"accountId":"YOUR_ACCOUNT_ID","callId":"YOUR_CALL_ID","callStatus":"YOUR_CALL_STATUS","conferenceId":null,"direction":"YOUR_CALL_DIRECTION,"from":"FROM_EXAMPLE","parentCallId":null,"queueId":null,"requestType":"YOUR_REQUEST_TYPE","to":"TO_EXAMPLE"}';
const signingSecret: string = "YOUR_SIGNING_SECRET";
const requestHeader: string =
"t=YOUR_TIMESTAMP,v1=YOUR_HASH_EXAMPLE,v1=YOUR_HASH_EXAMPLE";
RequestVerifier.verifyRequestSignature(
requestBody,
requestHeader,
signingSecret,
tolerance,
);
}
```