Git Product home page Git Product logo

ruby-bulksms's Introduction

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:[email protected])

Modifications have been added by Basayel Said (email:[email protected])

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.

ruby-bulksms's People

Contributors

basayel avatar modsaid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.