Skip to content

Instantly share code, notes, and snippets.

@HunnyJummani
Last active February 17, 2021 20:27
Embed
What would you like to do?
require 'send_otp'
class Otp
# You can configure it in credentials/secrets as per your requirement and initialize both here.
AUTH_KEY = MSG_91_AUTH_KEY_HERE
SENDER_ID = MSG_91_SENDER_ID_HERE
attr_accessor :phone_no, :sendotp
def initialize(phone_no)
@phone_no = phone_no
@sendotp = SendOtp::Otp.new(AUTH_KEY)
end
def create
sendotp.send_otp(phone_no, SENDER_ID)
end
def verify(otp)
sendotp.verify(phone_no, otp)
end
def retry
# if you want to enable call based otp then keep retry_voice = true, false either.
sendotp.retry(phone_no, retry_voice)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment