Project

cm-sms

0.01
No commit activity in last 3 years
No release in over 3 years
Send text messages by means of the HTTP protocol with the service of https://www.cmtelecom.com.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
~> 3.0
~> 1.0

Runtime

~> 3.2
~> 2.12
 Project Readme

alt text

Cm-Sms

Build Status Gem Code Climate Coverage

Description

Send text (SMS) messages via the HTTP API of CM Telecom from your Ruby app.

For Rails integration, please see: https://github.com/HitFox/cm-sms-rails. ​

Usage

Create a class that is inherited from CmSms::Messenger.

class TextMessageNotifier < CmSms::Messenger
end

Now you can add methods to send messages. For example, send a welcome message with:

class TextMessageNotifier < CmSms::Messenger
  default from: 'some string or mobile number'

  def welcome(recipient)
    @recipient = recipient
    
    content(to: recipient.mobile_number, body: 'Some text, reference: recipient.id)
  end
end

Setting defaults

Use the public class method default to set default values that will be used in every method of your CmSms::Messenger subclass. This method accepts a Hash as the parameter with possible keys :from, :to and :body. You may override these defaults inside the methods themselves.

Example:

class TextMessageNotifier < CmSms::Messenger
  default from: 'Quentin', '00491710000000'
  ...
end

Deliver Messages

To send your SMS, call the desired method and then call deliver_now on the return value.

Calling the method returns a CmSms::Message object:

message = TextMessageNotifier.new.welcome(User.first)   # => Returns a CmSms::Message object
message.deliver_now

Optional Number Validation

Cm-Sms will look for the presence of either Phony or Phonelib and use one of these libraries to perform a basic check of receiver number. This check does not consider whether the number is a mobile number.

Installation

If you user bundler, then just add

$ gem 'cm-sms'

to your Gemfile and execute

$ bundle install

or without bundler

$ gem install cms-sms

Upgrade

$ bundle update cms-sms

or without bundler

$ gem update cms-sms

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/HitFox/cm-sms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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