Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tnzapi

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tnzapi

Node.js Library for TNZ Group REST API

  • 2.1.0
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by145.03%
Maintainers
1
Weekly downloads
 
Created
Source

tnzapi

Documentation

The documentation for the TNZ API can be found here.

Versions

tnzapi uses a modified version of Semantic Versioning for all changes. See this document for details.

Supported NodeJS Versions

This library supports the following NodeJS implementations:

  • NodeJS v14

Installation

Install from npm using npm, a package manager for NodeJS.

npm i tnzapi

You may need to run the above commands with sudo.

Getting Started

Getting started with the TNZ API couldn't be easier. Create a Client and you're ready to go.

API Credentials

The TNZAPI needs your TNZ API credentials. You can either pass these directly to the constructor (see the code below) or via environment variables.

const tnzapi = require('tnzapi');

const client = new tnzapi();

client.Sender = "user@example.com";
client.APIKey = "ABC123";
...

Send an Email:

const tnzapi = require('tnzapi');

const client = new tnzapi({
    "Sender": "user@example.com",
    "APIKey": "ABC123"
});

var request = client.Send.Email({
    "EmailSubject": "NodeJS Test",
    "MessagePlain": "Test Email",
    "Destinations": [{"Recipient":"recipient@example.com"}]
});

var callback = function(data) {
    console.log("Response:",JSON.stringify(data, null, "  "));
}

request.SendMessage(callback);

Send a SMS:

const tnzapi = require('tnzapi');

const client = new tnzapi({
    "Sender": "user@example.com",
    "APIKey": "ABC123"
});

var request = client.Send.SMS({
    "Reference": "Test",
    "Message": "Test SMS Message click [[Reply]] to opt out",
    "Destinations": [{"Recipient":"+64211231234"}]
});

var callback = function(data) {
    console.log("Response:",JSON.stringify(data, null, "  "));
}

request.SendMessage(callback);

Send a Fax Document:

const tnzapi = require('tnzapi');

const client = new tnzapi({
    "Sender": "user@example.com",
    "APIKey": "ABC123"
});

var request = client.Send.Fax({
    "Reference": "Test Fax",
    "Destinations": [{"Recipient":"+6491232345"}]
});

request.AddAttachment("C:\\Document.pdf");

var callback = function(data) {
    console.log("Response:",JSON.stringify(data, null, "  "));
}

request.SendMessage(callback);

Make a Call - Text-to-Speech (TTS):

const tnzapi = require('./tnzapi');

const client = new tnzapi({
    "Sender": "user@example.com",
    "APIKey": "ABC123"
});

var request = client.Send.TTS({
    "Reference": "Voice Test - 64211232345",
    "MessageToPeople": "Hi there!",
    "Destinations": [{"Recipient":"+64211232345"}]
});

request.AddKeypad(1,"+6499293000","You pressed 1");

var callback = function(data) {
    console.log("Response:",JSON.stringify(data, null, "  "));
}

request.SendMessage(callback);

Make a Call - Upload MP3 / Wav File:

const tnzapi = require('tnzapi');

const client = new tnzapi({
    "Sender": "user@example.com",
    "APIKey": "ABC123"
});

var request = client.Send.Voice({
    "Reference": "Voice Test - 64211232345",
    "Destinations": [{"Recipient":"+64211232345"}]
});

request.AddVoiceFile("MessageToPeople","C:\\file1.wav");
request.AddVoiceFile("MessageToAnswerPhones","C:\\file2.wav");

request.AddKeypad(1,"+6491232345","C:\\file3.wav");

var callback = function(data) {
    console.log("Response:",JSON.stringify(data, null, "  "));
}

request.SendMessage(callback);

Getting help

If you need help installing or using the library, please check the TNZ Contact if you don't find an answer to your question.

Keywords

FAQs

Package last updated on 31 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc