sms-gateway-nodejs

0.1.0 • Public • Published

sms-gateway-nodejs

MIT Licence Build Status Codacy Badge Issuestats Issuestats

A library to interact with SMS Gateway API.

Installation

npm install --save sms-gateway-nodejs

Documentation

Initialization

Arguments

  1. emailAddress (String): Your smsgateway username
  2. password (String): Your smsgateway password

Example

smsGateway = require('sms-gateway-nodejs')('ntrinquier@provider.com', 'p4ssw0rd')

Contact

Device

Messages

“Contacts” Methods

createContact(page)

Create a contact.

Arguments

  1. name (String): The contact's name
  2. number (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

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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

  1. device (String): The ID of device you wish to send the message from
  2. number (String): The number to send the message to
  3. message (String): The content of the message to be sent
  4. [sendAt=undefined] (String): Time to send the message in Unix Time format
  5. [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

  1. device (String): The ID of device you wish to send the message from
  2. numbers (Array): The numbers to send the message to
  3. message (String): The content of the message to be sent
  4. [sendAt=undefined] (String): Time to send the message in Unix Time format
  5. [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

  1. device (String): The ID of device you wish to send the message from
  2. contact (String): The contact to send the message to
  3. message (String): The content of the message to be sent
  4. [sendAt=undefined] (String): Time to send the message in Unix Time format
  5. [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

  1. device (String): The ID of device you wish to send the message from
  2. contacts (Array): The contacts to send the message to
  3. message (String): The content of the message to be sent
  4. [sendAt=undefined] (String): Time to send the message in Unix Time format
  5. [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

  1. data (Array): Objects containing the messages to send, at the following format:
  2. device (String): The ID of device you wish to send the message from
  3. contact|number (String): The contact or number to send the message to
  4. message (String): The content of the message to be sent
  5. [sendAt=undefined] (String): Time to send the message in Unix Time format
  6. [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
})

Readme

Keywords

none

Package Sidebar

Install

npm i sms-gateway-nodejs

Weekly Downloads

48

Version

0.1.0

License

MIT

Last publish

Collaborators

  • ntrinquier