SMS library inspired by ActionMailer
Ruby
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
lib twilio api sms updated Sep 2, 2014
spec update specs to the new rspec syntax Mar 29, 2015
.gitignore Initial commit May 24, 2014
.rspec Initial commit May 24, 2014
Gemfile update specs to the new rspec syntax Mar 29, 2015
Gemfile.lock update gems Apr 12, 2015
LICENSE.txt Initial commit May 24, 2014
README.md readme updated May 31, 2014
Rakefile
VERSION
actionsms.gemspec Regenerate gemspec for version 0.0.2 Apr 12, 2015

README.md

ActionSMS

ActionSMS was inspired by ActionMailer and it aims to provide a unified interface for using an SMS provider.

Synopsis

# config/initializers/sms.rb
require 'sms/method/twilio'
Sms.delivery_method = Sms::Method::Twilio.new(account_sid, auth_token, default_from)
# app/models/user.rb
require 'actionsms'
after_create do
  message = Sms::Message.new(from: '123', to: phone, text: 'Thanks for signing up!')
  message.deliver
end

Example controller receiving SMS:

require 'sms'

class SmsController < ActionController::Metal
  def receive
    self.content_type = 'text/plain'
    unless %w[from to text].all? { |key| params.key?(key) }
      self.status = 400
      self.response_body = "Invalid Request\n"
      return
    end
    SmsReceiver.receive(params)
    self.response_body = ''
  end
end

class SmsReceiver < Sms
  def receive(sms)
    Rails.logger.info "SMS: #{sms.inspect}"
  end
end

TODO

  • Railtie for doing things like config.action_sms.delivery_method = :file
  • Configurable place for the file