1.2.1 • Published 7 years ago

tq1-public-sdk v1.2.1

Weekly downloads
30
License
For internal use ...
Repository
github
Last release
7 years ago

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
1.2.1

7 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago