Last active
February 17, 2021 20:27
-
-
Save HunnyJummani/662a3dfaada86dbe9a90cf2f56e4d9a9 to your computer and use it in GitHub Desktop.
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 '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