lib/cellular/backends/sendega.rb in cellular-2.1.0 vs lib/cellular/backends/sendega.rb in cellular-2.2.0
- old
+ new
@@ -1,13 +1,13 @@
require 'savon'
module Cellular
module Backends
+ # Sendega backend (http://sendega.com)
class Sendega < Backend
+ GATEWAY_URL = 'https://smsc.sendega.com/Content.asmx?WSDL'.freeze
- GATEWAY_URL = 'https://smsc.sendega.com/Content.asmx?WSDL'
-
def self.deliver(options = {}, savon_options = {})
# Send an SMS and return its initial delivery status code.
#
# Delivery status codes:
# 0 -- Message is received and is being processed.
@@ -43,33 +43,33 @@
result = client.call(:send, message: defaults_with(options))
request_queue[index] = {
batch: batch,
result: result,
- body:result.body[:send_response][:send_result],
+ body: result.body[:send_response][:send_result],
response: map_response(result.body[:send_response][:send_result])
}
end
# for now just resturn first response
request_queue[0][:response]
end
- def self.receive(data)
+ def self.receive(_data)
raise NotImplementedError
end
def self.savon_config
{
- username: Cellular.config.username,
- password: Cellular.config.password,
- dlrUrl: Cellular.config.delivery_url
+ username: Cellular.config.username,
+ password: Cellular.config.password,
+ dlrUrl: Cellular.config.delivery_url
}
end
def self.defaults_with(options)
- {
+ {
sender: options[:sender],
destination: options[:batch],
pricegroup: options[:price] || 0, # default price to 0
contentTypeID: 1,
contentHeader: '',
@@ -83,25 +83,24 @@
pid: 0,
dcs: 0
}.merge!(savon_config)
end
- def self.map_response(_body)
- msg = _body[:success] ? success_message : _body[:error_message]
- [ _body[:error_number].to_i, msg ]
+ def self.map_response(body)
+ msg = body[:success] ? success_message : body[:error_message]
+ [body[:error_number].to_i, msg]
end
def self.success_message
'Message is received and is being processed.'
end
def self.recipients_batch(options)
if options[:recipients].blank?
[options[:recipient]]
else
- options[:recipients].each_slice(100).to_a.map{|x| x.join(',') }
+ options[:recipients].each_slice(100).to_a.map { |x| x.join(',') }
end
end
-
end
end
end