Skip to content

Net::SMS::BulkSMS is a Ruby library that allows you to easily integrate SMS services into your Ruby or RubyOnRails applications.

Notifications You must be signed in to change notification settings

RubyOnWorld/ruby-bulksms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Net::SMS::BulkSMS is a Ruby library that allows you to easily integrate SMS services into your Ruby or RubyOnRails applications.

It has support for all BulkSMS international sites, including the UK, USA, South Africa, Spain and Europe.

To use the library, you will need an account from www.bulksms.com and some credits.

Examples

Creating a new service and sending a message is simple.

s = Service.new('myusername', 'mypassword')
s.send('Hello, I hope you like my message!', '44799123456')

Additional message options

The Service class also has a send instance method that accepts a Message object. This allows you to construct your own Message objects and set additional parameters.

s = Service.new('myusername', 'mypassword')
m = Message.new('Hello, look at my funky message', '44799123456')
m.routing_group = 1
m.want_report = 1
s.send_message(m)

Both send and send_message return a Response object.

Checking your account balance

If you already have an existing Service object, you can easily check your account balance.

s = Service.new('myusername', 'mypassword')
s.account.credits

Alternatively, you can create an Account object directly.

a = Account.new('myusername', 'mypassword')
a.credits

Sending multiple messages with a single http connection

Also you can use a single http connection & send multiple messages using send_multiple method that accepts an array of Message object and return an array of Response object

s = Service.new('myusername', 'mypassword')
messages = []
responses = []
m1 = Message.new('Hello1, look at my funky message', '44799123456')
m2 = Message.new('Hello2, look at my funky message', '44799123666')
messages << m1
messages << m2
responses = s.send_multiple(messages)

For a further example, see the simple command line client provided.

Limitations

This library currently only implements a small portion of the API, allowing you to send messages and check your account balance. Further parts of the BulkSMS API may be implemented in the future such as the ability to receive messages and status reports and manage the address book provided by BulkSMS.

A note about testing

I tried to cover the library with unit tests where possible however I’m not very experienced with unit testing network services and all tests require a valid account to run. If anybody could share some advice here it would be much appreciated.

Authors

The Original work is made by Luke Redpath (email:contact@lukeredpath.co.uk)

Modifications have been added by Basayel Said (email:eng.basayel.said@gmail.com)

Modifications include:

  • fixing a bug related to getting the host of bulksms service.

  • Adding method named (send_multiple) in order to use a single http connection in sending multiple message objects.

  • adding gem spec file to the library.

  • packaging the library as a gem.

About

Net::SMS::BulkSMS is a Ruby library that allows you to easily integrate SMS services into your Ruby or RubyOnRails applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages