Created
August 6, 2022 02:27
-
-
Save dmbf29/30b6ecb67f157bbaebae02de4ee63295 to your computer and use it in GitHub Desktop.
Twilio Sms Service object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twilio-ruby' | |
class SendSmsService | |
def initialize(message) | |
@message = message | |
# probably pass in the user as well so you can get the phone number? | |
end | |
def call | |
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN) | |
client.messages.create( | |
from: ENV['TWILIO_NUMBER'], # Your Twilio number | |
to: '+81802166xxxx', # User mobile phone number | |
body: message | |
) | |
end | |
end | |
# To call it: | |
# SendSmsService.new('YOUR MESSAGE').call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment