veratad 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/veratad.rb +110 -0
- metadata +45 -0
data/lib/veratad.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'builder'
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
class VeratadClient
|
7
|
+
attr_accessor :username, :password, :first_name, :last_name,
|
8
|
+
:billing_address, :billing_city, :billing_state,
|
9
|
+
:billing_zip, :id, :dob, :last4
|
10
|
+
attr_reader :raw_response, :response, :status, :message
|
11
|
+
|
12
|
+
STANDARD_URL = 'https://idresponse.com:6650/gateway.php'
|
13
|
+
OFAC_URL = 'https://ofac.idresponse.com:6650/gateway.php'
|
14
|
+
OUTPUT_TYPE = '4.3b'
|
15
|
+
|
16
|
+
@@url = 'https://idresponse.com:6650/gateway.php'
|
17
|
+
|
18
|
+
def initialize(username='', password='', info={})
|
19
|
+
@username = username
|
20
|
+
@password = password
|
21
|
+
@function = 'age'
|
22
|
+
self.populate(info) if info
|
23
|
+
end
|
24
|
+
|
25
|
+
def query
|
26
|
+
builder = Builder::XmlMarkup.new
|
27
|
+
builder.query do |q|
|
28
|
+
q.user @username
|
29
|
+
q.pass @password
|
30
|
+
q.function @function
|
31
|
+
q.tag! 'output-type', "#{VeratadClient::OUTPUT_TYPE}"
|
32
|
+
q.tag! 'client-side' do |cs|
|
33
|
+
cs.id @id
|
34
|
+
end
|
35
|
+
q.fn @first_name
|
36
|
+
q.ln @last_name
|
37
|
+
self.address_query(q, 'bill')
|
38
|
+
self.dob_query(q)
|
39
|
+
self.last4_query(q)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def address_query(query, type)
|
44
|
+
if self.send("#{type}ing_address".to_sym)
|
45
|
+
query.tag! type do |t|
|
46
|
+
t.addr self.send("#{type}ing_address".to_sym)
|
47
|
+
t.city self.send("#{type}ing_city".to_sym)
|
48
|
+
t.state self.send("#{type}ing_state".to_sym)
|
49
|
+
t.zip self.send("#{type}ing_zip".to_sym)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def dob_query(query)
|
55
|
+
if @dob
|
56
|
+
query.dob format('%0.4d%0.2d%0.2d', @dob.year, @dob.month, @dob.day)
|
57
|
+
query.tag! 'dob-type', 'YYYYMMDD'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def last4_query(query)
|
62
|
+
if @last4
|
63
|
+
query.last4 @last4
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def populate(info)
|
68
|
+
info.keys.each { |k| self.send("#{k.to_s}=".to_sym, info[k]) }
|
69
|
+
end
|
70
|
+
|
71
|
+
def verify!
|
72
|
+
@response = REXML::Document.new(self.run_verification.body).root.elements
|
73
|
+
@status = @response['status'].text.to_i
|
74
|
+
@message = @response['message'].text
|
75
|
+
|
76
|
+
@status === 0
|
77
|
+
end
|
78
|
+
|
79
|
+
def run_verification
|
80
|
+
@raw_response = self.http.request_post(url.path, self.query_string)
|
81
|
+
end
|
82
|
+
|
83
|
+
def query_string
|
84
|
+
"query=#{URI.escape(self.query)}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def http
|
88
|
+
Net::HTTP.start(self.url.host, self.url.port, :use_ssl => true)
|
89
|
+
end
|
90
|
+
|
91
|
+
def url
|
92
|
+
URI.parse(@@url)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.ofac?
|
96
|
+
@@url == OFAC_URL
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.standard?
|
100
|
+
@@url == STANDARD_URL
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.use_ofac!
|
104
|
+
@@url = OFAC_URL
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.use_standard!
|
108
|
+
@@url = STANDARD_URL
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: veratad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kenny Parnell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Ruby interface to the Veritad identity verification API
|
15
|
+
email: k.parnell@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/veratad.rb
|
21
|
+
homepage: https://github.com/kparnell/veratad
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.11
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Veratad
|
45
|
+
test_files: []
|