deltavista_crif_dva_interface 0.0.12 → 0.0.13
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.
- data/lib/deltavista_crif_dva_interface.rb +1 -0
- data/lib/deltavista_crif_dva_interface/address_update.rb +39 -26
- data/lib/deltavista_crif_dva_interface/credit_check_short_v02.rb +1 -1
- data/lib/deltavista_crif_dva_interface/delta_vista_service.rb +3 -2
- data/lib/deltavista_crif_dva_interface/errors.rb +9 -0
- data/lib/deltavista_crif_dva_interface/restful_service.rb +2 -2
- data/lib/deltavista_crif_dva_interface/version.rb +1 -1
- data/lib/deltavista_crif_dva_interface/xml_converter.rb +13 -0
- metadata +3 -2
@@ -2,6 +2,7 @@ require "country_iso_translater"
|
|
2
2
|
|
3
3
|
require "deltavista_crif_dva_interface/version"
|
4
4
|
require "deltavista_crif_dva_interface/config"
|
5
|
+
require "deltavista_crif_dva_interface/errors"
|
5
6
|
require "deltavista_crif_dva_interface/restful_service"
|
6
7
|
require "deltavista_crif_dva_interface/delta_vista_service"
|
7
8
|
require "deltavista_crif_dva_interface/xml_converter"
|
@@ -1,27 +1,34 @@
|
|
1
1
|
module DeltavistaCrifDvaInterface
|
2
2
|
class AddressUpdate < XmlConverter
|
3
|
+
DEFAULT_OPTIONS = {
|
4
|
+
:encoding => 'UTF-8',
|
5
|
+
:request_type => 'AddressUpdate'
|
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
23
|
puts address.inspect
|
17
|
-
builder = Nokogiri::XML::Builder.new(:encoding =>
|
24
|
+
builder = Nokogiri::XML::Builder.new(:encoding => @config[:encoding]) do |xml|
|
18
25
|
xml.dvaCheckRequest {
|
19
26
|
xml.identity {
|
20
|
-
xml.username @username
|
21
|
-
xml.password @password
|
27
|
+
xml.username @config[:username]
|
28
|
+
xml.password @config[:password]
|
22
29
|
}
|
23
30
|
xml.reference @@reference_id
|
24
|
-
xml.requestType @request_type
|
31
|
+
xml.requestType @config[:request_type]
|
25
32
|
xml.private {
|
26
33
|
%w(title lastName firstName maidenName street house poBox zip city country phone birthDate sex).each do |key|
|
27
34
|
value = to_string(address[key.downcase])
|
@@ -35,52 +42,58 @@ module DeltavistaCrifDvaInterface
|
|
35
42
|
end
|
36
43
|
|
37
44
|
def to_hash(xml_body)
|
38
|
-
|
39
|
-
xml_doc = Nokogiri::XML(xml_body, @@encoding)
|
45
|
+
xml_doc = Nokogiri.XML(xml_body, nil, @config[:encoding])
|
40
46
|
if valid_response? xml_doc
|
41
|
-
# private tag
|
42
47
|
address = {}
|
48
|
+
metadata = {}
|
43
49
|
xml_doc.xpath("//private").each do |private_node|
|
44
|
-
%w(addressId birthDate sex).each do |key|
|
45
|
-
|
50
|
+
%w(addressId birthDate sex title lastName firstName maidenName street house poBox zip city country phone).each do |key|
|
51
|
+
if key == "country"
|
52
|
+
address[key.downcase.to_sym] = convert_country(get_value(private_node, key))
|
53
|
+
else
|
54
|
+
address[key.downcase.to_sym] = get_value(private_node, key)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
59
|
xml_doc.xpath("//private/payLoad/highestAddress/private").each do |private_node|
|
50
60
|
%w(title lastName firstName maidenName street house poBox zip city country phone).each do |key|
|
51
61
|
if key == "country"
|
52
|
-
address[key.downcase] = convert_country(get_value(private_node, key))
|
62
|
+
address[key.downcase.to_sym] = convert_country(get_value(private_node, key))
|
53
63
|
else
|
54
|
-
address[key.downcase] = get_value(private_node, key)
|
64
|
+
address[key.downcase.to_sym] = get_value(private_node, key)
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
59
69
|
xml_doc.xpath("//private/payLoad").each do |payload_node|
|
60
70
|
%w(matchLevel isDeceased dateOfDeath reqDeliverabilityClass higherDelivKnown).each do |key|
|
61
|
-
|
71
|
+
metadata[key.downcase.to_sym] = get_value(payload_node, key)
|
62
72
|
end
|
63
73
|
end
|
64
74
|
|
65
75
|
xml_doc.xpath("//private/payLoad/highestAddress").each do |highestaddress_node|
|
66
76
|
%w(deliverabilityClass).each do |key|
|
67
|
-
|
77
|
+
metadata[key.downcase.to_sym] = get_value(highestaddress_node, key)
|
68
78
|
end
|
69
79
|
end
|
70
80
|
|
71
|
-
address
|
81
|
+
[address, metadata]
|
72
82
|
else
|
73
|
-
|
74
|
-
nil
|
83
|
+
raise NotFoundError
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
78
|
-
def
|
79
|
-
xml
|
87
|
+
def match_level(xml)
|
88
|
+
get_value(xml, "//private/payLoad/matchLevel")
|
89
|
+
end
|
90
|
+
|
91
|
+
def higher_delivery_known(xml)
|
92
|
+
get_value(xml, "//private/payLoad/higherDelivKnown")
|
80
93
|
end
|
81
94
|
|
82
|
-
def
|
83
|
-
|
95
|
+
def newer_address_found?(xml)
|
96
|
+
higher_delivery_known(xml) != '0.0' ? true : false
|
84
97
|
end
|
85
98
|
end
|
86
99
|
end
|
@@ -40,7 +40,7 @@ module DeltavistaCrifDvaInterface
|
|
40
40
|
http.use_ssl = true
|
41
41
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
42
42
|
end
|
43
|
-
|
43
|
+
http
|
44
44
|
end
|
45
45
|
|
46
46
|
def check_response!(response)
|
@@ -48,7 +48,7 @@ module DeltavistaCrifDvaInterface
|
|
48
48
|
raise NotFoundError if response.class == Net::HTTPNotFound
|
49
49
|
raise ServiceNotAvailableError
|
50
50
|
end
|
51
|
-
|
51
|
+
response
|
52
52
|
end
|
53
53
|
|
54
54
|
def valid_response?(response)
|
@@ -16,6 +16,19 @@ module DeltavistaCrifDvaInterface
|
|
16
16
|
return value.to_s.strip
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
def response_code(xml)
|
21
|
+
get_value xml, "//response/responseCode"
|
22
|
+
end
|
23
|
+
|
24
|
+
def response_text(xml)
|
25
|
+
get_value xml, "//response/responseText"
|
26
|
+
end
|
27
|
+
|
28
|
+
def valid_response?(xml)
|
29
|
+
response_code(xml) == '0' ? true : false
|
30
|
+
end
|
31
|
+
|
19
32
|
# Returns the value of a XPATH expression
|
20
33
|
def get_value(node, key)
|
21
34
|
node.xpath(key).collect(&:text)[0]
|
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.13
|
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-27 00:00:00 +02:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/deltavista_crif_dva_interface/config.rb
|
64
64
|
- lib/deltavista_crif_dva_interface/credit_check_short_v02.rb
|
65
65
|
- lib/deltavista_crif_dva_interface/delta_vista_service.rb
|
66
|
+
- lib/deltavista_crif_dva_interface/errors.rb
|
66
67
|
- lib/deltavista_crif_dva_interface/restful_service.rb
|
67
68
|
- lib/deltavista_crif_dva_interface/version.rb
|
68
69
|
- lib/deltavista_crif_dva_interface/xml_converter.rb
|