Class: DeltavistaCrifDvaInterface::SoapConverter
- Inherits:
-
Object
- Object
- DeltavistaCrifDvaInterface::SoapConverter
- Defined in:
- lib/deltavista_crif_dva_interface/soap_converter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#envelope ⇒ Object
readonly
Returns the value of attribute envelope.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #additional_input(key, value) ⇒ Object
- #commit(action) ⇒ Object
-
#convert_country(alpha3_code) ⇒ Object
Converts alpha-3 country code into alpha-2 country code.
- #format_date(date) ⇒ Object
-
#initialize(options) ⇒ SoapConverter
constructor
A new instance of SoapConverter.
- #insert_company_address(address) ⇒ Object
- #insert_identity ⇒ Object
- #insert_private_address(address) ⇒ Object
- #insert_reference_number ⇒ Object
- #parse_location(address) ⇒ Object
Constructor Details
#initialize(options) ⇒ SoapConverter
Returns a new instance of SoapConverter.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 8 def initialize() @options = @envelope = Hash.new @client = Savon.client( :wsdl => .wsdl, :endpoint => .endpoint, :soap_version => 2 ) @result = { :committed => false, :success => false, :data => Hash.new } @logger = .logger ? .logger : Logger.new(STDOUT) insert_identity insert_reference_number end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def client @client end |
#envelope ⇒ Object (readonly)
Returns the value of attribute envelope.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def envelope @envelope end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def @options end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def result @result end |
Instance Method Details
#additional_input(key, value) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 74 def additional_input(key, value) envelope[:additional_inputs] = Array.new unless envelope[:additional_inputs] envelope[:additional_inputs] << { :key => key, :value => value } end |
#commit(action) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 26 def commit(action) begin result[:data] = @client.call(action, envelope) result[:success] = true rescue result[:data] = Hash.new result[:success] = false ensure result[:committed] = true end result end |
#convert_country(alpha3_code) ⇒ Object
Converts alpha-3 country code into alpha-2 country code
83 84 85 86 87 88 89 90 91 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 83 def convert_country(alpha3_code) alpha2_code = '' begin alpha2_code = SunDawg::CountryIsoTranslater.translate_standard(alpha3_code, "alpha3", "alpha2") rescue SunDawg::CountryIsoTranslater::NoCountryError ensure alpha2_code end end |
#format_date(date) ⇒ Object
93 94 95 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 93 def format_date(date) (date.is_a? Time) ? date.strftime('%Y-%m-%d') : nil end |
#insert_company_address(address) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 64 def insert_company_address(address) envelope[:searched_address] = { :company_name => address[:company_name], :location => parse_location(address), :attributes! => { 'xsi:type' => 'CompanyAddressDescription' } } end |
#insert_identity ⇒ Object
43 44 45 46 47 48 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 43 def insert_identity envelope[:identity_descriptor] = { :user_name => .user_name, :password => .password } end |
#insert_private_address(address) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 50 def insert_private_address(address) envelope[:searched_address] = { :first_name => address[:first_name], :last_name => address[:last_name], :maiden_name => address[:maiden_name], :sex => address[:sex], :birth_date => format_date(address[:birth_date]), :location => parse_location(address), :attributes! => { 'xsi:type' => 'PersonAddressDescription' } } end |
#insert_reference_number ⇒ Object
39 40 41 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 39 def insert_reference_number envelope[:reference_number] = rand(3000) end |
#parse_location(address) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 97 def parse_location(address) { :street => address[:street], :house_number => address[:house_number], :zip => address[:zip], :city => address[:city], :country => address[:country] } end |