class OTP::SMSJob

Uses the AWS SNS API to send the OTP SMS message.

Constants

ENABLED

Indicates if the messaging is disabled. Handy for testing purposes.

TEMPLATE

A generic template for the message body.

Public Instance Methods

perform(phone_number, otp_code, template = TEMPLATE) click to toggle source

Sends the SMS message with the OTP code

@return nil

# File lib/otp/sms_job.rb, line 19
def perform(phone_number, otp_code, template = TEMPLATE)
  message = template % { otp: otp_code }

  Aws::SNS::Client.new(region: ENV['AWS_SMS_REGION']).publish(
    message: message,
    phone_number: phone_number
  ) if ENABLED
end