Class: IccsSoap::GeoNumberService
- Inherits:
-
Object
- Object
- IccsSoap::GeoNumberService
- Defined in:
- lib/iccs-soap/geo_number_service.rb
Constant Summary collapse
- @@client =
Savon.client(:wsdl => IccsSoap::Config.geo_number_service.document_url, :endpoint => IccsSoap::Config.geo_number_service.endpoint_url, :namespace => IccsSoap::Config.geo_number_service.namespace_url, :log => $soap_log, :soap_header => %Q(<simpleAuth xmlns="http://xsoap.iccs.de/v1" username="#{IccsSoap::Config.security_service.user}" password="#{IccsSoap::Config.security_service.password}" />))
Class Method Summary collapse
- .activate_number(*params) ⇒ Object
- .allocate_numbers(*params) ⇒ Object
- .https_req(uri) ⇒ Object
- .quarantine_number(*params) ⇒ Object
- .return_number_to_block(*params) ⇒ Object
- .route_number(options) ⇒ Object
Class Method Details
.activate_number(*params) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/iccs-soap/geo_number_service.rb', line 27 def activate_number(*params) params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to? response = @@client.call(:activate_number, :message => { :beginning => params[:beginning], :ending => params[:ending] || params[:beginning] }) response.body[:activate_number_response][:number] rescue Savon::SOAPFault => e $soap_log.error("soap error in activate_number(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}") raise end |
.allocate_numbers(*params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/iccs-soap/geo_number_service.rb', line 12 def allocate_numbers(*params) params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to? response = @@client.call(:allocate_numbers, :message => { :amount => "1", :ndc => params[:ndc], :foreign_nr => params[:foreign_nr] || params[:external_id], :customer_nr => params[:customer_nr], :assignmentRule => "GEO_SINGLE_10_11" }) response.body[:allocate_numbers_response][:numbers][:number] rescue Savon::SOAPFault => e $soap_log.error("soap error in allocate_numbers(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}") raise end |
.https_req(uri) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/iccs-soap/geo_number_service.rb', line 74 def https_req(uri) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) https.request(request) end |
.quarantine_number(*params) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/iccs-soap/geo_number_service.rb', line 39 def quarantine_number(*params) params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to? response = @@client.call(:quarantine_number, :message => { :beginning => params[:beginning], :ending => params[:ending] || params[:beginning] }) response.body[:quarantine_number_response] rescue Savon::SOAPFault => e $soap_log.error("soap error in quarantine_number(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}") raise end |
.return_number_to_block(*params) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/iccs-soap/geo_number_service.rb', line 51 def return_number_to_block(*params) params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to? response = @@client.call(:return_number_to_block, :message => { :beginning => params[:beginning], :ending => params[:ending] || params[:beginning] }) response.body[:return_number_to_block_response] rescue Savon::SOAPFault => e $soap_log.error("soap error in return_number_to_block(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}") raise end |
.route_number(options) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/iccs-soap/geo_number_service.rb', line 63 def route_number() remote_call = "route_number" base_url = "https://intern.dns-net.de/cgi-bin/iccs/" remote_call_param = "&#{remote_call}=#{remote_call}".gsub(/_/, '+') uri = URI.parse("#{base_url}/#{remote_call}.pl?iccs_login=bbtel&iccs_password=Dieu87s3&" + .keys.map {|option| URI.encode("#{option}=#{[option]}").gsub(/&/, '%26').gsub(/\?/, '%3F')}.join('&') + remote_call_param) response = https_req(uri) raise Error, "uri: \"#{uri}\" response: \"#{response.body}\"" if response.body.match(/FAULT/) return true #or: OpenStruct.new({:uri => uri, :response => response}) end |