Sha256: ec18d55c60345b5059839937b183b9bcd718b860ca2fd088ff1e7ec6986416cd

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

require 'json'
require 'net/http'
require 'uri'
require 'logger'

module Direct7
  class VERIFY
    def initialize(client)
      @client = client
      @log = Logger.new(STDOUT) # You can customize the log destination as needed
    end

    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

    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

    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

    def get_status(otp_id)
      response = @client.get(
        @client.host,
        "/verify/v1/report/#{otp_id}"
      )
      @log.info('OTP Message status retrieved successfully.')
      response
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
direct7-0.0.18 lib/direct7/verify.rb
direct7-0.0.17 lib/direct7/verify.rb
direct7-0.0.16 lib/direct7/verify.rb
direct7-0.0.13 lib/direct7/verify.rb
direct7-0.0.12 lib/direct7/verify.rb
direct7-0.0.11 lib/direct7/verify.rb
direct7-0.0.10 lib/direct7/verify.rb
direct7-0.0.9 lib/direct7/verify.rb
direct7-0.0.8 lib/direct7/verify.rb
direct7-0.0.1 lib/direct7/verify.rb