Guest User

Untitled

a guest
Sep 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def confirm
  2. from_phone_number = params['From']
  3. @registration = Registration.find_by_phone_number(from_phone_number)
  4. @content = params['Body']
  5.  
  6. @twilio_client = Twilio::REST::Client.new(
  7. TWILIO_SID,
  8. TWILIO_AUTH
  9. )
  10.  
  11. if @registration && @content == "YES"
  12. @registration.confirmed = true
  13. @registration.save
  14.  
  15. @twilio_client.account.sms.messages.create(
  16. :from => TWILIO_NUMBER,
  17. :to => "+1#{from_phone_number}",
  18. :body => "Your registration has been confirmed!"
  19. )
  20. else
  21. @twilio_client.account.sms.messages.create(
  22. :from => TWILIO_NUMBER,
  23. :to => "+1#{from_phone_number}",
  24. :body => "Could not confirm your registration."
  25. )
  26. end
  27.  
  28. render :text => "OK"
  29. end
Add Comment
Please, Sign In to add comment