exetel_sms: Send and receive messages via Exetel’s SMS API


gem install ‘exetel_sms’

Send a message:


require 'exetel_sms'
config = ExetelSms::Config.new('username', 'password')
sender = ExetelSms::Sender.new(config)
result = sender.send(
  'destination mobile number',
  'message',
  'from string',
  sender.class.new_reference_number('application_identifier')
)
if result.success?
  puts "Message sent successfully!"
else
  puts "Error sending message: #{result[:notes]}"
end

Was it really sent?


retriever = ExetelSms::Retriever.new(config)
result = retriever.check_sent('reference_number')
result[:message_status]
=> 'Sent'

Receiving messages from a Virtual Mobile Number


receiver = ExetelSms::Receiver.new(config)
if result = receiver.receive('my virtual mobile number')
  puts "Received from #{result[:from_mobile_number]}: #{result[:message]}"
end

Then you can delete the messages with ExetelSms::Deleter

Credit Check - also useful as a ping before sending


checker = ExetelSms::CreditCheck.new(config)
if result = checker.get_credit_limit
  puts "Credit limit is #{result[:limit]}"
end

Test API - test responses without making actual HTTP calls


good = ExetelSms::Client.with_test_api { retriever.check_sent('1') }
good[:message_status] # => 'Delivered'

bad = ExetelSms::Client.with_test_api(:fail) { retriever.check_sent('1') }
bad[:message_status] # => 'Failed'

Sent messages end up in ExetelSms::Client.sent_messages array. See test/ for more examples.

Contact the author


Andrew Snow <[email protected]> Andys^ on irc.freenode.net @andy_snow on Twitter