npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

runthered

v1.0.3

Published

A library for calling Run The Red's APIs from node.

Downloads

3

Readme

runthered-node

A node.js Run The Red API helper library.

Installation

npm install -g runthered

Examples

HTTP Gateway

Send an MT

var runthered = require('runthered');
// the credentials for the API
var username = "snoop7";
var password = "snoop7";
var serviceKey = "snop7";

// the options for the request
var message = "test";
var to = "6421859582";
var from = "2059";

var msgId = "55fb8506e138230a7217ab3e";

httpGatewayApi = new runthered.HttpGateway(username, password, serviceKey);

httpGatewayApi.pushMessage(
	{
	message: message,
	to: to,
	from: from
	},
	// callback function
	function(error, message) {
                if(error){
			console.log("We failed with error " + error);
		}else{
			// the response is just the msg_id
			console.log("The push message response is " + message);
		}
	}
	);

Query a delivery receipt for a message id:

httpGatewayApi.queryDlr(
	{
	id: msgId
	},
	// callback function
	function(error, dlrResponse) {
                if(error){
			console.log("We failed with error message " + error);
		}else{
			// the response is simple JSON with status, reason and id attributes
			console.log("The status is " + dlrResponse.status);
			console.log("The reason is " + dlrResponse.reason);
			console.log("The msgId is " + dlrResponse.id);
		}
	}
	);

Push API

Send an MT

var runthered = require('runthered');
// the credentials for the API
var username = "testuser";
var password = "testuser";
var serviceKey = "82221";

// the options for the request
var body = "test";
var to = "6421859582";
var from = "8222";
var pushId = 231434;

var msgId = "55fb4a1ae138230a7217ab1d";

pushApi = new runthered.PushApi(username, password, serviceKey);

pushApi.pushMessage(
	{
	body: body,
	to: to,
	from: from,
	pushId: pushId
	},
	// callback function
	function(error, pushResponse) {
                if(error){
			// the JSON response is something like {"jsonrpc": "2.0", "id": 231434, "error": {"message": "Invalid shortcode.", "code": -1}}
			console.log("We failed with error " + error.error.message);
			console.log("The error code is " + error.error.code);
		}else{
			// the JSON response is something like {"jsonrpc":"2.0","id":231434,"result":{"status":"Accepted","msg_id":"55fb46b5e138230a7217aaf3"}}
			console.log("The response pushId is " + pushResponse.id);
			console.log("The response status is " + pushResponse.result.status);
			console.log("The response msgId is " + pushResponse.result.msg_id);
		}
	}
	);

Query a delivery receipt for a message id:

pushApi.queryDlr(
	{
	msgId: msgId,
	pushId: pushId
	},
	// callback function
	function(error, dlrResponse) {
                if(error){
			// the JSON response is something like {"jsonrpc":"2.0","id":231434,"error":{"message":"Unknown Message Id.","code":-11}}
			console.log("We failed with error " + error.error.message);
			console.log("The error code is " + error.error.code);
		}else{
			// the JSON response is something like {"jsonrpc":"2.0","id":231434,"result":{"status":"ENROUTE","reason":"000","msg_id":"55fb47d4e138230a7217aaff"}}
			console.log("The status is " + dlrResponse.result.status);
			console.log("The reason is " + dlrResponse.result.reason);
			console.log("The msgId is " + dlrResponse.result.msg_id);
		}
	}
	);