Getting Started

Use these set up instructions to install and configure the Bringg Dispatcher SDK in your projects.

Overview

Installing the Bringg Dispatcher SDK requires only 4 steps:

  1. Create your project folder.
  2. Add the package.json.
  3. Create the script file.
  4. Install the Bringg Dispatcher SDK.

You can test your installation.

📘

Before you start, confirm you have the prerequisites.

Prerequisites

You must have the following installed in your environment:

  • node.js® (JavaScript runtime)
  • npm (the package manager for JaveScript)

Installation for Windows

Step 1. Create Your Project Directory

a. Create a project directory

mkdir c:\MyBringgSDKProject

b. Change Directories to Your Project Directory

cd MyBringgSDKProject

Step 2. Add the package.json file to Your Project Directory

  1. Create a file named package.json in your project directory and insert the following:
{
  "name": "bringg-sdk-nodejs-example",
  "version": "0.0.1",
  "dependencies": {
    "async-await-es7": "^1.0.2",
    "cache-decorator": "^0.1.6",
    "typescript": "2.7.2"
  },
  "devDependencies": {
    "babel-preset-es2017": "^6.24.1",
    "bringg-dashboard-sdk": "file:<your bringg-dashboard-sdk folder>"
  }
}
  1. Replace <your bringg-dashboard-sdk-folder> with a relative path to your bringg-dashboard-sdk folder.

Step 3. Create the script file to Your Project Directory

a. Create a file named script in your project directory and insert the following:

let BringgDashboardSDK = require("bringg-dashboard-sdk");

async function runAwait() {

  try {
    
    // setConfiguration is optional
    BringgDashboardSDK.setConfigurations(("https://<Bringg API URL>","https://<Bringg Realtime URL>");
                                         
    // delegateLogger is optional
    BringgDashboardSDK.delegateLogger({debug:console.log, info:console.log, warn:console.log, error:console.log, log:console.log});
    
    // initwithAuthToken returns an instance of the SDK from which Bringg SDK requests are done
    const bringgDashboardSDK = await BringgDashboardSDK.initWithAuthToken(<region>, <token>);
    
    // setLogLevel is optional
    BringgDashboardSDK.setLogLevel(BringgDashboardSDK.LOG_DEBUG);
    
    // call the bringgDashboardSDK instance opened by initwithAuthToken with the users.getAll() method
    console.log(await bringgDashboardSDK.users.getAll())

  } catch (e) {
    console.error(e.details);
  }
}

runAwait();

b. Replace "https://<Bringg API URL>" with your Bringg API Server Path.
c. Replace "https://<Bringg Realtime URL" with your Bring realtime URL.
d. Replace <region> with your region.
e. Replace <token> with your authorization token.
f. Save the file.

Step 4. Install the Bringg Dispatcher SDK

npm install

👍

That's All!

The npm install command installed the Bringg Dispatcher SDK and placed it in the new directory node_modules.

Test Your Installation

You can use the following application to test your installation. This example application initializes the Bringg Dispatcher SDK with a username and password, and then gets all users. It returns an array of User Objects .

  1. Create a file named MyTestApp.js
  2. Insert the following lines of code:
et BringgDashboardSDK = require("bringg-dashboard-sdk");

async function runAwait() {

  try {
    BringgDashboardSDK.setConfigurations("https://<Bringg Server Path>","https://localhost:3030");
    BringgDashboardSDK.delegateLogger({debug:console.log, info:console.log, warn:console.log, error:console.log, log:console.log});
    BringgDashboardSDK.initWithEmail("<username>", "password");
    BringgDashboardSDK.setLogLevel(BringgDashboardSDK.LOG_DEBUG);
    console.log(await bringgDashboardSDK.users.getAll())
  } catch (e) {
    console.error(e.details);
  }
}

runAwait();
  1. Replace "https://<Bringg Server Path>" with your Bringg Server Path.

  2. Replace <username> with your user name.

  3. Replace <password> with your password.

  4. Run the test.

node MyTestApp.js