Module: Robocall
- Defined in:
- lib/robocall.rb,
lib/robocall/engine.rb,
lib/robocall/version.rb,
app/models/robocall/robocall.rb,
app/helpers/robocall/application_helper.rb,
app/controllers/robocall/robocalls_controller.rb,
app/controllers/robocall/application_controller.rb
Defined Under Namespace
Modules: ApplicationHelper Classes: ApplicationController, Engine, Robocall, RobocallsController
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.auth_token ⇒ Object
Returns the value of attribute auth_token.
-
.base_path ⇒ Object
Returns the value of attribute base_path.
-
.from_phone_number ⇒ Object
Returns the value of attribute from_phone_number.
-
.sid ⇒ Object
Returns the value of attribute sid.
Class Method Summary collapse
- .send_robocall(to: to, text: text, language: 'en-US', from: from_phone_number) ⇒ Object
- .send_robocall_xml(to: to, xml: xml, from: from_phone_number) ⇒ Object
- .send_text(to: to, text: text, from: from_phone_number) ⇒ Object
Class Attribute Details
.auth_token ⇒ Object
Returns the value of attribute auth_token.
9 10 11 |
# File 'lib/robocall.rb', line 9 def auth_token @auth_token end |
.base_path ⇒ Object
Returns the value of attribute base_path.
9 10 11 |
# File 'lib/robocall.rb', line 9 def base_path @base_path end |
.from_phone_number ⇒ Object
Returns the value of attribute from_phone_number.
9 10 11 |
# File 'lib/robocall.rb', line 9 def from_phone_number @from_phone_number end |
.sid ⇒ Object
Returns the value of attribute sid.
9 10 11 |
# File 'lib/robocall.rb', line 9 def sid @sid end |
Class Method Details
.send_robocall(to: to, text: text, language: 'en-US', from: from_phone_number) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/robocall.rb', line 35 def send_robocall(to: to, text: text, language: 'en-US', from: from_phone_number) # Render XML template = <<'HAML' <?xml version='1.0' encoding='utf-8' ?> %Response %Say{:voice => 'alice', :language => language} = text HAML data = {} data['text'] = text data['language'] = language xml = Haml::Engine.new(template).to_html(Object.new, data ) send_robocall_xml(to: to, xml: xml, from: from) end |
.send_robocall_xml(to: to, xml: xml, from: from_phone_number) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/robocall.rb', line 20 def send_robocall_xml(to: to, xml: xml, from: from_phone_number) twilio = get_twilio # Store the xml in a record callback_record = Robocall.new callback_record.xml = xml callback_record.save # construct the callback URL url = base_path+"/robocall/#{callback_record.id}/#{callback_record.token}" twilio.account.calls.create( :from => from, :to => to, :url => url ) end |
.send_text(to: to, text: text, from: from_phone_number) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/robocall.rb', line 11 def send_text(to: to, text: text, from: from_phone_number) twilio = get_twilio twilio.account.sms..create( :from => from, :to => to, :body => text ) end |