Class: Tolliver::Services::Methods::Sms::Plivo
- Inherits:
-
Object
- Object
- Tolliver::Services::Methods::Sms::Plivo
- Defined in:
- lib/tolliver/services/methods/sms/plivo.rb
Instance Method Summary collapse
- #deliver(notification, notification_receiver) ⇒ Object
-
#initialize(params = {}) ⇒ Plivo
constructor
A new instance of Plivo.
Constructor Details
#initialize(params = {}) ⇒ Plivo
Returns a new instance of Plivo.
18 19 20 21 22 23 24 25 26 |
# File 'lib/tolliver/services/methods/sms/plivo.rb', line 18 def initialize(params = {}) require 'plivo' if params[:auth_id].blank? || params[:auth_token].blank? raise Tolliver::Errors::StandardError.new('Please provide Auth ID and Auth Token in SMS provider params.') end @auth_id = params[:auth_id] @auth_token = params[:auth_token] @client = ::Plivo::RestClient.new(@auth_id, @auth_token) end |
Instance Method Details
#deliver(notification, notification_receiver) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tolliver/services/methods/sms/plivo.rb', line 28 def deliver(notification, notification_receiver) # Sender raise Tolliver::Errors::StandardError.new("Please specify SMS sender.") if Tolliver.sms_sender.nil? # Request API @client..create(Tolliver.sms_sender, # TODO: This should be improved to take sender from number pool and remember number / message mapping [notification_receiver.receiver_phone.to_s], ActionController::Base.helpers.(notification..to_s)) true end |