Socket
Socket
Sign inDemoInstall

infobip-nodejs

Package Overview
Dependencies
47
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    infobip-nodejs

A NodeJS Wrapper for InfoBip


Version published
Weekly downloads
43
increased by48.28%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Infobip

NPM Version Build Status

A NodeJS Wrapper for InfoBip

Overview

This project provides an easy-to-use object-oriented API to access endpoints delineated at https://www.infobip.com/docs/api

Installation

Install from the NPM Registry


  npm i --save infobip-nodejs

Usage


let InfoBip = require('infobip-nodejs')

let APIKEY = '1IkXmSWOlE4y9Inhgyd6g5f2R7'
const environment = process.env.NODE_ENV
const isProduction = (environment === 'production')

const infobip = new InfoBip(APIKEY, isProduction, {
  authType:'basic',
  username:'user', // Infobip Username used for registration
  password:'*******', // Infobip Password used for registration
  encrypted:false,
  baseHost: 'okllaq.api.infobip.com'
})

/* 
  Send SMS to two mobile numbers  
  
  - NB: make sure the Sender ID is registred with infobip before use
*/
const promise = infobip.sendSMS({
  messages: [{
    from: "YourCompanyName", // Sender ID
    destinations: [
      { to: '+2348164422256' },  // MTN Numbers
      { to: '+2347039664638' }
    ],
    text: 'Dear Customer, Thanks for registering with our service.'
  }],
  bulkId: "BULK-ID-awq6545pOu7ye6" // Auto-generated with prefix: "BULK-ID-"
})

promise.then( response => {
 const { body } = response
 console.log('response body: ', body)
}).catch( error => {
  console.error(error)
})

API Resources

  • infobip.sendSMS()
  • infobip.sendSMSBinary()
  • infobip.sendVoice()

Mocking instance for Unit/Integration Tests


const APIKEY = "hJ5Ds2e49jk0UiLa8fq36Sw7Y"
const isProduction = false
const infobip = new InfoBip(APIKEY, isProduction, {
  authType:'basic',
  username:'user', // Infobip Username used for registration
  password:'*********', // Infobip Password used for registration
  encrypted:false,
  baseHost: 'okllaq.api.infobip.com'
});

// start mocking on instance (during a unit/integration test)
infobip.engageMock()

// calling a mocked method sendVoice()
infobip.sendVoice({
  from: "MyCompanyName", // Sender ID
  to: "+2349023465560", // Airtel Number
  language: "en",
  voice: {
    name: "Paul",
    gender: "male"
  }
  text: "Just Saying Hello"
});

// stop mocking on instance
infobip.disengageMock()

// It's also possible to swap out mocked methods
// with custom implementations
infobip.mockMacro('sendSMS', function (params) {
  return Promise.reject({
    messageId: "xxxxxxxxxxxxxxxxxxxxxxxxx"
  });
});

License

MIT

Credits

Contributing

See the CONTRIBUTING.md file for info

Keywords

FAQs

Last updated on 25 Mar 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc