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

@lonely_dev/termii-js

v1.0.2

Published

TERMII-JS ==============================================================================================================================

Downloads

406

Readme

TERMII-JS

Termii-Js is a convenience Typescript/JavaScript library that provides an interface, which developers with an utmost love for everything JavaScript can leverage for a seamless interaction with the Termii platform https://termii.com/.

Setup

To use, first install:

npm install @lonely_dev/termii-js

or

yarn add @lonely_dev/termii-js

The library provides classes you can utilize in consuming some of the various APIs provided by Termii. These APIs are made available by the library as dedicated classes or as part of a root API.

Usage

You can send a simple message like so:

const termii = require("@lonely_dev/termii-js");
const termiiAPIInstance = termii.createTermiiAPIInstance("API_KEY_GOES_HERE"); // You can also use destructuring instead

(async () => {
  await termiiAPIInstance
    .message({
      to: "PHONE_NUMBER",
      from: "SENDER_ID",
      sms: "MESSAGE",
      channel: "generic"
    })
    .send();
})();

or like so:

const { MessageAPI } = require("@lonely_dev/termii-js");

(async () => {
  await MessageAPI
    .createMessagingInstance({
      to: "PHONE_NUMBER",
      from: "SENDER_ID",
      sms: "MESSAGE",
      channel: "generic",
      api_key: "API_KEY_HERE"
    })
    .send();
})();

Other available APIs

The NumbersAPI class provides the interface for the Termii number API. You can access it using the numbers function of the Termii API instance or you can import the class directly.

// Removed for brevity
(async () => {
  await termiiAPIInstance
    .numbers({
      to: "PHONE_NUMBER",
      sms: "MESSAGE"
    })
})()

or

const { NumbersAPI } = require("@lonely_dev/termii-js");

(async () => {
  await NumbersAPI
    .createNumberInstance({
      to: "PHONE_NUMBER",
      sms: "MESSAGE",
      api_key: "API_KEY_HERE"
    })
    .send();
})();

Side note: Notice that you do not need to set the api_key field if you're accessing an API from the root instance, which is where you set the API key (i.e the function argument).

You can access the SendersIDAPI class using the senderID function of the root instance or by using the static createSenderIDInstance function exposed by the class itself. Use the link attached to this section to know how this instance can be configured. Remember that you only need to provide the API key again if you're not accessing from the root API instance. The non-static functions available in this class are fetchSenderID and requestSenderID

You can access the TemplateAPI class using the template function of the root instance or by using the static createTemplateInstance function exposed by the class itself.

Tokens

You can also access the tokens APIs by using the tokens variable of the root instance.

const tokens = termiiAPIInstance.tokens;

Each token API also has a dedicated class. The classes provided include: EmailTokenAPI, SendTokenAPI, VoiceCallAPI and VoiceTokenAPI. They can be accessed like so:

(async () => {
  await tokens.sendToken({ /* See docs for how to configure send token*/}).send();
  await tokens.voiceToken({ /* See docs for how to configure voice token*/}).send();
  await tokens.emailToken({ /* See docs for how to configure email token*/}).send();
  await tokens.voiceCall({ /* See docs for how to configure send call*/}).send();
})()

You can even access them through static functions.

(async () => {
  SendTokenAPI.createSendTokenInstance({/* See docs for how to configure send token*/}).send();
  VoiceTokenAPI.createVoiceTokenInstance({/* See docs for how to configure voice token*/}).send();
  EmailTokenAPI.createEmailTokenInstance({/* See docs for how to configure email token*/}).send();
  VoiceCallAPI.createVoiceCallInstance({/* See docs for how to configure voice call*/}).send();
})()