class Outbox::Msg91::Client
Uses MSG91s php API client to deliver SMS messages.
Outbox::Messages::SMS.default_client( :msg91, authkey = "xxxxxxxxxxxxxxxxxxx") sms = Outbox::Messages::SMS.new( from: = "ABCDEFG" <6 digit code> body: 'Hello World' ) sms.deliver('+15552224444')
Attributes
auth_key[R]
senderid[R]
Public Class Methods
new(settings = nil)
click to toggle source
Calls superclass method
# File lib/outbox/msg91/client.rb, line 16 def initialize(settings = nil) super options = @settings.dup p @options # 4 indicates transactional sms @route_code = 4 @authkey = options[:authkey] end
Public Instance Methods
deliver(sms)
click to toggle source
MSG91 API Documented at api.msg91.com/apidoc/textsms/send-sms.php
# File lib/outbox/msg91/client.rb, line 35 def deliver(sms) params = {:authkey => @authkey, :mobiles => sms.to, :message => sms.body , :sender => sms.from ,:route => @route_code, :response => "json"} url = "http://api.msg91.com" uri = full_path(url, '/api/sendhttp.php', params) #p uri response = Net::HTTP.get(uri) end
full_path(url, path, params)
click to toggle source
# File lib/outbox/msg91/client.rb, line 28 def full_path(url, path, params) encoded_params = URI.encode_www_form(params) params_string = [path, encoded_params].join("?") URI.parse(url + params_string) end