2.0.1 • Published 5 years ago

mitto-rest-client v2.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Mitto REST API Node.js client

This is the official Node.js client for the Mitto REST API (https://www.mitto.ch).

NPM-Package: https://www.npmjs.com/package/mitto-rest-client

Install

npm install mitto-rest-client

Usage

Simple SMS sending

var apiKey = "YOUR-API-KEY";
var testMode = false; // optional; set to true if you want to send a test messages (no delivery, no cost, but visible in your portal)

require("mitto-rest-client")
    .create(apiKey, testMode)
    .sendTextMessage("YourSender", "491771234567", "Hello World!");

Send flash SMS

var apiKey = "YOUR-API-KEY";

require("mitto-rest-client")
    .create(apiKey)
    .sendTextMessage("YourSender", "491771234567", "Hello World!", {flash: true});

Set a client reference

var apiKey = "YOUR-API-KEY";

require("mitto-rest-client")
    .create(apiKey)
    .sendTextMessage("YourSender", "491771234567", "Hello World!", {reference: "My internal reference number #1"});

// in the Mitto customer portal you can configure a DeliveryReport Callback URL; this will receive the "reference" parameter from above...
// alternatively you can support your Account Manager to set the URL for you.

Unicode SMS sending

var apiKey = "YOUR-API-KEY";

require("mitto-rest-client")
    .create(apiKey)
    .sendUnicodeTextMessage("YourSender", "491771234567", "привет");

Inspect response

var apiKey = "YOUR-API-KEY";

require("mitto-rest-client")
    .create(apiKey)
    .sendTextMessage(
        "YourSender",
        "491771234567",
        "Hello World!",
        null,
        function(error, apiResponse) {
            if(error) {
                console.error(error);
            }
            if(apiResponse) {
                console.log(
                    "ResponseCode: " + apiResponse.responseCode + "\n" +
                    "ResponseText: " + apiResponse.responseText + "\n" +
                    "MessageId: " + apiResponse.id + "\n" +
                    "Timestamp: " + apiResponse.timestamp + "\n" +
                    "TextLength: " + apiResponse.textLength + "\n\n"
                );
            }
        }
    );