Class: Nuntius::TwilioVoiceProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- Nuntius::TwilioVoiceProvider
- Defined in:
- app/providers/nuntius/twilio_voice_provider.rb
Overview
Send Voice call messages using twilio.com
Instance Attribute Summary
Attributes inherited from BaseProvider
Instance Method Summary collapse
Methods inherited from BaseProvider
all_settings, class_from_name, #initialize, #name, setting_reader, states, transport
Constructor Details
This class inherits a constructor from Nuntius::BaseProvider
Instance Method Details
#callback(params) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/providers/nuntius/twilio_voice_provider.rb', line 33 def callback(params) refresh.save twiml = script_for_path(, "/#{params[:path]}", params) if twiml [200, {"Content-Type" => "application/xml"}, [twiml[:body]]] else [404, {"Content-Type" => "text/html; charset=utf-8"}, ["Not found"]] end end |
#deliver ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/providers/nuntius/twilio_voice_provider.rb', line 18 def deliver # Need hostname here too response = client.calls.create(from: .from.present? ? .from : from, to: .to, method: "POST", url: callback_url) .provider_id = response.sid .status = translated_status(response.status) end |
#refresh ⇒ Object
26 27 28 29 30 31 |
# File 'app/providers/nuntius/twilio_voice_provider.rb', line 26 def refresh response = client.calls(.provider_id).fetch .provider_id = response.sid .status = translated_status(response.status) end |