Class: DeltavistaCrifDvaInterface::DeltaVistaService
- Inherits:
-
RestfulService
- Object
- RestfulService
- DeltavistaCrifDvaInterface::DeltaVistaService
- Defined in:
- lib/deltavista_crif_dva_interface/delta_vista_service.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.genders(language = 'de') ⇒ Array
All available genders for deltavista check.
-
.legal_forms(language = 'de') ⇒ Array
All available legal forms for deltavista check.
Instance Method Summary collapse
-
#collection_check(address, collection) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface.
-
#credit_check(address) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface.
-
#extract_response(xml_body) ⇒ Struct
XML Body converted to hash.
-
#initialize(config) ⇒ DeltaVistaService
constructor
A new instance of DeltaVistaService.
-
#verify_address(address) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface.
Methods inherited from RestfulService
#check_response!, #create_http_request, #get_http_response, #post_http_request, #put_http_request, #to_url, #valid_response?
Constructor Details
#initialize(config) ⇒ DeltaVistaService
7 8 9 10 11 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 7 def initialize(config) @url = config.deltavista_service_url @logger = config.logger || Logger.new(STDOUT) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 5 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 5 def logger @logger end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 5 def url @url end |
Class Method Details
.genders(language = 'de') ⇒ Array
26 27 28 29 30 31 32 33 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 26 def self.genders(language = 'de') I18n.load_path += Dir["#{File.dirname(__FILE__)}/../../config/*.yml"] I18n.backend.load_translations I18n.locale = language.to_sym [0, 1, 2].map do |key| [I18n.t("gender.#{key}"), key] end end |
.legal_forms(language = 'de') ⇒ Array
15 16 17 18 19 20 21 22 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 15 def self.legal_forms(language = 'de') I18n.load_path += Dir["#{File.dirname(__FILE__)}/../../config/*.yml"] I18n.backend.load_translations I18n.locale = language.to_sym [2, 3, 4, 5, 6, 7, 8, 9, 99].map do |key| [I18n.t("legal_form.#{key}"), key] end end |
Instance Method Details
#collection_check(address, collection) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface. The XML-Response will be converted back into an address object and returned. If no address is available the method returns nil.
If the Service is not available a StandardError will be thrown.
79 80 81 82 83 84 85 86 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 79 def collection_check(address, collection) @parser = CollectionCheck.new @config request_body = @parser.to_xml(address, collection) headers = {'Content-Type' => 'text/xml'} post_http_request(url, request_body, headers) do |data| extract_response data end end |
#credit_check(address) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface. The XML-Response will be converted back into an address object and returned. If no address is available the method returns nil.
If the Service is not available a StandardError will be thrown.
42 43 44 45 46 47 48 49 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 42 def credit_check(address) @parser = CreditCheckShortV02.new @config request_body = @parser.to_xml(address) headers = {'Content-Type' => 'text/xml'} post_http_request(url, request_body, headers) do |data| extract_response data end end |
#extract_response(xml_body) ⇒ Struct
90 91 92 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 90 def extract_response(xml_body) @parser.to_hash(xml_body) end |
#verify_address(address) ⇒ Struct
Takes an address object and sends it as XML to the DeltaVista-Interface. The XML-Response will be converted back into an address object and returned. If no address is available the method returns nil.
If the Service is not available a StandardError will be thrown.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/deltavista_crif_dva_interface/delta_vista_service.rb', line 59 def verify_address(address) @parser = AddressUpdate.new @config request_body = @parser.to_xml(address) logger.debug request_body.inspect headers = {'Content-Type' => 'text/xml'} post_http_request(url, request_body, headers) do |data| logger.debug data.inspect extract_response data end end |