Class: Direct7::VERIFY
- Inherits:
-
Object
- Object
- Direct7::VERIFY
- Defined in:
- lib/direct7/verify.rb
Instance Method Summary collapse
- #get_status(otp_id) ⇒ Object
-
#initialize(client) ⇒ VERIFY
constructor
A new instance of VERIFY.
- #resend_otp(otp_id) ⇒ Object
- #send_otp(originator, recipient, content = nil, data_coding = nil, expiry = nil, template_id = nil) ⇒ Object
- #verify_otp(otp_id, otp_code) ⇒ Object
Constructor Details
#initialize(client) ⇒ VERIFY
Returns a new instance of VERIFY.
8 9 10 11 |
# File 'lib/direct7/verify.rb', line 8 def initialize(client) @client = client @log = Logger.new(STDOUT) # You can customize the log destination as needed end |
Instance Method Details
#get_status(otp_id) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/direct7/verify.rb', line 57 def get_status(otp_id) response = @client.get( @client.host, "/verify/v1/report/#{otp_id}" ) @log.info('OTP Message status retrieved successfully.') response end |
#resend_otp(otp_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/direct7/verify.rb', line 34 def resend_otp(otp_id) params = { 'otp_id' => otp_id } response = @client.post( @client.host, '/verify/v1/otp/resend-otp', true, params= params ) @log.info('OTP Message Re-sent successfully.') response end |
#send_otp(originator, recipient, content = nil, data_coding = nil, expiry = nil, template_id = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/direct7/verify.rb', line 13 def send_otp(originator, recipient, content= nil, data_coding= nil, expiry= nil, template_id= nil) if template_id.nil? params = { 'originator' => originator, 'recipient' => recipient, 'content' => content, 'expiry' => expiry, 'data_coding' => data_coding } else params = { 'originator' => originator, 'recipient' => recipient, 'template_id' => template_id } end response = @client.post(@client.host, '/verify/v1/otp/send-otp', true, params= params) @log.info('OTP Message sent successfully.') response end |
#verify_otp(otp_id, otp_code) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/direct7/verify.rb', line 47 def verify_otp(otp_id, otp_code) params = { 'otp_id' => otp_id, 'otp_code' => otp_code } response = @client.post(@client.host, '/verify/v1/otp/verify-otp', true, params= params) @log.info('OTP Message verified successfully.') response end |