1.0.5 • Published 6 years ago
sms-hubtel v1.0.5
sms-hubtel
A nodejs module for hubtel send message APi
Features
Sending Messages
Scheduling Messages
Rescheduling Messages
Getting A Particular Message
Getting All Messages
Cancelling Scheduled Messages
Installation
npm i --save sms-hubtel
Usage
const hubtelSMS = require("sms-hubtel");
const SMS = hubtelSMS({
clientid: "HubtelApplicationClientId",
secretid: "HubtelApplicationSecreteId"
});
Send Message
SMS.sendSMS({
From: "Sender", //Sender
To: "+233509879941", //Receiver
Content: "hello, world!",
RegisteredDelivery: true
})
.then(res => console.log(res))
.catch(error => console.log(error));
Sample response
{
"Status": 0,
"MessageId": "43cceb19d2a242f58fb338692e12c0bb",
"Rate": 0,
"NetworkId": "0"
}
NB: To send the message at a particular time (schedule) add Time to the request object Example is
{
"From": "smsgh",
"To": "+233248183797",
"Content": "hello, world!",
"RegisteredDelivery": "true",
"Time": "2014-01-01 10:00:00"
}
Get message
SMS.getMessage("messageID").then(data => {
console.log(data);
});
Sample Response
{
"MessageId": "6f19395db2fb497ea4ebd1e218dd3e4c",
"From": "Seinti",
"To": "+233208183783",
"Time": "2013-06-02 10:56:34",
"UpdateTime": "2013-08-12 17:11:42",
"NetworkId": "62001",
"Units": 1,
"Rate": 1,
"Status": "Undeliverable",
"Content": "hello, Kwadwo!"
}
Query message (Get all your messages)
SMS.queryMessage().then(data => {
console.log(data);
});
Sample Response
{
"TotalPages": 1,
"Messages": [
{
"Rate": 0,
"Units": 1,
"MessageId": "4e60fb0b-a562-42bd-bf4a-22f1361c853d",
"Content": "hello, world!",
"Status": "Out of Credit",
"NetworkId": "62002",
"UpdateTime": "2018-10-06 02:43:05",
"Time": "2018-10-06 02:43:05",
"Direction": "out",
"To": "+233509879941",
"From": "Kwadwo"
},
{
"Rate": 0,
"Units": 1,
"MessageId": "c1fc94c4-3c3e-4750-9176-966959d93620",
"Content": "Hello John",
"Status": "Out of Credit",
"NetworkId": "62002",
"UpdateTime": "2018-10-14 12:17:08",
"Time": "2018-10-14 12:17:08",
"Direction": "out",
"To": "+233509879941",
"From": "John"
},
{
"Rate": 0,
"Units": 1,
"MessageId": "190cbcc7-8368-456c-a412-f5f754abcd71",
"Content": "Hello John",
"Status": "Out of Credit",
"NetworkId": "62002",
"UpdateTime": "2018-10-14 14:15:05",
"Time": "2018-10-14 14:15:05",
"Direction": "out",
"To": "+233509879941",
"From": "John"
}
]}
,
NB:You can provide a query parameter
SMS.queryMessage({ limit: 10 }).then(data => {
console.log(data);
});
Reschedule schedule message
SMS.rescheduleMessage(
"MessageID",
"2013-08-12 17:11:42" // Time
).then(data => {
console.log(data);
});
Cancel schedule message
SMS.cancelMessage("MessageID").then(data => {
console.log(data);
});
Test
npm run test
Please visit https://developers.hubtel.com for more information
Happy Coding