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
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#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 ⇒ 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_control ⇒ 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 25 26 27 |
# 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, :env_namespace => 'soapenv' ) @result = { :committed => false, :success => false, :data => Hash.new } @action = .action @logger = .logger ? .logger : Logger.new(STDOUT) insert_control insert_identity insert_reference_number end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 6 def action @action end |
#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
84 85 86 87 88 89 90 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 84 def additional_input(key, value) envelope[:additional_inputs] = Array.new unless envelope[:additional_inputs] envelope[:additional_inputs] << { :key => key, :value => value } end |
#commit ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 29 def commit # begin result[:data] = @client.call(action, :message => 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
93 94 95 96 97 98 99 100 101 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 93 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
103 104 105 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 103 def format_date(date) (date.is_a? Date) ? date.strftime('%Y-%m-%d') : nil end |
#insert_company_address(address) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 74 def insert_company_address(address) envelope[:searched_address] = { :company_name => address[:company_name], :location => parse_location(address), :attributes! => { 'xsi:type' => 'CompanyAddressDescription' } } end |
#insert_control ⇒ Object
53 54 55 56 57 58 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 53 def insert_control envelope[:control] = { :major_version => 1, :minor_version => 0 } end |
#insert_identity ⇒ Object
46 47 48 49 50 51 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 46 def insert_identity envelope[:identity_descriptor] = { :user_name => .user_name, :password => .password } end |
#insert_private_address(address) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 60 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
42 43 44 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 42 def insert_reference_number envelope[:reference_number] = rand(3000) end |
#parse_location(address) ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/deltavista_crif_dva_interface/soap_converter.rb', line 107 def parse_location(address) { :street => address[:street], :house_number => address[:house_number], :zip => address[:zip], :city => address[:city], :country => address[:country] } end |