TWW

Build Status Code Climate Coverage Status

Send SMS through TWW plataform. Avoid to handle with HTTP libraries or to parse XML response.

Installation

Add this line to your application's Gemfile:

gem 'tww'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tww

Usage

To send SMS:

TWW.config do |config|
  config.username = 'you username goes here'
  config.password= 'you password goes here'
  config.from = 'Your identification (OPTIONAL)'
  config.layout = 'Layout ID (JUST FOR VOICE MESSAGES)'
end

client = TWW.client

client.deliver('11987654321', 'Hello World using old fashioned SMS')
client.call('11987654321', 'I just called to say I love you')

You can inspect TWW response:

# Previous setup
resp = client.deliver('11987654321', 'Hello World using old fashioned SMS')

case
when resp.ok?
  puts 'Everything is nice!'
when resp.nok?
  puts 'Something goes wrong'
when resp.na?
  puts 'Service not available!'
when resp.error?
  puts 'Unknow error'
end

You can use obscure parameters from TWW API.

# Previous setup
client.call('11987654321', 'Var 1 value', var2: 'Var 2 value', retry: 3)

To fake SMS:

require 'rspec'
require 'tww'

TWW.enable_testing!

RSpec.describe 'TWW Testing' do
  before
    client = TWW.client
    resp = client.deliver('11987654321', 'Hello World from TWW Gem')
  end

  it 'is not empty' do
    expect(client.sent).to_not be_empty
  end

  it 'is empty after clear'
    client.clear
    expect(client.sent).to be_empty
  end
end

Support

It supports Ruby version 2.1.x, 2.2.x and 2.3.x.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dlibanori/tww.

License

The gem is available as open source under the terms of the MIT License.