You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

nimbasms

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nimbasms

A Node JS module for communicating with Nimba SMS API.

1.0.0
latest
npmnpm
Version published
Weekly downloads
10
42.86%
Maintainers
1
Weekly downloads
 
Created
Source

nimbasms-node

A NodeJS module for communicating with Nimba SMS API.

Usage

  • Installation
  • Check balance
  • Groups
  • Sendernames
  • Create Contacts
  • Send Message
  • Verifications

Installation

npm install nimbasms

Check balance

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)

// Get your account balance
client.accounts.get()
    .then(account => {
        console.log(`My Account balance: ${account['balance']}`);
    })
    .catch(error => {
        console.log(error);
    })

Groups

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)

client.groups.list()
    .then(groups => {
      console.log(`There are ${groups.count} groups.`);
      // or
      // console.log(`There are ${groups.results.length} groups.`);
    })
    .catch(error => {
        console.log(error);
    })

Sendernames

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)

client.sendernames.list()
  .then(sendernames => {
      console.log(`There are ${sendernames.count} sendernames.`);
      for(let sendername of sendernames.results)  {
          console.log(sendername)
      }
  })
  .catch(error => {
      console.log(error);
  })

Create Contact

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)

// List of all contacts
client.contacts.list()
  .then(contacts => {
      console.log(`There are ${contacts.results.length} contacts.`);
      for(let contact of contacts.results) {
          console.log(contact);
      }
  })
  .catch(error => {
      console.log(error);
  })


// This contact will be added to the default contact list
const body = {
    numero: '224XXXXXXXXX'
}
client.contacts.create(body)
  .then(contact => {
        console.log(`A contact has been added : `, contact);
    })
    .catch(error => {
        console.log(error);
    });

// Create with groups and name - name and groups are optional.
const body = {
    numero: '224XXXXXXXXX',
    name: 'Foo',
    groups: ['API', 'Facebook Client'],
}

client.contacts.create(body)
    .then(contact => {
        console.log(`A contact has been added :`, contact);
    })
    .catch(error => {
        console.log(error);
    });

Messages

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)


// Get All messages
client.messages.list()
    .then(messages => {
        console.log(`There are ${messages.count} messages in your account.`);
    })
    .catch(error => {
        console.log(error);
    });

// Get only 10 last messages
client.messages.list({limit: 10})
    .then(messages => {
        console.log('Here are the last 10 messages in your account:')
        for( message of messages.results){
            console.log(message)
        }
    })
    .catch(error => {
        console.log(error);
    });

// Send a message
const body = {
  to: ['6XXXXXXXXX'], // The recepients
  message: 'Hello from Nimba SMS !', 
  sender_name: 'YYYYYYYYYY', // Replace with your sender name
}

client.messages.create(body)
  .then(message => {
      console.log(`A new message has been sent : `, message);
  })
  .catch(error => {
      console.log(error);
  });

// Retrieve a message's details
const messageId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
client.messages.get(messageId)
  .then(message => {
    console.log('Got one message : ', message)
  })
  .catch(error => {
    console.log(error);
  });

Verifications

const { Client } = require('nimbasms/client');

const config = {
    SERVICE_ID = 'XXXXXXXXXXX', 
    SECRET_TOKEN = 'YYYYYYYYYYYYYYYYYYY',
}

const client = new Client(config)


// Send a verification request
const verification = {
    to: "+123456789",
    message: "Your verification code is: <1234>",
    expiry_time: 5,
};

client.verifications.create(verification)
    .then(response => {
        console.log("A verification request is issued: ", response);
    })
    .catch(error => {
        console.log(error);
    });


// Verify a verification request
const verificationParams = {
    verificationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    code: "YYYY",
};

client.verifications.verify(verificationParams)
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.log(error);
    })

Credit

Nimba SMS

Keywords

NIMBASMS

FAQs

Package last updated on 07 Nov 2023

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