https://github.com/stitchng/infobip
A NodeJS Wrapper for InfoBip
https://github.com/stitchng/infobip
bulksms bulkvoice infobip nodejs rest-api sms sms-api tts
Last synced: 2 months ago
JSON representation
A NodeJS Wrapper for InfoBip
- Host: GitHub
- URL: https://github.com/stitchng/infobip
- Owner: stitchng
- License: mit
- Created: 2019-05-31T08:58:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T06:17:49.000Z (about 3 years ago)
- Last Synced: 2025-10-05T17:29:07.574Z (9 months ago)
- Topics: bulksms, bulkvoice, infobip, nodejs, rest-api, sms, sms-api, tts
- Language: JavaScript
- Size: 374 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Infobip
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
A NodeJS Wrapper for [InfoBip](https://www.infobip.com/docs/api#channels/)
## 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
```bash
npm i --save infobip-nodejs
```
# Usage
```js
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
```js
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
- [Ifeora Okechukwu](https://twitter.com/isocroft)
# Contributing
See the [CONTRIBUTING.md](https://github.com/stitchng/infobip/blob/master/CONTRIBUTING.md) file for info
[npm-image]: https://img.shields.io/npm/v/infobip-nodejs.svg?style=flat-square
[npm-url]: https://npmjs.org/package/infobip-nodejs
[travis-image]: https://img.shields.io/travis/stitchng/infobip/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/stitchng/infobip