Class: OTP::SMSJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- OTP::SMSJob
- Defined in:
- lib/otp/sms_job.rb
Overview
Uses the AWS SNS API to send the OTP SMS message.
Constant Summary collapse
- TEMPLATE =
A generic template for the message body.
'%{otp} is your magic password 🗝️'
- ENABLED =
Indicates if the messaging is disabled. Handy for testing purposes.
true
Instance Method Summary collapse
-
#perform(phone_number, otp_code, template = TEMPLATE) ⇒ Object
Sends the SMS message with the OTP code.
Instance Method Details
#perform(phone_number, otp_code, template = TEMPLATE) ⇒ Object
Sends the SMS message with the OTP code
19 20 21 22 23 24 25 26 |
# File 'lib/otp/sms_job.rb', line 19 def perform(phone_number, otp_code, template = TEMPLATE) = template % { otp: otp_code } Aws::SNS::Client.new(region: ENV['AWS_SMS_REGION']).publish( message: , phone_number: phone_number ) if ENABLED end |