class WavecellOtpAndSms::VerifyOtp
Attributes
code[RW]
uid[RW]
Public Class Methods
new(options = {})
click to toggle source
Initialize OTP parameters
# File lib/wavecell_otp_and_sms/verify_otp.rb, line 9 def initialize(options = {}) @uid = options[:uid] @code = options[:code] end
Public Instance Methods
send()
click to toggle source
Call this to generate url for the api calls
# File lib/wavecell_otp_and_sms/verify_otp.rb, line 15 def send generate_url end
Private Instance Methods
generate_url()
click to toggle source
Construct API using the parameters and initial configuration
# File lib/wavecell_otp_and_sms/verify_otp.rb, line 21 def generate_url api_key = WavecellOtpAndSms.configuration.api_key sub_account = WavecellOtpAndSms.configuration.sub_account details = [uid, code] parameters = { uid: uid, code: code } query_string = parameters.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join("&") url = "https://api.wavecell.com/otp/v1/#{sub_account}/#{uid}?code=#{code}" HTTParty.get(url.to_str, :body => parameters.to_json, :headers => { "Content-Type" => "application/json", "Authorization" => "Bearer #{api_key}" }) end