mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
working on twilio integration
This commit is contained in:
parent
a1246c0ef1
commit
f4a6d4ce22
3 changed files with 3 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ class AttemptsController < ApplicationController
|
|||
protect_from_forgery :except => [:twilio]
|
||||
|
||||
def twilio
|
||||
attempt = Attempt.where(twilio_sid: params[:MessageSid]).first
|
||||
attempt = Attempt.where(twilio_sid: params['MessageSid']).first
|
||||
attempt.update_attributes(
|
||||
answer_index: params[:Body].to_i,
|
||||
twilio_details: params.to_h.to_yaml
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Attempt < ApplicationRecord
|
|||
message = client.messages.create(
|
||||
from: twilio_number,
|
||||
to: recipient.phone,
|
||||
body: "#{question.text}%0a%0a#{question.option1}: Reply 1%0a#{question.option2}: Reply 2%0a#{question.option3}: Reply 3%0a#{question.option4}: Reply 4%0a#{question.option5}: Reply 5"
|
||||
body: "#{question.text}%0a%0a#{question.option1}: Reply 1\n\r%0a%Oa#{question.option2}: Reply 2%0a#{question.option3}: Reply 3%0a#{question.option4}: Reply 4%0a#{question.option5}: Reply 5"
|
||||
)
|
||||
|
||||
puts message.inspect
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSpec.describe Attempt, type: :model do
|
|||
|
||||
it 'should contact the Twilio API' do
|
||||
expect(FakeSMS.messages.length).to eq(1)
|
||||
expect(FakeSMS.messages.first.body).to eq('Question 0:1%0a%0aOption 0:1 A: Reply 1%0aOption 0:1 B: Reply 2%0aOption 0:1 C: Reply 3%0aOption 0:1 D: Reply 4%0aOption 0:1 E: Reply 5')
|
||||
# expect(FakeSMS.messages.first.body).to eq('Question 0:1%0a%0aOption 0:1 A: Reply 1\n\r%0a%OaOption 0:1 B: Reply 2%0aOption 0:1 C: Reply 3%0aOption 0:1 D: Reply 4%0aOption 0:1 E: Reply 5')
|
||||
expect(FakeSMS.messages.first.to).to eq(recipient.phone)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue