deltavista_crif_dva_interface 0.0.9 → 0.0.10
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 -4
- data/lib/deltavista_crif_dva_interface/address_update.rb +9 -14
- data/lib/deltavista_crif_dva_interface/credit_check_short_v02.rb +1 -7
- data/lib/deltavista_crif_dva_interface/version.rb +1 -1
- data/lib/deltavista_crif_dva_interface/xml_converter.rb +29 -0
- metadata +7 -4
@@ -4,9 +4,6 @@ require "deltavista_crif_dva_interface/version"
|
|
4
4
|
require "deltavista_crif_dva_interface/config"
|
5
5
|
require "deltavista_crif_dva_interface/restful_service"
|
6
6
|
require "deltavista_crif_dva_interface/delta_vista_service"
|
7
|
+
require "deltavista_crif_dva_interface/xml_converter"
|
7
8
|
require "deltavista_crif_dva_interface/credit_check_short_v02"
|
8
9
|
require "deltavista_crif_dva_interface/address_update"
|
9
|
-
|
10
|
-
module DeltavistaCrifDvaInterface
|
11
|
-
# Your code goes here...
|
12
|
-
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module DeltavistaCrifDvaInterface
|
2
|
-
class AddressUpdate
|
2
|
+
class AddressUpdate < XmlConverter
|
3
3
|
|
4
4
|
# XML request and response encoding
|
5
5
|
@@encoding = 'UTF-8'
|
@@ -13,7 +13,6 @@ module DeltavistaCrifDvaInterface
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_xml(address)
|
16
|
-
puts address.inspect
|
17
16
|
builder = Nokogiri::XML::Builder.new(:encoding => @@encoding) do |xml|
|
18
17
|
xml.dvaCheckRequest {
|
19
18
|
xml.identity {
|
@@ -24,7 +23,8 @@ module DeltavistaCrifDvaInterface
|
|
24
23
|
xml.requestType @request_type
|
25
24
|
xml.private {
|
26
25
|
%w(title lastName firstName maidenName street house poBox zip city country phone birthDate sex).each do |key|
|
27
|
-
|
26
|
+
value = to_string(address[key.downcase])
|
27
|
+
xml.send(key, value) if value && !value.empty?
|
28
28
|
end
|
29
29
|
}
|
30
30
|
}
|
@@ -34,7 +34,6 @@ module DeltavistaCrifDvaInterface
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def to_hash(xml_body)
|
37
|
-
puts xml_body
|
38
37
|
xml_doc = Nokogiri::XML(xml_body, @@encoding)
|
39
38
|
if valid_response? xml_doc
|
40
39
|
# private tag
|
@@ -42,20 +41,22 @@ module DeltavistaCrifDvaInterface
|
|
42
41
|
xml_doc.xpath("//private").each do |private_node|
|
43
42
|
%w(addressId title lastName firstName maidenName street house poBox zip city country phone birthDate sex).each do |key|
|
44
43
|
if key == "country"
|
45
|
-
address[key.downcase] = convert_country(private_node
|
44
|
+
address[key.downcase] = convert_country(get_value(private_node, key))
|
46
45
|
else
|
47
|
-
address[key.downcase] = private_node
|
46
|
+
address[key.downcase] = get_value(private_node, key)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
50
|
+
|
51
51
|
xml_doc.xpath("//private/payLoad").each do |payload_node|
|
52
52
|
%w(matchLevel isDeceased dateOfDeath reqDeliverabilityClass higherDelivKnown).each do |key|
|
53
|
-
address[key.downcase] = payload_node
|
53
|
+
address[key.downcase] = get_value(payload_node, key)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
56
57
|
xml_doc.xpath("//private/payLoad/highestAddress").each do |highestaddress_node|
|
57
58
|
%w(deliverabilityClass).each do |key|
|
58
|
-
address[key.downcase] = highestaddress_node
|
59
|
+
address[key.downcase] = get_value(highestaddress_node, key)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
address
|
@@ -72,12 +73,6 @@ module DeltavistaCrifDvaInterface
|
|
72
73
|
def valid_response?(xml)
|
73
74
|
response_code(xml) == '0' ? true : false
|
74
75
|
end
|
75
|
-
|
76
|
-
def convert_country(alpha3_code)
|
77
|
-
SunDawg::CountryIsoTranslater.translate_standard(alpha3_code, "alpha3", "alpha2")
|
78
|
-
end
|
79
|
-
|
80
76
|
end
|
81
|
-
|
82
77
|
end
|
83
78
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module DeltavistaCrifDvaInterface
|
2
|
-
class CreditCheckShortV02
|
2
|
+
class CreditCheckShortV02 < XmlConverter
|
3
3
|
|
4
4
|
# XML request and response encoding
|
5
5
|
@@encoding = 'UTF-8'
|
@@ -67,12 +67,6 @@ module DeltavistaCrifDvaInterface
|
|
67
67
|
def valid_response?(xml)
|
68
68
|
response_code(xml) == '0' ? true : false
|
69
69
|
end
|
70
|
-
|
71
|
-
def convert_country(alpha3_code)
|
72
|
-
SunDawg::CountryIsoTranslater.translate_standard(alpha3_code, "alpha3", "alpha2")
|
73
|
-
end
|
74
|
-
|
75
70
|
end
|
76
|
-
|
77
71
|
end
|
78
72
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module DeltavistaCrifDvaInterface
|
2
|
+
class XmlConverter
|
3
|
+
|
4
|
+
def to_xml(object)
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_hash(xml_doc)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_string(value)
|
13
|
+
if value.is_a? Time
|
14
|
+
return value.strftime("%d.%m.%Y")
|
15
|
+
else
|
16
|
+
return value.to_s.strip
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Returns the value of a XPATH expression
|
20
|
+
def get_value(node, key)
|
21
|
+
node.xpath(key).collect(&:text)[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Converts alpha-3 country code into alpha-2 country code
|
25
|
+
def convert_country(alpha3_code)
|
26
|
+
SunDawg::CountryIsoTranslater.translate_standard(alpha3_code, "alpha3", "alpha2")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -2,15 +2,16 @@
|
|
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.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marc Cadalbert
|
9
|
+
- Maik Duff
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date: 2012-03-
|
14
|
+
date: 2012-03-26 00:00:00 +02:00
|
14
15
|
default_executable:
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
@@ -46,9 +47,10 @@ dependencies:
|
|
46
47
|
version: "0"
|
47
48
|
type: :runtime
|
48
49
|
version_requirements: *id003
|
49
|
-
description:
|
50
|
+
description: This interface is used to get credit check and address informations from Deltavista service.
|
50
51
|
email:
|
51
52
|
- mc@impac.ch
|
53
|
+
- md@impac.ch
|
52
54
|
executables: []
|
53
55
|
|
54
56
|
extensions: []
|
@@ -63,6 +65,7 @@ files:
|
|
63
65
|
- lib/deltavista_crif_dva_interface/delta_vista_service.rb
|
64
66
|
- lib/deltavista_crif_dva_interface/restful_service.rb
|
65
67
|
- lib/deltavista_crif_dva_interface/version.rb
|
68
|
+
- lib/deltavista_crif_dva_interface/xml_converter.rb
|
66
69
|
has_rdoc: true
|
67
70
|
homepage: ""
|
68
71
|
licenses: []
|
@@ -90,6 +93,6 @@ rubyforge_project: deltavista_crif_dva_interface
|
|
90
93
|
rubygems_version: 1.5.1
|
91
94
|
signing_key:
|
92
95
|
specification_version: 3
|
93
|
-
summary:
|
96
|
+
summary: Interface to connect services from Deltavsita
|
94
97
|
test_files: []
|
95
98
|
|