tq1-public-sdk

1.2.1 • Public • Published

TQ1 Node.js Public API SDK

Build Status

Install

  1. Add tq1-public-sdk dependency to your package.json

Usage

Setup

Provided with the Application Key and an API Access Token, create a client as following


var tq1 = require('tq1-public-sdk');

var client = tq1('my application key', 'my application token');

Calling the API

API call examples:


// Fetching metadata

client.fetchMetadata(function(err, data) {
  // data will be an object like the one described at http://docs.tq1publicapi.apiary.io/#reference/authentication/fetch-metadata/get
});

// Sending Exclusive push notification to client with id 123456

var notification = {
  'status': 0,
  'parameters': {
    'custom': {
      'Client Code': ['123456']
    }
  },
  'content': {
    'title': 'Message title (for admin and reports purposes only)',
    'message': 'push notification message (will be shown on user device)',
    'scheduled_at': 1420741200,
  },
  'audienceText': ['Message for user with code 123456'],
  "max_audience": 1
};

client.schedulePushExclusiveNotification(notification, function(err, data) {
  // data will be an object like the one described at http://docs.tq1publicapi.apiary.io/#reference/authentication/new-exclusive-push-notification/post
});

Error handling

All calls that result in an error of some sort (validation or HTTP failure), will have an error object containing the following properties:

  • name: It is a string constant with value equal to "TQError", which can also be checked/compared with the .constants.errorName property of the client
  • message: Contains an error message string informing the error reason.
client.schedulePushExclusiveNotification(null, function(err, data) {
  // err.name == client.constants.errorName
  // > true
});

Test

$ npm install
$ npm test

Readme

Keywords

none

Package Sidebar

Install

npm i tq1-public-sdk

Weekly Downloads

7

Version

1.2.1

License

For internal use only

Last publish

Collaborators

  • felipesabino
  • taqtile