Skip to content

Instantly share code, notes, and snippets.

@jagdeepsingh
Last active May 25, 2017 12:06
Show Gist options
  • Select an option

  • Save jagdeepsingh/3804c8afee868801ee2fbefacdf70f53 to your computer and use it in GitHub Desktop.

Select an option

Save jagdeepsingh/3804c8afee868801ee2fbefacdf70f53 to your computer and use it in GitHub Desktop.
cm-sms- Wrapper for the CM SMS Gateway API

cm-sms

Contents:

Setup account

Register for an account on cmtelecom.com and you will be provided with a TOKEN (e.g. 00000000-0000-0000-0000-000000000000) for authentication.

Configuration

Add the following to Gemfile and run bundle install.

gem 'cm-sms', github: 'jagdeepsingh/cm-sms', ref: 'a7a25460838e1eeb09578e8f3d1ab3cc27ba1534'

Set the product token.

CmSms.config.product_token = TOKEN

Define messenger class

Define a class for sending SMS.

# app/services/sms_notifier.rb
class SmsNotifier < CmSms::Messenger
  def sms(from, to, body, reference)
    content(from: from,
            to: to,
            body: body,
            reference: reference)
  end
end

Send SMS

SmsNotifier.sms(SENDER, MOBILE_NUMBER, SMS_BODY, UNIQUE_REFERENCE).deliver_now

MOBILE_NUMBER should be a mobile number in the format 00919512345678 or +919512345678, where 91 is country code followed by 10-digit mobile number 9512345678.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment