1.0.0 • Published 5 years ago
@smsglobaldev/smsglobal v1.0.0
Example
Check out the code examples
Smsglobal rest api credentials
Rest api credentials can be provided in the SMSGlobal client or node environment variables. The credential variables are SMSGLOBAL_API_KEY and SMSGLOBAL_API_SECRET
Installation
npm install --save smsglobalUsage
- Require
smsglobalin your file
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
var smsglobal = require('smsglobal')(apiKey, secret);To send a sms
var payload = {
origin: 'from number',
destination: 'destination',
message: 'This is a test message'
}
smsglobal.sms.send(payload, function (error, response) {
console.log(response);
});To fetch a list outgoing sms
var promise = smsglobal.sms.getAll();
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});To fetch an outgoing sms by id
var id = 'outgoing-sms-id';
var promise = smsglobal.sms.get(id);
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});To fetch a list incoming sms
var promise = smsglobal.sms.incoming.getAll();
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});To fetch an incoming sms by id
var id = 'incoming-sms-id';
var promise = smsglobal.sms.incoming.get(id);
promise
.then(function(response) {
console.log(response)
})
.catch(function(error){
console.log(error)
});All method returns promise if no callback is given
Running tests
Run the tests:
npm testTo run test with code coverage report
npm run mocha-onlyFollowing endpoints are covered
- sms
- sms-incoming
Reference
1.0.0
5 years ago