README
sms-gateway-nodejs
A library to interact with SMS Gateway API.
Installation
npm install --save sms-gateway-nodejs
Documentation
Initialization
Arguments
emailAddress
(String): Your smsgateway usernamepassword
(String): Your smsgateway password
Example
smsGateway = require('sms-gateway-nodejs')('ntrinquier@provider.com', 'p4ssw0rd')
Contact
Device
Messages
listOfMessages
fetchSingleMessage
sendMessageToNumber
sendMessageToNumbers
sendMessageToContact
sendMessageToContacts
sendMessagesToRecipients
“Contacts” Methods
createContact(page)
Create a contact.
Arguments
name
(String): The contact's namenumber
(String): The contact's number
Example
smsGateway.contact.createContact('Nicolas', '+33612121212')
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
listOfContacts(page)
Get a list of the contacts.
Arguments
page
(String): The page number
Example
smsGateway.contact.listOfContacts(2)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
fetchSingleContact(id)
Get a specific contact.
Arguments
id
(String): The contact ID
Example
smsGateway.contact.fetchSingleContact(2182)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
“Devices” Methods
listOfDevices(page)
Get a list of the devices.
Arguments
page
(String): The page number
Example
smsGateway.device.listOfDevices(2)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
fetchSingleDevice(id)
Get a specific device.
Arguments
id
(String): The device ID
Example
smsGateway.device.fetchSingleDevice(2182)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
“Messages” Methods
listOfMessages(page)
Get a list of the messages.
Arguments
page
(String): The page number
Example
smsGateway.message.listOfMessages(2)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
fetchSingleMessage(id)
Get a specific message.
Arguments
id
(String): The message ID
Example
smsGateway.message.fetchSingleMessage(2182)
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
sendMessageToNumber(device, number, message, [sendAt], [expiresAt])
Send a message to a number.
Arguments
device
(String): The ID of device you wish to send the message fromnumber
(String): The number to send the message tomessage
(String): The content of the message to be sent[sendAt=undefined]
(String): Time to send the message in Unix Time format[expiresAt=undefined]
(String): Time to give up trying to send the message at in Unix Time format
Example
smsGateway.message.sendMessageToNumber('2012', '+33123456789', 'Hello world :)')
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
sendMessageToNumbers(device, numbers, message, [sendAt], [expiresAt])
Send a message to numbers.
Arguments
device
(String): The ID of device you wish to send the message fromnumbers
(Array): The numbers to send the message tomessage
(String): The content of the message to be sent[sendAt=undefined]
(String): Time to send the message in Unix Time format[expiresAt=undefined]
(String): Time to give up trying to send the message at in Unix Time format
Example
smsGateway.message.sendMessageToNumbers('2012', ['+33123456789', '+33987654321'], 'Penguins rock!')
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
sendMessageToContact(device, contact, message, [sendAt], [expiresAt])
Send a message to a contact.
Arguments
device
(String): The ID of device you wish to send the message fromcontact
(String): The contact to send the message tomessage
(String): The content of the message to be sent[sendAt=undefined]
(String): Time to send the message in Unix Time format[expiresAt=undefined]
(String): Time to give up trying to send the message at in Unix Time format
Example
smsGateway.message.sendMessageToContact('2012', '30', 'Hello world :)')
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
sendMessageToContacts(device, contacts, message, [sendAt], [expiresAt])
Send a message to contacts.
Arguments
device
(String): The ID of device you wish to send the message fromcontacts
(Array): The contacts to send the message tomessage
(String): The content of the message to be sent[sendAt=undefined]
(String): Time to send the message in Unix Time format[expiresAt=undefined]
(String): Time to give up trying to send the message at in Unix Time format
Example
smsGateway.message.sendMessageToContacts('2012', ['5', '30'], 'Penguins rock!')
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})
sendMessagesToRecipients(data)
Send messages to numbers or contacts.
Arguments
data
(Array): Objects containing the messages to send, at the following format:device
(String): The ID of device you wish to send the message fromcontact|number
(String): The contact or number to send the message tomessage
(String): The content of the message to be sent[sendAt=undefined]
(String): Time to send the message in Unix Time format[expiresAt=undefined]
(String): Time to give up trying to send the message at in Unix Time format
Example
smsGateway.message.sendMessagesToRecipients([{
device: '2190',
contact: '42',
message: 'Hi!',
}, {
device: '2109',
number: '+33123456789',
message: 'Hello!',
}])
.then((response) => {
// do something with response
})
.catch((error) => {
// handle error
})