Class: VeratadClient
- Inherits:
-
Object
- Object
- VeratadClient
- Defined in:
- lib/veratad.rb
Constant Summary collapse
- STANDARD_URL =
'https://idresponse.com:6650/gateway.php'- OFAC_URL =
'https://ofac.idresponse.com:6650/gateway.php'- OUTPUT_TYPE =
'4.3b'- @@url =
'https://idresponse.com:6650/gateway.php'
Instance Attribute Summary collapse
-
#billing_address ⇒ Object
Returns the value of attribute billing_address.
-
#billing_city ⇒ Object
Returns the value of attribute billing_city.
-
#billing_state ⇒ Object
Returns the value of attribute billing_state.
-
#billing_zip ⇒ Object
Returns the value of attribute billing_zip.
-
#dob ⇒ Object
Returns the value of attribute dob.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last4 ⇒ Object
Returns the value of attribute last4.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#password ⇒ Object
Returns the value of attribute password.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #address_query(query, type) ⇒ Object
- #dob_query(query) ⇒ Object
- #http ⇒ Object
-
#initialize(username = '', password = '', info = {}) ⇒ VeratadClient
constructor
A new instance of VeratadClient.
- #last4_query(query) ⇒ Object
- #populate(info) ⇒ Object
- #query ⇒ Object
- #query_string ⇒ Object
- #run_verification ⇒ Object
- #url ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(username = '', password = '', info = {}) ⇒ VeratadClient
18 19 20 21 22 23 |
# File 'lib/veratad.rb', line 18 def initialize(username='', password='', info={}) @username = username @password = password @function = 'age' self.populate(info) if info end |
Instance Attribute Details
#billing_address ⇒ Object
Returns the value of attribute billing_address.
7 8 9 |
# File 'lib/veratad.rb', line 7 def billing_address @billing_address end |
#billing_city ⇒ Object
Returns the value of attribute billing_city.
7 8 9 |
# File 'lib/veratad.rb', line 7 def billing_city @billing_city end |
#billing_state ⇒ Object
Returns the value of attribute billing_state.
7 8 9 |
# File 'lib/veratad.rb', line 7 def billing_state @billing_state end |
#billing_zip ⇒ Object
Returns the value of attribute billing_zip.
7 8 9 |
# File 'lib/veratad.rb', line 7 def billing_zip @billing_zip end |
#dob ⇒ Object
Returns the value of attribute dob.
7 8 9 |
# File 'lib/veratad.rb', line 7 def dob @dob end |
#first_name ⇒ Object
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/veratad.rb', line 7 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/veratad.rb', line 7 def id @id end |
#last4 ⇒ Object
Returns the value of attribute last4.
7 8 9 |
# File 'lib/veratad.rb', line 7 def last4 @last4 end |
#last_name ⇒ Object
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/veratad.rb', line 7 def last_name @last_name end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/veratad.rb', line 10 def end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/veratad.rb', line 7 def password @password end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
10 11 12 |
# File 'lib/veratad.rb', line 10 def raw_response @raw_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/veratad.rb', line 10 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/veratad.rb', line 10 def status @status end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/veratad.rb', line 7 def username @username end |
Class Method Details
.ofac? ⇒ Boolean
93 94 95 |
# File 'lib/veratad.rb', line 93 def self.ofac? @@url == OFAC_URL end |
.standard? ⇒ Boolean
97 98 99 |
# File 'lib/veratad.rb', line 97 def self.standard? @@url == STANDARD_URL end |
.use_ofac! ⇒ Object
101 102 103 |
# File 'lib/veratad.rb', line 101 def self.use_ofac! @@url = OFAC_URL end |
.use_standard! ⇒ Object
105 106 107 |
# File 'lib/veratad.rb', line 105 def self.use_standard! @@url = STANDARD_URL end |
Instance Method Details
#address_query(query, type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/veratad.rb', line 43 def address_query(query, type) if self.send("#{type}ing_address".to_sym) query.tag! type do |t| t.addr self.send("#{type}ing_address".to_sym) t.city self.send("#{type}ing_city".to_sym) t.state self.send("#{type}ing_state".to_sym) t.zip self.send("#{type}ing_zip".to_sym) end end end |
#dob_query(query) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/veratad.rb', line 54 def dob_query(query) if @dob query.dob format('%0.4d%0.2d%0.2d', @dob.year, @dob.month, @dob.day) query.tag! 'dob-type', 'YYYYMMDD' end end |
#http ⇒ Object
85 86 87 |
# File 'lib/veratad.rb', line 85 def http Net::HTTP.start(self.url.host, self.url.port, :use_ssl => true) end |
#last4_query(query) ⇒ Object
61 62 63 |
# File 'lib/veratad.rb', line 61 def last4_query(query) query.last4 @last4 if @last4 end |
#populate(info) ⇒ Object
65 66 67 |
# File 'lib/veratad.rb', line 65 def populate(info) info.keys.each { |k| self.send("#{k.to_s}=".to_sym, info[k]) } end |
#query ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/veratad.rb', line 25 def query builder = Builder::XmlMarkup.new builder.query do |q| q.user @username q.pass @password q.function @function q.tag! 'output-type', "#{VeratadClient::OUTPUT_TYPE}" q.tag! 'client-side' do |cs| cs.id @id end q.fn @first_name q.ln @last_name self.address_query(q, 'bill') self.dob_query(q) self.last4_query(q) end end |
#query_string ⇒ Object
81 82 83 |
# File 'lib/veratad.rb', line 81 def query_string "query=#{URI.escape(self.query)}" end |
#run_verification ⇒ Object
77 78 79 |
# File 'lib/veratad.rb', line 77 def run_verification @raw_response = self.http.request_post(url.path, self.query_string) end |
#url ⇒ Object
89 90 91 |
# File 'lib/veratad.rb', line 89 def url URI.parse(@@url) end |
#verify! ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/veratad.rb', line 69 def verify! @response = REXML::Document.new(self.run_verification.body).root.elements @status = @response['status'].text.to_i = @response['message'].text @status === 0 end |