deltavista_crif_dva_interface 0.1.27 → 0.2.00

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.
@@ -3,21 +3,26 @@ module DeltavistaCrifDvaInterface
3
3
 
4
4
  def initialize(options)
5
5
  options.action = :get_report
6
+ options.response = :get_report_response
6
7
  super(options)
7
8
  end
8
9
 
9
10
  def private_collection_check(address, collection)
10
11
  insert_private_address address
11
12
  envelope[:report_type] = 'COLLECTION_CHECK_CONSUMER'
13
+ envelope[:target_report_format] = 'NONE'
12
14
  insert_collection collection
13
15
  commit
16
+ result[:data]
14
17
  end
15
18
 
16
19
  def business_collection_check(address, collection)
17
20
  insert_company_address address
18
21
  envelope[:report_type] = 'COLLECTION_CHECK_BUSINESS'
22
+ envelope[:target_report_format] = 'NONE'
19
23
  insert_collection collection
20
24
  commit
25
+ result[:data]
21
26
  end
22
27
 
23
28
  private
@@ -32,7 +32,7 @@ module DeltavistaCrifDvaInterface
32
32
  if language == 'de'
33
33
  [
34
34
  ['Unbekannt', 0],
35
- ['Männlich', 1],
35
+ ['Männlich', 1],
36
36
  ['Weiblich', 2]
37
37
  ]
38
38
  end
@@ -1,15 +1,17 @@
1
1
  module DeltavistaCrifDvaInterface
2
2
  class SoapConfig
3
- attr_accessor :endpoint, :wsdl, :user_name, :password, :action, :logger
3
+ attr_accessor :endpoint, :wsdl, :user_name, :password, :action, :response, :logger
4
4
 
5
5
  def initialize(options)
6
6
  default_endpoint = 'https://preprodservices.crif-online.ch/CrifSS/CrifSoapServiceV1'
7
7
  default_wsdl = File.expand_path('../../wsdl/crif-soap-service_v1.0.wsdl', File.dirname(__FILE__))
8
+
8
9
  @endpoint = options[:endpoint] ? options[:endpoint] : default_endpoint
9
10
  @wsdl = options[:wsdl] ? options[:wsdl] : default_wsdl
10
11
  @user_name = options[:user_name]
11
12
  @password = options[:password]
12
- @action = options[:action] ? options[:action] : ''
13
+ @action = options[:action] ? options[:action] : nil
14
+ @response = options[:response] ? options[:response] : nil
13
15
  @logger = options[:logger] ? options[:logger] : Logger.new(STDOUT)
14
16
  end
15
17
 
@@ -3,27 +3,33 @@ require 'savon'
3
3
  module DeltavistaCrifDvaInterface
4
4
  class SoapConverter
5
5
 
6
- attr_reader :options, :client, :action, :envelope, :result, :logger
6
+ attr_reader :options, :client, :action, :response, :attributes, :envelope, :result, :logger
7
7
 
8
8
  def initialize(options)
9
9
  @options = options
10
10
  @logger = options.logger ? options.logger : Logger.new(STDOUT)
11
- @envelope = Hash.new
11
+ @envelope = {
12
+ :attributes! => Hash.new
13
+ }
14
+ @attributes = Hash.new
12
15
  @client = Savon.client(
13
16
  :wsdl => options.wsdl,
14
17
  :endpoint => options.endpoint,
15
- :pretty_print_xml => true,
16
18
  :soap_version => 2,
17
19
  :env_namespace => 'soapenv',
20
+ :pretty_print_xml => true,
18
21
  :namespace_identifier => 'ns1',
22
+ :element_form_default => :qualified,
19
23
  :logger => logger
20
24
  )
21
25
  @result = {
22
26
  :committed => false,
23
27
  :success => false,
28
+ :response => nil,
24
29
  :data => Hash.new
25
30
  }
26
31
  @action = options.action
32
+ @response = options.response
27
33
  insert_control
28
34
  insert_identity
29
35
  insert_reference_number
@@ -31,14 +37,14 @@ module DeltavistaCrifDvaInterface
31
37
 
32
38
  def commit
33
39
  begin
34
- result[:data] = @client.call(action, :message => envelope)
40
+ result[:response] = @client.call(action, :message => envelope, :attributes => attributes)
41
+ result[:data] = result[:response].body[options.response]
35
42
  result[:success] = true
36
43
  rescue StandardError => e
37
44
  logger.error e.message
38
45
  logger.error e.backtrace.join('\n') if e.backtrace
39
46
  raise e
40
47
  end
41
- result
42
48
  end
43
49
 
44
50
  def insert_reference_number
@@ -66,27 +72,26 @@ module DeltavistaCrifDvaInterface
66
72
  :last_name => address[:last_name],
67
73
  :maiden_name => address[:maiden_name],
68
74
  :sex => address[:sex],
69
- :birth_date => format_date(address[:birth_date]),
70
- :attributes! => {
71
- 'xsi:type' => 'PersonAddressDescription'
72
- }
75
+ :birth_date => format_date(address[:birth_date])
73
76
  }
77
+ map_attribute({
78
+ 'xsi:type' => 'ns1:PersonAddressDescription'
79
+ }, :searched_address)
74
80
  end
75
81
 
76
82
  def insert_company_address(address)
77
83
  envelope[:searched_address] = {
78
84
  :location => parse_location(address),
79
- :company_name => address[:company_name],
80
- :attributes! => {
81
- 'xsi:type' => 'CompanyAddressDescription'
82
- }
85
+ :company_name => address[:company_name]
83
86
  }
87
+ map_attribute({
88
+ 'xsi:type' => 'ns1:CompanyAddressDescription'
89
+ }, :searched_address)
84
90
  end
85
91
 
86
92
  def additional_input(key, value)
87
- envelope[:additional_inputs] = Hash.new unless envelope[:additional_inputs]
88
- envelope[:additional_inputs][:additional_input] = Array.new unless envelope[:additional_inputs][:additional_input]
89
- envelope[:additional_inputs][:additional_input] << {
93
+ envelope[:additional_input] = Array.new unless envelope[:additional_input]
94
+ envelope[:additional_input] << {
90
95
  :key => key,
91
96
  :value => value
92
97
  }
@@ -117,5 +122,16 @@ module DeltavistaCrifDvaInterface
117
122
  }
118
123
  end
119
124
 
125
+ def map_attribute(hash, *path)
126
+ target = envelope
127
+ last_child = path.slice!(-1)
128
+ path.each do |children|
129
+ target[children] = Hash.new unless target[children]
130
+ target = target[children]
131
+ end
132
+ target[:attributes!] = Hash.new unless target[:attributes!]
133
+ target[:attributes!][last_child] = hash
134
+ end
135
+
120
136
  end
121
137
  end
@@ -1,3 +1,3 @@
1
1
  module DeltavistaCrifDvaInterface
2
- VERSION = '0.1.27'
2
+ VERSION = '0.2.00'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.crif-online.ch/webservices/crifsoapservice/wsdl/v1.00" xmlns:crifss10="http://www.crif-online.ch/webservices/crifsoapservice/v1.00" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CrifSoapServiceV1_0" targetNamespace="http://www.crif-online.ch/webservices/crifsoapservice/wsdl/v1.00">
2
+ <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.crif-online.ch/webservices/crifsoapservice/v1.00" xmlns:crifss10="http://www.crif-online.ch/webservices/crifsoapservice/v1.00" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CrifSoapServiceV1_0" targetNamespace="http://www.crif-online.ch/webservices/crifsoapservice/v1.00">
3
3
  <documentation>Crif Soap Service V1.0</documentation>
4
4
  <types>
5
5
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deltavista_crif_dva_interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.2.00
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-05-21 00:00:00.000000000 Z
14
+ date: 2013-05-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec