Module: StupidSMS::SMS

Defined in:
lib/stupid_sms/sms.rb

Class Method Summary collapse

Class Method Details

.send(client: SMSClient.new, recipient:, body:) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/stupid_sms/sms.rb', line 3

def self.send(client: SMSClient.new, recipient:, body:)
  from_number = StupidSMS.configuration.from_number
  client.send_message(from: from_number, to: recipient, body: body)
  true
rescue Twilio::REST::RequestError => e # the user has unsubscribed
  puts "[StupidSMS ERROR] Twilio::REST::RequestError to: #{recipient} body: #{body}"
  puts e
  false
end