identity_linker 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module IdentityLinker
2
+ class Error < StandardError
3
+ def initialize(e)
4
+ super
5
+ end
6
+
7
+ def message
8
+ super.sub('(S:Server) ','')
9
+ end
10
+
11
+ def to_s
12
+ super.sub('(S:Server) ','')
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,5 @@
1
1
  require 'savon'
2
+ require 'identity_linker/error'
2
3
 
3
4
  module IdentityLinker
4
5
  class Linker
@@ -15,21 +16,25 @@ module IdentityLinker
15
16
  end
16
17
 
17
18
  def find_linked_identity(id_type, id_value, target)
18
- response = client.request(:wsdl, :find_linked_identity) do
19
- xml = <<-END
20
- <serverId>#{server_id}</serverId>
21
- <serverSecret>#{server_secret}</serverSecret>
22
- <identity>
23
- <idType>#{id_type}</idType>
24
- <idValue>#{id_value}</idValue>
25
- </identity>
26
- <target>#{target}</target>
27
- END
28
- soap.body = xml
29
- end
30
-
31
- if response.success?
32
- return response.to_hash[:find_linked_identity_response][:linked_identity]
19
+ begin
20
+ response = client.request(:wsdl, :find_linked_identity) do
21
+ xml = <<-END
22
+ <serverId>#{server_id}</serverId>
23
+ <serverSecret>#{server_secret}</serverSecret>
24
+ <identity>
25
+ <idType>#{id_type}</idType>
26
+ <idValue>#{id_value}</idValue>
27
+ </identity>
28
+ <target>#{target}</target>
29
+ END
30
+ soap.body = xml
31
+ end
32
+
33
+ if response.success?
34
+ return response.to_hash[:find_linked_identity_response][:linked_identity]
35
+ end
36
+ rescue Savon::SOAP::Fault => e
37
+ raise Error.new(e)
33
38
  end
34
39
 
35
40
  nil
@@ -40,23 +45,26 @@ module IdentityLinker
40
45
  end
41
46
 
42
47
  def find_linked_identity_with_details(id_type, id_value, target)
43
- response = client.request(:wsdl, :find_linked_identity_with_details) do
44
- xml = <<-END
45
- <serverId>#{server_id}</serverId>
46
- <serverSecret>#{server_secret}</serverSecret>
47
- <identity>
48
- <idType>#{id_type}</idType>
49
- <idValue>#{id_value}</idValue>
50
- </identity>
51
- <target>#{target}</target>
52
- END
53
- soap.body = xml
48
+ begin
49
+ response = client.request(:wsdl, :find_linked_identity_with_details) do
50
+ xml = <<-END
51
+ <serverId>#{server_id}</serverId>
52
+ <serverSecret>#{server_secret}</serverSecret>
53
+ <identity>
54
+ <idType>#{id_type}</idType>
55
+ <idValue>#{id_value}</idValue>
56
+ </identity>
57
+ <target>#{target}</target>
58
+ END
59
+ soap.body = xml
60
+ end
61
+
62
+ if response.success?
63
+ return response.to_hash[:find_linked_identity_with_details_response][:linked_identity]
64
+ end
65
+ rescue Savon::SOAP::Fault => e
66
+ raise Error.new(e)
54
67
  end
55
-
56
- if response.success?
57
- return response.to_hash[:find_linked_identity_with_details_response][:linked_identity]
58
- end
59
-
60
68
  nil
61
69
  end
62
70
 
@@ -65,20 +73,24 @@ module IdentityLinker
65
73
  end
66
74
 
67
75
  def find_all_linked_identities(id_type, id_value)
68
- response = client.request(:wsdl, :find_all_linked_identities) do
69
- xml = <<-END
76
+ begin
77
+ response = client.request(:wsdl, :find_all_linked_identities) do
78
+ xml = <<-END
70
79
  <serverId>#{server_id}</serverId>
71
80
  <serverSecret>#{server_secret}</serverSecret>
72
81
  <identity>
73
82
  <idType>#{id_type}</idType>
74
83
  <idValue>#{id_value}</idValue>
75
84
  </identity>
76
- END
77
- soap.body = xml
78
- end
79
-
80
- if response.success?
81
- return response.to_hash[:find_all_linked_identities_response][:linked_identity]
85
+ END
86
+ soap.body = xml
87
+ end
88
+
89
+ if response.success?
90
+ return response.to_hash[:find_all_linked_identities_response][:linked_identity]
91
+ end
92
+ rescue Savon::SOAP::Fault => e
93
+ raise Error.new(e)
82
94
  end
83
95
 
84
96
  nil
@@ -89,20 +101,24 @@ module IdentityLinker
89
101
  end
90
102
 
91
103
  def find_all_linked_identities_with_details(id_type, id_value)
92
- response = client.request(:wsdl, :find_all_linked_identities_with_details) do
93
- xml = <<-END
104
+ begin
105
+ response = client.request(:wsdl, :find_all_linked_identities_with_details) do
106
+ xml = <<-END
94
107
  <serverId>#{server_id}</serverId>
95
108
  <serverSecret>#{server_secret}</serverSecret>
96
109
  <identity>
97
110
  <idType>#{id_type}</idType>
98
111
  <idValue>#{id_value}</idValue>
99
112
  </identity>
100
- END
101
- soap.body = xml
102
- end
103
-
104
- if response.success?
105
- return response.to_hash[:find_all_linked_identities_with_details_response][:linked_identity]
113
+ END
114
+ soap.body = xml
115
+ end
116
+
117
+ if response.success?
118
+ return response.to_hash[:find_all_linked_identities_with_details_response][:linked_identity]
119
+ end
120
+ rescue Savon::SOAP::Fault => e
121
+ raise Error.new(e)
106
122
  end
107
123
 
108
124
  nil
@@ -113,8 +129,9 @@ module IdentityLinker
113
129
  end
114
130
 
115
131
  def find_linked_identities_of_type(id_type, id_value, target)
116
- response = client.request(:wsdl, :find_linked_identities_of_type) do
117
- xml = <<-END
132
+ begin
133
+ response = client.request(:wsdl, :find_linked_identities_of_type) do
134
+ xml = <<-END
118
135
  <serverId>#{server_id}</serverId>
119
136
  <serverSecret>#{server_secret}</serverSecret>
120
137
  <identity>
@@ -122,12 +139,15 @@ module IdentityLinker
122
139
  <idValue>#{id_value}</idValue>
123
140
  </identity>
124
141
  <target>#{target}</target>
125
- END
126
- soap.body = xml
127
- end
128
-
129
- if response.success?
130
- return [response.to_hash[:find_linked_identities_of_type_response][:linked_identity]].flatten.compact
142
+ END
143
+ soap.body = xml
144
+ end
145
+
146
+ if response.success?
147
+ return [response.to_hash[:find_linked_identities_of_type_response][:linked_identity]].flatten.compact
148
+ end
149
+ rescue Savon::SOAP::Fault => e
150
+ raise Error.new(e)
131
151
  end
132
152
 
133
153
  nil
@@ -1,3 +1,3 @@
1
1
  module IdentityLinker
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -42,6 +42,7 @@ files:
42
42
  - identity_linker.gemspec
43
43
  - lib/identity_linker.rb
44
44
  - lib/identity_linker/config.rb
45
+ - lib/identity_linker/error.rb
45
46
  - lib/identity_linker/linker.rb
46
47
  - lib/identity_linker/version.rb
47
48
  - spec/spec_helper.rb
@@ -71,3 +72,4 @@ specification_version: 3
71
72
  summary: Ruby library for accessing Cru's Identity Linking system
72
73
  test_files:
73
74
  - spec/spec_helper.rb
75
+ has_rdoc: