Sha256: e3c30c8873d2ab979d334319674d0d40958e65c234e551c29484d5341133bd3d
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
# ShortMessage [](http://badge.fury.io/rb/short_message) ## Installation Add it to your Gemfile: ```ruby gem 'short_message' ``` Run the following command to install it: ```console bundle install ``` Run the generator: ```console rails generate short_message:install ``` And run the migrations: ```console rake db:migrate ``` ## Usage Create a message and deliver it: ```ruby @sms = ShortMessage::Message.new(sender: "0041791234567", recipient: "0041799876543", text: "Hello World!") @sms.deliver ``` ## Delivery Report ShortMessage listens for status updates on `/short_message/messages/status`. Provide `:id` and `:status` by either `POST` or `GET`. ## Customization ### Status Codes If you need to customize the status response codes simply edit the internationalization files in config/locales ### Params To override the params string add the code below into `config/initializers/short_message.rb`: ```ruby ShortMessage::Message.module_eval do private def build_deliver_params_string # your code here end def build_recharge_params_string amount # your code here end end ``` ### Events ShortMessage sends event notifications on message delivery `short_message.delivered` and on status update `short_message.status_updated`. Add following code to an initializer to listen: ```ruby ActiveSupport::Notifications.subscribe('short_message.status_updated') do |name, start, finish, id, payload| Activity.create(successful: true, message: "Message #{payload[:options][:key]} has now status #{payload[:options][:status]}.") end ```
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
short_message-1.1.2 | README.md |
short_message-1.1.1 | README.md |
short_message-1.1.0 | README.md |