mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
23 lines
482 B
Ruby
23 lines
482 B
Ruby
require 'twilio-ruby'
|
|
|
|
class Attempt < ApplicationRecord
|
|
|
|
belongs_to :schedule
|
|
belongs_to :recipient
|
|
belongs_to :recipient_schedule
|
|
belongs_to :question
|
|
|
|
def send_message
|
|
twilio_number = ENV['TWILIO_NUMBER']
|
|
client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
|
|
|
|
client.messages.create(
|
|
from: twilio_number,
|
|
to: recipient.phone,
|
|
body: question.text
|
|
)
|
|
|
|
update_attributes(sent_at: Time.new)
|
|
end
|
|
|
|
end
|