soap4juddi 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45d54feebdd6c0c2ef331e7b62cbe266bcda4516
4
- data.tar.gz: 71e0654c9f9bcc857c863f8e17a1a8fa5a289f8c
3
+ metadata.gz: 9aa704713a3987adc9b8ad09abf4d15f9c7353d8
4
+ data.tar.gz: e27b11a2a99b6f10d04f5b5c1a0f76df3ec49986
5
5
  SHA512:
6
- metadata.gz: e3966c3d7617914a4d48cf862ee88fa9ea259b61bbd8badfbebc3fe1682e2c350ed193d6b85ae758a4b792410e482510cfd2154a53fb372ddbfef581050eba08
7
- data.tar.gz: ff3fbbfc8a6d5155884ab5eb8e10f5c716236058a8474b8c89207d182779693c22e73bece3d98abe4241a6209df19a9df5cb748acb4de9c2c057cd7e6c267854
6
+ metadata.gz: 17268df6f47e68f26ad3f85e629aaf956913d897459f09855b75cbc12206b98ef5f4405ff5f2f7cf82443d7b4e9906b941a7614cb75d9faf34d5bc7cfded3bd3
7
+ data.tar.gz: 5bab4343e05df97c8469b1cae7e23fcb7387f1f53d943a6be70fa5c8a2bd4ed3215d1406ca74f9917e28294e88249e1f9a15d20f7125aabb0b3ce4d09d595e53
@@ -15,7 +15,7 @@ module Soap4juddi
15
15
  end
16
16
 
17
17
  def save_element_bindings(service, bindings, urn, description)
18
- validate_bindings(bindings)
18
+ validate_elements(bindings, 'bindings')
19
19
  body = auth_body
20
20
  body = add_bindings(body, service, bindings, urn, description)
21
21
  @soap_connector.request_soap(@base_uri, 'publishv2', 'save_binding', body) do | res|
@@ -23,32 +23,13 @@ module Soap4juddi
23
23
  end
24
24
  end
25
25
 
26
- def save_business(key, name, description, contacts)
27
- body = @soap_xml.element_with_value("name", name)
28
- if description
29
- description.each do |desc|
30
- xml = @soap_xml.element_with_value('description', desc, {'xml:lang' => 'en'})
31
- body = "#{body}#{xml}" if desc and not (desc == "")
32
- end
33
- end
34
- if (contacts) and (not contacts.empty?)
35
- # byebug
36
- contacts_xml = ""
37
- contacts.each do |contact|
38
- # contact_details = "<contact useType='(Job Title, Role)'> <description>Primary Contact</description> <personName>Ernst</personName> <phone useType='(Extension, Domestic, International, DSN)'>0217881441</phone> <email useType='Email'>ernst@b.com</email> </contact>"
39
-
40
- contact_details = "<contact useType='(Job Title, Role)'> <description>#{contact['description']}</description> <personName>#{contact['name']}</personName> <phone useType='(Extension, Domestic, International, DSN)'>#{contact['phone']}</phone> <email useType='Email'>#{contact['email']}</email> </contact>"
41
-
42
- contacts_xml = contacts_xml + contact_details
43
- end
44
- xml = @soap_xml.element_with_value("contacts", contacts_xml)
45
- body = "#{body}#{xml}" if xml and not (xml == "")
46
- end
47
-
48
- businessEntity = @soap_xml.element_with_value('businessEntity', body, {'businessKey' => key})
26
+ def save_business(key, name, descriptions, contacts)
27
+ validate_elements(contacts, 'contacts')
28
+ validate_elements(descriptions, 'descriptions')
29
+ body = build_business_entity(key, name, descriptions, contacts)
49
30
  @soap_connector.request_soap(@base_uri,
50
31
  'publishv2', 'save_business',
51
- "#{auth_body} #{businessEntity}") do | res|
32
+ "#{auth_body} #{body}") do | res|
52
33
  extract_business(res.body)
53
34
  end
54
35
  end
@@ -200,6 +181,21 @@ module Soap4juddi
200
181
  end
201
182
 
202
183
  private
184
+
185
+ def add_descriptions(body, descriptions)
186
+ if descriptions
187
+ descriptions.each do |desc|
188
+ body = add_description(body, desc)
189
+ end
190
+ end
191
+ body
192
+ end
193
+
194
+ def add_description(body, desc)
195
+ xml = @soap_xml.element_with_value('description', desc, {'xml:lang' => 'en'})
196
+ body = "#{body}#{xml}" if desc and not (desc == "")
197
+ body
198
+ end
203
199
 
204
200
  def add_bindings(body, service, bindings, urn, description)
205
201
  if (not bindings.nil?) and (not (bindings.size == 0))
@@ -210,6 +206,31 @@ module Soap4juddi
210
206
  body
211
207
  end
212
208
 
209
+ def add_contacts(body, contacts)
210
+ if (contacts) and (not contacts.empty?)
211
+ # byebug
212
+ contacts_xml = add_contacts_to_xml("", contacts)
213
+ xml = @soap_xml.element_with_value("contacts", contacts_xml)
214
+ body = "#{body}#{xml}" if xml and not (xml == "")
215
+ end
216
+ body
217
+ end
218
+
219
+ def add_contacts_to_xml(contacts_xml, contacts)
220
+ contacts.each do |contact|
221
+ contact_details = "<contact useType='(Job Title, Role)'> <description>#{contact['description']}</description> <personName>#{contact['name']}</personName> <phone useType='(Extension, Domestic, International, DSN)'>#{contact['phone']}</phone> <email useType='Email'>#{contact['email']}</email> </contact>"
222
+ contacts_xml = contacts_xml + contact_details
223
+ end
224
+ contacts_xml
225
+ end
226
+
227
+ def build_business_entity(key, name, descriptions, contacts)
228
+ body = @soap_xml.element_with_value("name", name)
229
+ body = add_descriptions(body, descriptions)
230
+ body = add_contacts(body, contacts)
231
+ @soap_xml.element_with_value('businessEntity', body, {'businessKey' => key})
232
+ end
233
+
213
234
  def add_binding(body, service, binding, urn, description)
214
235
  access_point = @soap_xml.element_with_value('accessPoint', binding, {'URLType' => extract_binding_url_type(binding)})
215
236
  description_data = @soap_xml.element_with_value('description', description)
@@ -221,8 +242,8 @@ module Soap4juddi
221
242
  body + bindingTemplate
222
243
  end
223
244
 
224
- def validate_bindings(bindings)
225
- raise Soap4juddi::InvalidElementError.new('invalid bindings') if not bindings.is_a?(Array)
245
+ def validate_elements(elements, label)
246
+ raise Soap4juddi::InvalidElementError.new("invalid #{label}") if not elements.is_a?(Array)
226
247
  true
227
248
  end
228
249
 
@@ -1,3 +1,3 @@
1
1
  module Soap4juddi
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soap4juddi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst van Graan