init
This commit is contained in:
21
app/workers/sms.rb
Normal file
21
app/workers/sms.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class SmsSender
|
||||
attr_accessor :from
|
||||
attr_accessor :to
|
||||
attr_accessor :message
|
||||
|
||||
def initialize args_as_hash
|
||||
@from = args_as_hash["from"] ||= ENV["twilio_number"]
|
||||
@to = args_as_hash["to"]
|
||||
@message = args_as_hash["message"]
|
||||
end
|
||||
|
||||
def send!
|
||||
twilio.messages.create(from: @from, to: @to, body: @message)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def twilio
|
||||
Twilio::REST::Client.new ENV['twilio_sid'], ENV['twilio_token']
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user