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

smsmanager-js-api

v1.3.2

Published

A simple SMS sending library using the SMSManager API with message ID support

Downloads

13

Readme

SmsManager JS API

A simple TypeScript/JavaScript library for sending SMS messages using the SMSManager API (https://smsmanager.com). Supports both Promise-based and callback-based usage, and returns message ID information. Source code available on GitHub.

Installation

npm install smsmanager-js-api

Building the Project

To build the project, follow these steps:

  1. Install dependencies:

    npm install
  2. Build the project:

    npm run build

The compiled JavaScript files will be output to the dist directory.

Usage

Promise-based (TypeScript)

import SmsManager from 'smsmanager-js-api';

const sender = new SmsManager('your-api-key-here');

async function sendMessage() {
  const result = await sender.send('phone-number-here', 'Your message text');
  if (result.success) {
    console.log('SMS sent successfully. Message ID:', result.messageId);
  } else {
    console.log('Failed to send SMS');
  }
}

sendMessage();

Callback-based (TypeScript)

import SmsManager from 'smsmanager-js-api';

const sender = new SmsManager('your-api-key-here');

sender.send('phone-number-here', 'Your message text', (error, result) => {
  if (error) {
    console.error('Error sending SMS:', error);
  } else if (result.success) {
    console.log('SMS sent successfully. Message ID:', result.messageId);
  } else {
    console.log('Failed to send SMS');
  }
});

Promise-based (JavaScript)

const SmsManager = require('smsmanager-js-api');

const sender = new SmsManager('your-api-key-here');

sender.send('phone-number-here', 'Your message text')
  .then(result => {
    if (result.success) {
      console.log('SMS sent successfully. Message ID:', result.messageId);
    } else {
      console.log('Failed to send SMS');
    }
  })
  .catch(error => {
    console.error('Error sending SMS:', error);
  });

Callback-based (JavaScript)

const SmsManager = require('smsmanager-js-api');

const sender = new SmsManager('your-api-key-here');

sender.send('phone-number-here', 'Your message text', (error, result) => {
  if (error) {
    console.error('Error sending SMS:', error);
  } else if (result.success) {
    console.log('SMS sent successfully. Message ID:', result.messageId);
  } else {
    console.log('Failed to send SMS');
  }
});

API

new SmsManager(apiKey: string)

Creates a new instance of the SmsManager class.

  • apiKey (string): Your SMSManager API key

sender.send(phoneNumber: string, message: string): Promise<SMSResult>

sender.send(phoneNumber: string, message: string, callback: (error: Error | null, result: SMSResult) => void): void

Sends an SMS message.

  • phoneNumber (string): The recipient's phone number
  • message (string): The text message to send
  • callback (optional function): A callback function to handle the result

Returns a Promise that resolves to an SMSResult object or calls the callback with the result. The SMSResult object has the following structure:

interface SMSResult {
  success: boolean;
  messageId: string | null;
}
  • success: true if the message was sent successfully, false otherwise.
  • messageId: A string containing the message ID if the send was successful, null otherwise.

License

MIT