iccs-soap 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +13 -0
- data/Gemfile +3 -0
- data/README.md +0 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/iccs-soap.gemspec +25 -0
- data/lib/iccs-soap.rb +135 -0
- data/lib/iccs-soap/customer_service.rb +122 -0
- data/lib/iccs-soap/de_te_me_service.rb +4 -0
- data/lib/iccs-soap/geo_block_service.rb +4 -0
- data/lib/iccs-soap/geo_number_service.rb +83 -0
- data/lib/iccs-soap/mobile_number_service.rb +4 -0
- data/lib/iccs-soap/number_transfer_service.rb +26 -0
- data/lib/iccs-soap/security_service.rb +32 -0
- data/lib/iccs-soap/service_number_service.rb +4 -0
- data/spec/functional/config_spec.rb +20 -0
- data/spec/functional/customer_service_spec.rb +4 -0
- data/spec/functional/de_te_me_service_spec.rb +4 -0
- data/spec/functional/geo_block_service_spec.rb +4 -0
- data/spec/functional/geo_number_service_spec.rb +4 -0
- data/spec/functional/mobile_number_service_spec.rb +4 -0
- data/spec/functional/number_transfer_service_spec.rb +4 -0
- data/spec/functional/security_service_spec.rb +19 -0
- data/spec/functional/service_number_service_spec.rb +4 -0
- data/spec/spec_helper.rb +11 -0
- metadata +214 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rdoc/task'
|
6
|
+
require 'sdoc'
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
11
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
12
|
+
end
|
13
|
+
|
14
|
+
Rake::RDocTask.new do |rdoc|
|
15
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
16
|
+
rdoc.options << '--fmt' << 'shtml'
|
17
|
+
rdoc.template = 'direct'
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :version do
|
21
|
+
namespace :bump do
|
22
|
+
desc 'Increase the major number and set the others to zero'
|
23
|
+
task :major do
|
24
|
+
major, minor, patch = load_version
|
25
|
+
store_version(major + 1, 0, 0)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Increase the minor number and set patch to zero'
|
29
|
+
task :minor do
|
30
|
+
major, minor, patch = load_version
|
31
|
+
store_version(major, minor + 1, 0)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Increase the patch level'
|
35
|
+
task :patch do
|
36
|
+
major, minor, patch = load_version
|
37
|
+
store_version(major, minor, patch + 1)
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_version
|
41
|
+
File.read(File.join(File.dirname(__FILE__), 'VERSION')).split('.').map(&:to_i)
|
42
|
+
end
|
43
|
+
|
44
|
+
def store_version(major, minor, patch)
|
45
|
+
version = "#{major}.#{minor}.#{patch}"
|
46
|
+
f= File.new(File.join(File.dirname(__FILE__), 'VERSION'), File::WRONLY)
|
47
|
+
f.write(version)
|
48
|
+
f.close
|
49
|
+
puts "version is now #{version}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.14
|
data/iccs-soap.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "iccs-soap"
|
4
|
+
s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
|
5
|
+
s.authors = ["Sascha Teske"]
|
6
|
+
s.email = %q{sascha.teske@gmail.com}
|
7
|
+
s.homepage = %q{http://github.com/slaxor/iccs-soap}
|
8
|
+
s.summary = %q{Wrapper for iccs soap api.}
|
9
|
+
s.description = %q{iccs-soap.}
|
10
|
+
|
11
|
+
s.add_dependency 'savon'
|
12
|
+
s.add_dependency 'redis'
|
13
|
+
s.add_dependency 'term-ansicolor' #for customlogging
|
14
|
+
s.add_development_dependency 'rake'
|
15
|
+
s.add_development_dependency 'sdoc'
|
16
|
+
s.add_development_dependency 'rspec'
|
17
|
+
s.add_development_dependency 'rr'
|
18
|
+
s.add_development_dependency 'shoulda'
|
19
|
+
s.add_development_dependency 'debugger'
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
data/lib/iccs-soap.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'savon'
|
3
|
+
require 'redis'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'logger'
|
6
|
+
module IccsSoap
|
7
|
+
# config/iccs.yml example:
|
8
|
+
#
|
9
|
+
# development: &devel
|
10
|
+
# customer_service:
|
11
|
+
# base_url: http://example.com/iccs-xsoap
|
12
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
13
|
+
# endpoint_url: http://example.com/iccs-xsoap/CustomerService
|
14
|
+
# document_url: http://example.com/iccs-xsoap/CustomerService?wsdl
|
15
|
+
# de_te_me_service:
|
16
|
+
# base_url: http://example.com/iccs-xsoap
|
17
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
18
|
+
# endpoint_url: http://example.com/iccs-xsoap/DeTeMeService
|
19
|
+
# document_url: http://example.com/iccs-xsoap/DeTeMeService?wsdl
|
20
|
+
# geo_block_service:
|
21
|
+
# base_url: http://example.com/iccs-xsoap
|
22
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
23
|
+
# endpoint_url: http://example.com/iccs-xsoap/GeoBlockService
|
24
|
+
# document_url: http://example.com/iccs-xsoap/GeoBlockService?wsdl
|
25
|
+
# geo_number_service:
|
26
|
+
# base_url: http://example.com/iccs-xsoap
|
27
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
28
|
+
# endpoint_url: http://example.com/iccs-xsoap/GeoNumberService
|
29
|
+
# document_url: http://example.com/iccs-xsoap/GeoNumberService?wsdl
|
30
|
+
# mobile_number_service:
|
31
|
+
# base_url: http://example.com/iccs-xsoap
|
32
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
33
|
+
# endpoint_url: http://example.com/iccs-xsoap/MobileNumberService
|
34
|
+
# document_url: http://example.com/iccs-xsoap/MobileNumberService?wsdl
|
35
|
+
# service_number_service:
|
36
|
+
# base_url: http://example.com/iccs-xsoap
|
37
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
38
|
+
# endpoint_url: http://example.com/iccs-xsoap/ServiceNumberService
|
39
|
+
# document_url: http://example.com/iccs-xsoap/ServiceNumberService?wsdl
|
40
|
+
# number_transfer_service:
|
41
|
+
# base_url: http://example.com/iccs-xsoap
|
42
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
43
|
+
# endpoint_url: http://example.com/iccs-xsoap/GeoNumberService
|
44
|
+
# document_url: http://example.com/iccs-xsoap/GeoNumberService?wsdl
|
45
|
+
# security_service:
|
46
|
+
# user: theuser
|
47
|
+
# password: verysecret
|
48
|
+
# base_url: http://example.com/iccs-xsoap
|
49
|
+
# namespace_url: http://security.xsoap.iccs.de/v1'
|
50
|
+
# endpoint_url: http://example.com/iccs-xsoap/SecurityService
|
51
|
+
# document_url: http://example.com/iccs-xsoap/SecurityService?wsdl
|
52
|
+
|
53
|
+
# all these nice colorful log entries are created here
|
54
|
+
# if you don`t like them just override its #call method
|
55
|
+
class CustomLogFormatter
|
56
|
+
require 'term/ansicolor'
|
57
|
+
TIME_FORMAT = "%Y-%m-%d %H:%M:%S."
|
58
|
+
HOST = %x(hostname).chomp
|
59
|
+
APP = File.basename(Dir.pwd)
|
60
|
+
|
61
|
+
String.send(:include, Term::ANSIColor)
|
62
|
+
|
63
|
+
def call(severity, time, progname, msg)
|
64
|
+
@severity = severity
|
65
|
+
@time = time
|
66
|
+
@progname = progname
|
67
|
+
@msg = msg
|
68
|
+
formatted_msg
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def formatted_severity
|
74
|
+
{
|
75
|
+
'DEBUG' => 'DEBUG'.blue,
|
76
|
+
'INFO' => ' INFO'.green,
|
77
|
+
'WARN' => ' WARN'.yellow,
|
78
|
+
'ERROR' => 'ERROR'.intense_red,
|
79
|
+
'FATAL' => 'FATAL'.intense_white.on_red,
|
80
|
+
'ANY' => ' ANY'.black.on_white
|
81
|
+
}[@severity]
|
82
|
+
end
|
83
|
+
|
84
|
+
def formatted_progname
|
85
|
+
end
|
86
|
+
|
87
|
+
def formatted_msg
|
88
|
+
formatted_time = @time.strftime(TIME_FORMAT) << @time.usec.to_s[0..2].rjust(3)
|
89
|
+
if @msg.kind_of?(Exception)
|
90
|
+
"#{formatted_time} #{HOST} #{APP}[#{$$}][#{formatted_severity}] #{@msg.inspect}\n" +
|
91
|
+
@msg.backtrace.map do |bt_line|
|
92
|
+
"#{formatted_time} #{HOST} #{APP}[#{$$}][#{formatted_severity}] #{bt_line}\n"
|
93
|
+
end.join
|
94
|
+
elsif @msg.kind_of?(String)
|
95
|
+
"#{formatted_time} #{HOST} #{APP}[#{$$}][#{formatted_severity}] #{@msg.strip}\n"
|
96
|
+
else
|
97
|
+
"#{formatted_time} #{HOST} #{APP}[#{$$}][#{formatted_severity}] #{@msg.class}: #{@msg.inspect}\n"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class Config < OpenStruct
|
103
|
+
class << self
|
104
|
+
env = 'development'
|
105
|
+
config_data = YAML.load(File.read(File.join('config', 'iccs.yml')))[env]
|
106
|
+
|
107
|
+
config_data.each do |k,v|
|
108
|
+
define_method(k.to_sym, lambda {__deep_struct__(v)})
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
# just a utility method to enable something along the line
|
114
|
+
#
|
115
|
+
# Config.foo.bar.baz
|
116
|
+
|
117
|
+
def __deep_struct__(h)
|
118
|
+
struct = {}
|
119
|
+
h.each do |k,v|
|
120
|
+
struct.merge!({k => v.kind_of?(Hash) ? __deep_struct__(v) : v})
|
121
|
+
end
|
122
|
+
new(struct)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
$soap_log = Logger.new(File.join('log', 'iccs-soap.log'))
|
129
|
+
$soap_log.formatter = IccsSoap::CustomLogFormatter.new
|
130
|
+
|
131
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'iccs-soap', '**', '*.rb')).each do |f|
|
132
|
+
require f
|
133
|
+
end
|
134
|
+
|
135
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module IccsSoap
|
2
|
+
class CustomerService
|
3
|
+
class << self
|
4
|
+
@@client = Savon.client(:wsdl => IccsSoap::Config.customer_service.document_url,
|
5
|
+
:endpoint => IccsSoap::Config.customer_service.endpoint_url,
|
6
|
+
:namespace => IccsSoap::Config.customer_service.namespace_url,
|
7
|
+
:log => $soap_log,
|
8
|
+
:soap_header => %Q(<simpleAuth xmlns="http://xsoap.iccs.de/v1" username="#{IccsSoap::Config.security_service.user}" password="#{IccsSoap::Config.security_service.password}" />))
|
9
|
+
|
10
|
+
def external_id(id, hostname, app_id)
|
11
|
+
app_id == "Talkyoo_dev" || app_id == "Talkyoo_pre" ? "#{id}-#{app_id}-#{hostname[0..5]}" : id
|
12
|
+
end
|
13
|
+
|
14
|
+
# finds the customer on the remote system using your (read: "foreignNr") id
|
15
|
+
def get_customer(id)
|
16
|
+
response = @@client.call(:get_customer, :message => {:customerNr => id})
|
17
|
+
response.body[:get_customer_response]
|
18
|
+
rescue Savon::SOAPFault => e
|
19
|
+
return nil if e.to_hash[:fault][:faultstring].match(/Kunde nicht gefunden/)
|
20
|
+
$soap_log.error("soap error in get_customer(#{id}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
21
|
+
raise
|
22
|
+
end
|
23
|
+
|
24
|
+
# deletes the customer on the remote system using your (read: "foreignNr") id
|
25
|
+
# note this will only succeed if no remnants are left there (e.g. assigned phone numbers).
|
26
|
+
# find and remove these first
|
27
|
+
def delete_customer(id)
|
28
|
+
response = @@client.call(:delete_customer, :message => {:foreignNr => id})
|
29
|
+
response.body[:delete_customer_response][:customer]
|
30
|
+
rescue Savon::SOAPFault => e
|
31
|
+
$soap_log.error("soap error in delete_customer(#{id}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
32
|
+
raise
|
33
|
+
end
|
34
|
+
|
35
|
+
# create a new customer on the remote system, there are lots of mandatory parameters:
|
36
|
+
# :first_name
|
37
|
+
# :last_name
|
38
|
+
# :externalId (our id, we'll need it to find the customers later)
|
39
|
+
# :ndc (National Destination Code which is usually the area code without the leading zero)
|
40
|
+
# :street
|
41
|
+
# :house_number
|
42
|
+
# :zip_code
|
43
|
+
# :city
|
44
|
+
def create_customer(*params)
|
45
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})}
|
46
|
+
response = @@client.call(:create_customer, :message => {
|
47
|
+
:externalId => params[:external_id],
|
48
|
+
:customer => {
|
49
|
+
:first_name => params[:first_name],
|
50
|
+
:foreign_nr => params[:external_id],
|
51
|
+
:last_name => params[:last_name],
|
52
|
+
:ndc => params[:ndc],
|
53
|
+
:state => "ACTIVE",
|
54
|
+
:type => "PRIVATE"
|
55
|
+
},
|
56
|
+
:addresses => {
|
57
|
+
:address => {
|
58
|
+
:city => params[:city],
|
59
|
+
:country => 'DE',
|
60
|
+
:house_number => params[:house_number].to_s[0..3],
|
61
|
+
:house_number_addon => params[:house_number].to_s[4..9],
|
62
|
+
:street=> params[:street],
|
63
|
+
:type=> "PRIMARY",
|
64
|
+
:zip_code=> params[:zip_code]
|
65
|
+
}
|
66
|
+
}
|
67
|
+
})
|
68
|
+
response.body[:create_customer_response][:customer]
|
69
|
+
rescue Savon::SOAPFault => e
|
70
|
+
$soap_log.error("soap error in create_customer(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
71
|
+
raise
|
72
|
+
end
|
73
|
+
|
74
|
+
# updates an existing customer on the remote system
|
75
|
+
# :id (mandatory, our id to find the customer)
|
76
|
+
# :first_name
|
77
|
+
# :last_name
|
78
|
+
# :external_id (we can change our customer_id)
|
79
|
+
# :ndc (National Destination Code which is usually the area code without the leading zero)
|
80
|
+
# :street
|
81
|
+
# :house_number
|
82
|
+
# :zip_code
|
83
|
+
# :city
|
84
|
+
|
85
|
+
def update_customer(*params)
|
86
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})}
|
87
|
+
|
88
|
+
response = @@client.call(:update_customer, :message => {
|
89
|
+
:foreignNr => params[:external_id],
|
90
|
+
:customer => {
|
91
|
+
:first_name => params[:first_name],
|
92
|
+
:external_id => params[:external_id],
|
93
|
+
:last_name => params[:last_name],
|
94
|
+
:ndc => params[:ndc],
|
95
|
+
:state => "ACTIVE",
|
96
|
+
:type => "PRIVATE"
|
97
|
+
},
|
98
|
+
:addresses => {
|
99
|
+
:address => {
|
100
|
+
:city => params[:city],
|
101
|
+
:country => 'DE',
|
102
|
+
:house_number => params[:house_number],
|
103
|
+
:street=> params[:street],
|
104
|
+
:type=> "PRIMARY",
|
105
|
+
:zip_code=> params[:zip_code]
|
106
|
+
}
|
107
|
+
}
|
108
|
+
})
|
109
|
+
|
110
|
+
if response.body[:update_customer_response][:customer].present?
|
111
|
+
return response.body[:update_customer_response][:customer]
|
112
|
+
else
|
113
|
+
return false
|
114
|
+
end
|
115
|
+
rescue Savon::SOAPFault => e
|
116
|
+
$soap_log.error("soap error in create_customer(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
117
|
+
false
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module IccsSoap
|
2
|
+
class GeoNumberService
|
3
|
+
require 'uri'
|
4
|
+
class << self
|
5
|
+
@@client = Savon.client(:wsdl => IccsSoap::Config.geo_number_service.document_url,
|
6
|
+
:endpoint => IccsSoap::Config.geo_number_service.endpoint_url,
|
7
|
+
:namespace => IccsSoap::Config.geo_number_service.namespace_url,
|
8
|
+
:log => $soap_log,
|
9
|
+
:soap_header => %Q(<simpleAuth xmlns="http://xsoap.iccs.de/v1" username="#{IccsSoap::Config.security_service.user}" password="#{IccsSoap::Config.security_service.password}" />))
|
10
|
+
|
11
|
+
|
12
|
+
def allocate_numbers(*params)
|
13
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to?
|
14
|
+
response = @@client.call(:allocate_numbers, :message => {
|
15
|
+
:amount => "1",
|
16
|
+
:ndc => params[:ndc],
|
17
|
+
:foreign_nr => params[:foreign_nr] || params[:external_id],
|
18
|
+
:customer_nr => params[:customer_nr],
|
19
|
+
:assignmentRule => "GEO_SINGLE_10_11"
|
20
|
+
})
|
21
|
+
response.body[:allocate_numbers_response][:numbers][:number]
|
22
|
+
rescue Savon::SOAPFault => e
|
23
|
+
$soap_log.error("soap error in allocate_numbers(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
24
|
+
raise
|
25
|
+
end
|
26
|
+
|
27
|
+
def activate_number(*params)
|
28
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to?
|
29
|
+
response = @@client.call(:activate_number, :message => {
|
30
|
+
:beginning => params[:beginning],
|
31
|
+
:ending => params[:ending] || params[:beginning]
|
32
|
+
})
|
33
|
+
response.body[:activate_number_response][:number]
|
34
|
+
rescue Savon::SOAPFault => e
|
35
|
+
$soap_log.error("soap error in activate_number(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
|
39
|
+
def quarantine_number(*params)
|
40
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to?
|
41
|
+
response = @@client.call(:quarantine_number, :message => {
|
42
|
+
:beginning => params[:beginning],
|
43
|
+
:ending => params[:ending] || params[:beginning]
|
44
|
+
})
|
45
|
+
response.body[:quarantine_number_response]
|
46
|
+
rescue Savon::SOAPFault => e
|
47
|
+
$soap_log.error("soap error in quarantine_number(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
|
51
|
+
def return_number_to_block(*params)
|
52
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to?
|
53
|
+
response = @@client.call(:return_number_to_block, :message => {
|
54
|
+
:beginning => params[:beginning],
|
55
|
+
:ending => params[:ending] || params[:beginning]
|
56
|
+
})
|
57
|
+
response.body[:return_number_to_block_response]
|
58
|
+
rescue Savon::SOAPFault => e
|
59
|
+
$soap_log.error("soap error in return_number_to_block(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
60
|
+
raise
|
61
|
+
end
|
62
|
+
|
63
|
+
def route_number(options)
|
64
|
+
remote_call = "route_number"
|
65
|
+
base_url = "https://intern.dns-net.de/cgi-bin/iccs/"
|
66
|
+
remote_call_param = "&#{remote_call}=#{remote_call}".gsub(/_/, '+')
|
67
|
+
uri = URI.parse("#{base_url}/#{remote_call}.pl?iccs_login=bbtel&iccs_password=Dieu87s3&" + options.keys.map {|option| URI.encode("#{option}=#{options[option]}").gsub(/&/, '%26').gsub(/\?/, '%3F')}.join('&') + remote_call_param)
|
68
|
+
response = https_req(uri)
|
69
|
+
|
70
|
+
raise Error, "uri: \"#{uri}\" response: \"#{response.body}\"" if response.body.match(/FAULT/)
|
71
|
+
return true #or: OpenStruct.new({:uri => uri, :response => response})
|
72
|
+
end
|
73
|
+
|
74
|
+
def https_req(uri)
|
75
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
76
|
+
https.use_ssl = true
|
77
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
78
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
79
|
+
https.request(request)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module IccsSoap
|
2
|
+
class NumberTransferService
|
3
|
+
class << self
|
4
|
+
@@client = Savon.client(:wsdl => IccsSoap::Config.number_transfer_service.document_url,
|
5
|
+
:endpoint => IccsSoap::Config.number_transfer_service.endpoint_url,
|
6
|
+
:namespace => IccsSoap::Config.number_transfer_service.namespace_url,
|
7
|
+
:log => $soap_log,
|
8
|
+
:soap_header => %Q(<simpleAuth xmlns="http://xsoap.iccs.de/v1" username="#{IccsSoap::Config.security_service.user}" password="#{IccsSoap::Config.security_service.password}" />))
|
9
|
+
|
10
|
+
def create_number_transfer(*params)
|
11
|
+
params = params[0].inject({}) { |start, accu| start.merge({accu[0].to_sym => accu[1]})} #TODO DRY this; but where to?
|
12
|
+
|
13
|
+
response = @@client.call(:create_number_transfer, :message => {
|
14
|
+
:beginning => params[:beginning],
|
15
|
+
:customerNrNew => params[:customer_nr_new],
|
16
|
+
:customerNrOld => params[:customer_nr_old]
|
17
|
+
})
|
18
|
+
|
19
|
+
return response
|
20
|
+
rescue Savon::SOAPFault => e
|
21
|
+
$soap_log.error("soap error in create_number_transfer(#{params}) #{e.to_hash[:fault][:faultcode]}: #{e.to_hash[:fault][:faultstring]}")
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module IccsSoap
|
2
|
+
class SecurityService
|
3
|
+
class << self
|
4
|
+
# opens a new session
|
5
|
+
def login
|
6
|
+
@client = Savon.client(
|
7
|
+
:log => $soap_log,
|
8
|
+
:wsdl => IccsSoap::Config.security_service.document_url,
|
9
|
+
:endpoint => IccsSoap::Config.security_service.endpoint_url,
|
10
|
+
:namespace => IccsSoap::Config.security_service.namespace_url
|
11
|
+
)
|
12
|
+
|
13
|
+
@response = @client.call(:login, :message => {
|
14
|
+
:userName => IccsSoap::Config.security_service.user,
|
15
|
+
:password => IccsSoap::Config.security_service.password
|
16
|
+
})
|
17
|
+
@client
|
18
|
+
rescue => e
|
19
|
+
{e => e.backtrace.join("\n")}
|
20
|
+
end
|
21
|
+
|
22
|
+
# ends the session
|
23
|
+
def logout
|
24
|
+
@response = @client.request :logout
|
25
|
+
remove_instance_variable @client
|
26
|
+
rescue => e
|
27
|
+
{e => e.backtrace.join("\n")}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe IccsSoap::Config do
|
3
|
+
before do
|
4
|
+
File.stub!(:read).and_return("development:\n user: foo\n password: pw123\n")
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should read the config file' do
|
8
|
+
File.should_receive(:read).and_return("development:\n user: bar")
|
9
|
+
load File.join(File.dirname(__FILE__), '..', '..', 'lib', 'iccs_soap.rb') #XXX: modifies all subsequent specs
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should define readers for every config line' do
|
13
|
+
load File.join(File.dirname(__FILE__), '..', '..', 'lib', 'iccs_soap.rb') #XXX: just to make the setup happy
|
14
|
+
IccsSoap::Config.should respond_to(:user)
|
15
|
+
IccsSoap::Config.user.should == 'foo'
|
16
|
+
IccsSoap::Config.should respond_to(:password)
|
17
|
+
IccsSoap::Config.password.should == 'pw123'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe IccsSoap::SecurityService do
|
2
|
+
it 'should have a NAMESPACE' do
|
3
|
+
IccsSoap::SecurityService::NAMESPACE.should match(/security.xsoap.iccs.de.v1/)
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'should have an ENDPOINT' do
|
7
|
+
IccsSoap::SecurityService::ENDPOINT.should match(/iccs-xsoap.SecurityService/)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should have a DOCUMENT' do
|
11
|
+
IccsSoap::SecurityService::DOCUMENT.should match(/iccs-xsoap.SecurityService\?wsdl/)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.login' do
|
15
|
+
it 'should have a class method .login' do
|
16
|
+
IccsSoap::SecurityService.should respond_to(:login)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
|
+
require 'debugger'
|
4
|
+
require 'iccs-soap'
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/autorun'
|
7
|
+
|
8
|
+
class JustARandomClass
|
9
|
+
include IccsSoap
|
10
|
+
end
|
11
|
+
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iccs-soap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.14
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sascha Teske
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: redis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: term-ansicolor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rr
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: shoulda
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: debugger
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: iccs-soap.
|
159
|
+
email: sascha.teske@gmail.com
|
160
|
+
executables: []
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files: []
|
163
|
+
files:
|
164
|
+
- .document
|
165
|
+
- .gitignore
|
166
|
+
- Gemfile
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- VERSION
|
170
|
+
- iccs-soap.gemspec
|
171
|
+
- lib/iccs-soap.rb
|
172
|
+
- lib/iccs-soap/customer_service.rb
|
173
|
+
- lib/iccs-soap/de_te_me_service.rb
|
174
|
+
- lib/iccs-soap/geo_block_service.rb
|
175
|
+
- lib/iccs-soap/geo_number_service.rb
|
176
|
+
- lib/iccs-soap/mobile_number_service.rb
|
177
|
+
- lib/iccs-soap/number_transfer_service.rb
|
178
|
+
- lib/iccs-soap/security_service.rb
|
179
|
+
- lib/iccs-soap/service_number_service.rb
|
180
|
+
- spec/functional/config_spec.rb
|
181
|
+
- spec/functional/customer_service_spec.rb
|
182
|
+
- spec/functional/de_te_me_service_spec.rb
|
183
|
+
- spec/functional/geo_block_service_spec.rb
|
184
|
+
- spec/functional/geo_number_service_spec.rb
|
185
|
+
- spec/functional/mobile_number_service_spec.rb
|
186
|
+
- spec/functional/number_transfer_service_spec.rb
|
187
|
+
- spec/functional/security_service_spec.rb
|
188
|
+
- spec/functional/service_number_service_spec.rb
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
homepage: http://github.com/slaxor/iccs-soap
|
191
|
+
licenses: []
|
192
|
+
post_install_message:
|
193
|
+
rdoc_options: []
|
194
|
+
require_paths:
|
195
|
+
- lib
|
196
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
+
none: false
|
198
|
+
requirements:
|
199
|
+
- - ! '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 1.8.23
|
211
|
+
signing_key:
|
212
|
+
specification_version: 3
|
213
|
+
summary: Wrapper for iccs soap api.
|
214
|
+
test_files: []
|