Class: FraudlabsproRuby::Api::SMSVerification

Inherits:
Object
  • Object
show all
Defined in:
lib/fraudlabspro_ruby/api/smsverification.rb

Class Method Summary collapse

Class Method Details

.sendSMS(params = {}) ⇒ Object

Send SMS Verification for authentication.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fraudlabspro_ruby/api/smsverification.rb', line 11

def self.sendSMS(params = {})
  if params[:tel].index('+') != 0
    params[:tel] = '+' + params[:tel]
  end

  uri = URI.parse("https://api.fraudlabspro.com/v2/verification/send")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data({
    'key' => FraudlabsproRuby::Configuration.api_key,
    'format' => 'json',
    'source' => 'sdk-ruby',
    'source_version' => FraudlabsproRuby::VERSION,
    'tel' => params[:tel],
    'mesg' => params[:mesg] || '',
    'otp_timeout' => params[:otp_timeout] || 3600,
    'country_code' => params[:country_code] || ''
  })

  response = http.request(request)

  if response == nil
    return false
  else
    return response
  end
end

.verifySMS(params = {}) ⇒ Object

Get Verification result.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fraudlabspro_ruby/api/smsverification.rb', line 41

def self.verifySMS(params = {})
  uri = URI.parse("https://api.fraudlabspro.com/v2/verification/result?key=" + FraudlabsproRuby::Configuration.api_key + "&format=json&tran_id=" + params[:tran_id] + "&otp=" + params[:otp])
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Get.new(uri.request_uri)

  response = http.request(request)

  if response == nil
    return false
  else
    return response
  end
end