Class: ActionSms::ConnectionAdapters::SMSGlobalAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActionSms::ConnectionAdapters::SMSGlobalAdapter
- Defined in:
- lib/action_sms_gateways/connection_adapters/sms_global.rb
Overview
All the concrete gateway adapters follow the interface laid down in this class. You can use this interface directly by borrowing the gateway connection from the Base with Base.connection.
Constant Summary collapse
- SERVICE_HOST =
"http://smsglobal.com.au"
- SERVICE_PATH =
"http-api.php"
Instance Method Summary collapse
- #authenticated?(params, secret_token) ⇒ Boolean
- #deliver(sms) ⇒ Object
-
#initialize(logger = nil, config = {}) ⇒ SMSGlobalAdapter
constructor
:nodoc:.
- #message_id(data) ⇒ Object
- #message_text(params) ⇒ Object
- #sender(params) ⇒ Object
- #status(delivery_receipt) ⇒ Object
Constructor Details
#initialize(logger = nil, config = {}) ⇒ SMSGlobalAdapter
:nodoc:
19 20 21 22 23 24 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 19 def initialize(logger = nil, config = {}) #:nodoc: super(logger) @config = config.dup @service_url = URI.join(SERVICE_HOST, SERVICE_PATH) @service_url.scheme = config[:use_ssl] ? "https" : "http" end |
Instance Method Details
#authenticated?(params, secret_token) ⇒ Boolean
49 50 51 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 49 def authenticated?(params, secret_token) params["userfield"] == secret_token end |
#deliver(sms) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 53 def deliver(sms) params = { :action => 'sendsms', :user => @config[:user], :password => @config[:password], :maxsplit => 3, :from => (sms.from || "reply2email"), :to => sms.recipients, :text => sms.body } params.merge!( :userfield => sms.user_field ) if sms.respond_to?(:user_field) send_http_request(@service_url.to_s, params) end |
#message_id(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 26 def (data) = "SMSGlobalMsgID:" if data.is_a?(Hash) = data["msgid"] + if elsif data.is_a?(String) match = /#{}\d+/.match(data) match[0] if match end end |
#message_text(params) ⇒ Object
41 42 43 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 41 def (params) params["msg"] end |
#sender(params) ⇒ Object
45 46 47 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 45 def sender(params) params["from"] end |
#status(delivery_receipt) ⇒ Object
37 38 39 |
# File 'lib/action_sms_gateways/connection_adapters/sms_global.rb', line 37 def status(delivery_receipt) delivery_receipt["dlrstatus"] end |