deltavista_crif_dva_interface 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,33 @@
|
|
1
1
|
module DeltavistaCrifDvaInterface
|
2
2
|
class CreditCheckShortV02 < XmlConverter
|
3
|
+
DEFAULT_OPTIONS = {
|
4
|
+
:encoding => 'UTF-8',
|
5
|
+
:request_type => 'CreditCheckShort'
|
6
|
+
}.freeze
|
3
7
|
|
4
|
-
# XML request and response encoding
|
5
|
-
@@encoding = 'UTF-8'
|
6
8
|
# unique id for each request
|
7
9
|
@@reference_id = 1000
|
8
10
|
|
9
|
-
def initialize
|
10
|
-
@
|
11
|
-
|
12
|
-
|
11
|
+
def initialize options
|
12
|
+
@config = {}
|
13
|
+
if options.is_a? Hash
|
14
|
+
@config = DEFAULT_OPTIONS.merge(options)
|
15
|
+
else
|
16
|
+
@config[:username] = options.username
|
17
|
+
@config[:password] = options.password
|
18
|
+
@config = DEFAULT_OPTIONS.merge(@config)
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
22
|
def to_xml(address)
|
16
|
-
|
17
|
-
builder = Nokogiri::XML::Builder.new(:encoding => @@encoding) do |xml|
|
23
|
+
builder = Nokogiri::XML::Builder.new(:encoding => @config[:encoding]) do |xml|
|
18
24
|
xml.dvaCheckRequest {
|
19
25
|
xml.identity {
|
20
|
-
xml.username @username
|
21
|
-
xml.password @password
|
26
|
+
xml.username @config[:username]
|
27
|
+
xml.password @config[:password]
|
22
28
|
}
|
23
29
|
xml.reference @@reference_id
|
24
|
-
xml.requestType @request_type
|
30
|
+
xml.requestType @config[:request_type]
|
25
31
|
xml.private {
|
26
32
|
%w(title lastName firstName maidenName street house poBox zip city country phone birthDate sex).each do |key|
|
27
33
|
xml.send(key, address[key.downcase]) if address[key.downcase] && !address[key.downcase].empty?
|
@@ -34,39 +40,29 @@ module DeltavistaCrifDvaInterface
|
|
34
40
|
end
|
35
41
|
|
36
42
|
def to_hash(xml_body)
|
37
|
-
|
38
|
-
xml_doc = Nokogiri.XML(xml_body, nil, @@encoding)
|
43
|
+
xml_doc = Nokogiri.XML(xml_body, nil, @config[:encoding])
|
39
44
|
if valid_response? xml_doc
|
40
45
|
# private tag
|
41
46
|
address = {}
|
42
|
-
xml_doc.xpath("//private").each do |private_node|
|
43
|
-
%w(addressId title lastName firstName maidenName street house poBox zip city country phone birthDate sex
|
47
|
+
xml_doc.xpath("//dvaCheckResponse/private").each do |private_node|
|
48
|
+
%w(addressId title lastName firstName maidenName street house poBox zip city country phone birthDate sex).each do |key|
|
44
49
|
if key == "country"
|
45
|
-
address[key.downcase] = convert_country(private_node
|
50
|
+
address[key.downcase.to_sym] = convert_country get_value(private_node, key)
|
46
51
|
else
|
47
|
-
address[key.downcase] = private_node
|
52
|
+
address[key.downcase.to_sym] = get_value(private_node, key)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
51
|
-
xml_doc.xpath("//payLoad").each do |payload_node|
|
56
|
+
xml_doc.xpath("//dvaCheckResponse/private/payLoad").each do |payload_node|
|
52
57
|
%w(personStatus score decision hasDebt decisionComment).each do |key|
|
53
|
-
address[key.downcase] = payload_node
|
58
|
+
address[key.downcase.to_sym] = get_value(payload_node, key)
|
54
59
|
end
|
55
60
|
end
|
56
61
|
address
|
57
62
|
else
|
58
|
-
|
59
|
-
nil
|
63
|
+
raise NotFoundError.new response_code(xml_doc), response_text(xml_doc)
|
60
64
|
end
|
61
65
|
end
|
62
|
-
|
63
|
-
def response_code(xml)
|
64
|
-
xml.xpath("//response/responseCode").collect(&:text)[0]
|
65
|
-
end
|
66
|
-
|
67
|
-
def valid_response?(xml)
|
68
|
-
response_code(xml) == '0' ? true : false
|
69
|
-
end
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: deltavista_crif_dva_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marc Cadalbert
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-03-
|
14
|
+
date: 2012-03-28 00:00:00 +02:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|