epp-client-afnic 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd3aca9088bc17f87cf82a39c60447b07a768a4b
4
- data.tar.gz: 340f2fbd7eeb4df5aab35ad9da6577c565d3d08c
5
2
  SHA512:
6
- metadata.gz: a3d652bc42fe84851f1df04bce0773dc290102d37194118267d4a0b25b983c73165fcc6d30dfbd45ea1f002717c124bdf52295ef6dcbfe9fd03f5c739f6e0166
7
- data.tar.gz: 823ad7c75fa1a03dd81593facdfa5c8e4d6e68b9993355e036330a2c06cd4744f1b04e75b7c558c704649e75db7099e74a69645c6430a2e4d35b7690826829ae
3
+ metadata.gz: 46632d82cdedaa8f5741f2188aaa8f59e9c77d6e31179997253cac9c773cf58926e1f431a07eb0da9cb1ad86ea70246dfedc9df5050cf69530f4ea80a553a65d
4
+ data.tar.gz: c2abc4895ec08a6ce2706f409c964224927079e3ddace1197643d3d6a11c9c96487d132958018b316e5421a62c451911b93b3d8df21f4fc4e1fcf037e5885b98
5
+ SHA1:
6
+ metadata.gz: 8f2c6f33f1787eeb6d0fe4acf073ffbd46100269
7
+ data.tar.gz: 3ded489d87400522ec64bc8deea3ab4ed0c4122c
data/Rakefile CHANGED
@@ -2,9 +2,9 @@
2
2
  require 'rake'
3
3
  require 'rdoc/task'
4
4
  require 'rubygems/package_task'
5
- require "bundler/gem_helper"
5
+ require 'bundler/gem_helper'
6
6
 
7
- MY_GEMS = Dir['*.gemspec'].map {|g| g.sub(/.*-(.*)\.gemspec/, '\1')}
7
+ MY_GEMS = Dir['*.gemspec'].map { |g| g.sub(/.*-(.*)\.gemspec/, '\1') }
8
8
 
9
9
  MY_GEMS.each do |g|
10
10
  namespace g do
@@ -26,10 +26,10 @@ task :build => 'all:build'
26
26
  task :install => 'all:install'
27
27
  task :push => 'all:push'
28
28
 
29
- desc "Generate documentation for the Rails framework"
29
+ desc 'Generate documentation for the Rails framework'
30
30
  Rake::RDocTask.new do |rdoc|
31
31
  rdoc.rdoc_dir = 'doc/rdoc'
32
- rdoc.title = "Documentation"
32
+ rdoc.title = 'Documentation'
33
33
 
34
34
  rdoc.options << '--line-numbers' << '--inline-source'
35
35
  rdoc.options << '--charset' << 'utf-8'
@@ -38,4 +38,3 @@ Rake::RDocTask.new do |rdoc|
38
38
  rdoc.rdoc_files.include('ChangeLog')
39
39
  rdoc.rdoc_files.include('lib/**/*.rb')
40
40
  end
41
-
@@ -8,12 +8,12 @@ Gem::Specification.new do |gem|
8
8
  gem.email = ['m@absolight.fr']
9
9
  gem.description = 'AFNIC EPP client library.'
10
10
  gem.summary = 'AFNIC EPP client library'
11
- gem.homepage = "https://github.com/Absolight/epp-client"
11
+ gem.homepage = 'https://github.com/Absolight/epp-client'
12
12
 
13
13
  gem.required_ruby_version = '>= 1.8.7'
14
- gem.required_rubygems_version = ">= 1.3.6"
14
+ gem.required_rubygems_version = '>= 1.3.6'
15
15
 
16
- gem.files = [
16
+ gem.files = [
17
17
  'ChangeLog',
18
18
  'EXAMPLE.AFNIC',
19
19
  'Gemfile',
@@ -25,15 +25,17 @@ Gem::Specification.new do |gem|
25
25
  'vendor/afnic/frnic-1.0.xsd',
26
26
  'vendor/afnic/frnic-1.1.xsd',
27
27
  'vendor/afnic/frnic-1.2.xsd',
28
+ 'vendor/afnic/frnic-1.3.xsd',
29
+ 'vendor/afnic/frnic-1.4.xsd',
28
30
  ]
29
31
 
30
32
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
33
  gem.require_paths = ['lib']
32
34
 
33
- gem.add_development_dependency "bundler", ">= 1.0.0"
35
+ gem.add_development_dependency 'bundler', '>= 1.0.0'
34
36
  gem.add_dependency('nokogiri', '~> 1.4')
35
37
  gem.add_dependency('builder', '>= 2.1.2')
36
- gem.add_dependency('epp-client-base', "#{EPPClient::VERSION}")
37
- gem.add_dependency('epp-client-rgp', "#{EPPClient::VERSION}")
38
- gem.add_dependency('epp-client-secdns', "#{EPPClient::VERSION}")
38
+ gem.add_dependency('epp-client-base', EPPClient::VERSION.to_s)
39
+ gem.add_dependency('epp-client-rgp', EPPClient::VERSION.to_s)
40
+ gem.add_dependency('epp-client-secdns', EPPClient::VERSION.to_s)
39
41
  end
@@ -3,13 +3,16 @@ require 'epp-client/rgp'
3
3
  require 'epp-client/secdns'
4
4
 
5
5
  module EPPClient
6
+ # This handles the AFNIC specificities.
7
+ #
8
+ # See http://www.afnic.fr/doc/interface/epp
6
9
  class AFNIC < Base
7
- SCHEMAS_AFNIC = %w[
8
- frnic-1.2
9
- ]
10
+ SCHEMAS_AFNIC = %w(
11
+ frnic-1.4
12
+ ).freeze
10
13
 
11
- EPPClient::SCHEMAS_URL.merge!(SCHEMAS_AFNIC.inject({}) do |a,s|
12
- a[s.sub(/-1\.2$/, '')] = "http://www.afnic.fr/xml/epp/#{s}" if s =~ /-1\.2$/
14
+ EPPClient::SCHEMAS_URL.merge!(SCHEMAS_AFNIC.inject({}) do |a, s|
15
+ a[s.sub(/-1\.4$/, '')] = "http://www.afnic.fr/xml/epp/#{s}" if s =~ /-1\.4$/
13
16
  a[s] = "http://www.afnic.fr/xml/epp/#{s}"
14
17
  a
15
18
  end)
@@ -21,11 +24,11 @@ module EPPClient
21
24
  # ==== Optional Attributes
22
25
  # [<tt>:test</tt>] sets the server to be the test server.
23
26
  def initialize(args)
24
- if args.delete(:test) == true
25
- args[:server] ||= 'epp.sandbox.nic.fr'
26
- else
27
- args[:server] ||= 'epp.nic.fr'
28
- end
27
+ args[:server] ||= if args.delete(:test) == true
28
+ 'epp.sandbox.nic.fr'
29
+ else
30
+ 'epp.nic.fr'
31
+ end
29
32
  @services = EPPClient::SCHEMAS_URL.values_at('domain', 'contact')
30
33
  args[:port] ||= 700
31
34
  super(args)
@@ -46,18 +49,18 @@ module EPPClient
46
49
  def domain_check_process(xml) # :nodoc:
47
50
  ret = super
48
51
  xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:chkData/frnic:domain/frnic:cd', EPPClient::SCHEMAS_URL).each do |dom|
49
- name = dom.xpath('frnic:name', EPPClient::SCHEMAS_URL)
50
- hash = ret.select {|d| d[:name] == name.text}.first
51
- hash[:reserved] = name.attr('reserved').value == "1"
52
- unless (reason = dom.xpath('frnic:rsvReason', EPPClient::SCHEMAS_URL).text).empty?
53
- hash[:rsvReason] = reason
54
- end
55
- hash[:forbidden] = name.attr('forbidden').value == "1"
56
- unless (reason = dom.xpath('frnic:fbdReason', EPPClient::SCHEMAS_URL).text).empty?
57
- hash[:fbdReason] = reason
58
- end
52
+ name = dom.xpath('frnic:name', EPPClient::SCHEMAS_URL)
53
+ hash = ret.find { |d| d[:name] == name.text }
54
+ hash[:reserved] = name.attr('reserved').value == '1'
55
+ unless (reason = dom.xpath('frnic:rsvReason', EPPClient::SCHEMAS_URL).text).empty?
56
+ hash[:rsvReason] = reason
57
+ end
58
+ hash[:forbidden] = name.attr('forbidden').value == '1'
59
+ unless (reason = dom.xpath('frnic:fbdReason', EPPClient::SCHEMAS_URL).text).empty?
60
+ hash[:fbdReason] = reason
61
+ end
59
62
  end
60
- return ret
63
+ ret
61
64
  end
62
65
 
63
66
  # Extends the EPPClient::Domain#domain_info so that the specific AFNIC
@@ -69,8 +72,8 @@ module EPPClient
69
72
  def domain_info_process(xml) #:nodoc:
70
73
  ret = super
71
74
  if (frnic_status = xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:infData/frnic:domain/frnic:status', EPPClient::SCHEMAS_URL)).size > 0
72
- ret[:status] ||= [] # The status is optional, there may be none at this point.
73
- ret[:status] += frnic_status.map {|s| s.attr('s')}
75
+ ret[:status] ||= [] # The status is optional, there may be none at this point.
76
+ ret[:status] += frnic_status.map { |s| s.attr('s') }
74
77
  end
75
78
  ret
76
79
  end
@@ -79,33 +82,33 @@ module EPPClient
79
82
  def legalEntityInfos(leI) #:nodoc:
80
83
  ret = {}
81
84
  ret[:legalStatus] = leI.xpath('frnic:legalStatus', EPPClient::SCHEMAS_URL).attr('s').value
82
- if (r = leI.xpath("frnic:idStatus", EPPClient::SCHEMAS_URL)).size > 0
83
- ret[:idStatus] = {:value => r.text}
84
- ret[:idStatus][:when] = r.attr('when').value if r.attr('when')
85
- ret[:idStatus][:source] = r.attr('source').value if r.attr('source')
85
+ if (r = leI.xpath('frnic:idStatus', EPPClient::SCHEMAS_URL)).size > 0
86
+ ret[:idStatus] = { :value => r.text }
87
+ ret[:idStatus][:when] = r.attr('when').value if r.attr('when')
88
+ ret[:idStatus][:source] = r.attr('source').value if r.attr('source')
86
89
  end
87
90
  %w(siren VAT trademark DUNS local).each do |val|
88
- if (r = leI.xpath("frnic:#{val}", EPPClient::SCHEMAS_URL)).size > 0
89
- ret[val.to_sym] = r.text
90
- end
91
+ if (r = leI.xpath("frnic:#{val}", EPPClient::SCHEMAS_URL)).size > 0
92
+ ret[val.to_sym] = r.text
93
+ end
91
94
  end
92
- if (asso = leI.xpath("frnic:asso", EPPClient::SCHEMAS_URL)).size > 0
93
- ret[:asso] = {}
94
- if (r = asso.xpath("frnic:waldec", EPPClient::SCHEMAS_URL)).size > 0
95
- ret[:asso][:waldec] = r.text
96
- else
97
- if (decl = asso.xpath('frnic:decl', EPPClient::SCHEMAS_URL)).size > 0
98
- ret[:asso][:decl] = Date.parse(decl.text)
99
- end
100
- publ = asso.xpath('frnic:publ', EPPClient::SCHEMAS_URL)
101
- ret[:asso][:publ] = {
102
- :date => Date.parse(publ.text),
103
- :page => publ.attr('page').value,
104
- }
105
- if (announce = publ.attr('announce')) && announce.value != '0'
106
- ret[:asso][:publ][:announce] = announce.value
107
- end
108
- end
95
+ if (asso = leI.xpath('frnic:asso', EPPClient::SCHEMAS_URL)).size > 0
96
+ ret[:asso] = {}
97
+ if (r = asso.xpath('frnic:waldec', EPPClient::SCHEMAS_URL)).size > 0
98
+ ret[:asso][:waldec] = r.text
99
+ else
100
+ if (decl = asso.xpath('frnic:decl', EPPClient::SCHEMAS_URL)).size > 0
101
+ ret[:asso][:decl] = Date.parse(decl.text)
102
+ end
103
+ publ = asso.xpath('frnic:publ', EPPClient::SCHEMAS_URL)
104
+ ret[:asso][:publ] = {
105
+ :date => Date.parse(publ.text),
106
+ :page => publ.attr('page').value,
107
+ }
108
+ if (announce = publ.attr('announce')) && announce.value != '0'
109
+ ret[:asso][:publ][:announce] = announce.value
110
+ end
111
+ end
109
112
  end
110
113
  ret
111
114
  end
@@ -180,51 +183,51 @@ module EPPClient
180
183
  def contact_info_process(xml) #:nodoc:
181
184
  ret = super
182
185
  if (contact = xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:infData/frnic:contact', EPPClient::SCHEMAS_URL)).size > 0
183
- if (list = contact.xpath('frnic:list', EPPClient::SCHEMAS_URL)).size > 0
184
- ret[:list] = list.map {|l| l.text}
185
- end
186
- if (firstName = contact.xpath('frnic:firstName', EPPClient::SCHEMAS_URL)).size > 0
187
- ret[:firstName] = firstName.text
188
- end
189
- if (iI = contact.xpath('frnic:individualInfos', EPPClient::SCHEMAS_URL)).size > 0
190
- ret[:individualInfos] = {}
191
- ret[:individualInfos][:birthDate] = Date.parse(iI.xpath('frnic:birthDate', EPPClient::SCHEMAS_URL).text)
192
- if (r = iI.xpath("frnic:idStatus", EPPClient::SCHEMAS_URL)).size > 0
193
- ret[:individualInfos][:idStatus] = {:value => r.text}
194
- ret[:individualInfos][:idStatus][:when] = r.attr('when').value if r.attr('when')
195
- ret[:individualInfos][:idStatus][:source] = r.attr('source').value if r.attr('source')
196
- end
197
- %w(birthCity birthPc birthCc).each do |val|
198
- if (r = iI.xpath("frnic:#{val}", EPPClient::SCHEMAS_URL)).size > 0
199
- ret[:individualInfos][val.to_sym] = r.text
200
- end
201
- end
202
- end
203
- if (leI = contact.xpath('frnic:legalEntityInfos', EPPClient::SCHEMAS_URL)).size > 0
204
- ret[:legalEntityInfos] = legalEntityInfos(leI)
205
- end
206
- if (obsoleted = contact.xpath('frnic:obsoleted', EPPClient::SCHEMAS_URL)).size > 0
207
- if obsoleted.text != '0'
208
- ret[:obsoleted] = {}
209
- if v_when = obsoleted.attr('when')
210
- ret[:obsoleted][:when] = DateTime.parse(v_when.value)
211
- end
212
- end
213
- end
214
- if (reachable = contact.xpath('frnic:reachable', EPPClient::SCHEMAS_URL)).size > 0
215
- if reachable.text != '0'
216
- ret[:reachable] = {}
217
- if v_when = reachable.attr('when')
218
- ret[:reachable][:when] = DateTime.parse(v_when.value)
219
- end
220
- if media = reachable.attr('media')
221
- ret[:reachable][:media] = media.value
222
- end
223
- if source = reachable.attr('source')
224
- ret[:reachable][:source] = source.value
225
- end
226
- end
227
- end
186
+ if (list = contact.xpath('frnic:list', EPPClient::SCHEMAS_URL)).size > 0
187
+ ret[:list] = list.map(&:text)
188
+ end
189
+ if (firstName = contact.xpath('frnic:firstName', EPPClient::SCHEMAS_URL)).size > 0
190
+ ret[:firstName] = firstName.text
191
+ end
192
+ if (iI = contact.xpath('frnic:individualInfos', EPPClient::SCHEMAS_URL)).size > 0
193
+ ret[:individualInfos] = {}
194
+ ret[:individualInfos][:birthDate] = Date.parse(iI.xpath('frnic:birthDate', EPPClient::SCHEMAS_URL).text)
195
+ if (r = iI.xpath('frnic:idStatus', EPPClient::SCHEMAS_URL)).size > 0
196
+ ret[:individualInfos][:idStatus] = { :value => r.text }
197
+ ret[:individualInfos][:idStatus][:when] = r.attr('when').value if r.attr('when')
198
+ ret[:individualInfos][:idStatus][:source] = r.attr('source').value if r.attr('source')
199
+ end
200
+ %w(birthCity birthPc birthCc).each do |val|
201
+ if (r = iI.xpath("frnic:#{val}", EPPClient::SCHEMAS_URL)).size > 0
202
+ ret[:individualInfos][val.to_sym] = r.text
203
+ end
204
+ end
205
+ end
206
+ if (leI = contact.xpath('frnic:legalEntityInfos', EPPClient::SCHEMAS_URL)).size > 0
207
+ ret[:legalEntityInfos] = legalEntityInfos(leI)
208
+ end
209
+ if (obsoleted = contact.xpath('frnic:obsoleted', EPPClient::SCHEMAS_URL)).size > 0
210
+ if obsoleted.text != '0'
211
+ ret[:obsoleted] = {}
212
+ if (v_when = obsoleted.attr('when'))
213
+ ret[:obsoleted][:when] = DateTime.parse(v_when.value)
214
+ end
215
+ end
216
+ end
217
+ if (reachable = contact.xpath('frnic:reachable', EPPClient::SCHEMAS_URL)).size > 0
218
+ if reachable.text != '0'
219
+ ret[:reachable] = {}
220
+ if (v_when = reachable.attr('when'))
221
+ ret[:reachable][:when] = DateTime.parse(v_when.value)
222
+ end
223
+ if (media = reachable.attr('media'))
224
+ ret[:reachable][:media] = media.value
225
+ end
226
+ if (source = reachable.attr('source'))
227
+ ret[:reachable][:source] = source.value
228
+ end
229
+ end
230
+ end
228
231
  end
229
232
  ret
230
233
  end
@@ -233,65 +236,55 @@ module EPPClient
233
236
  ret = super
234
237
 
235
238
  ext = extension do |xml|
236
- xml.ext( :xmlns => EPPClient::SCHEMAS_URL['frnic']) do
237
- xml.create do
238
- xml.contact do
239
- if contact.key?(:legalEntityInfos)
240
- lEI = contact[:legalEntityInfos]
241
- xml.legalEntityInfos do
242
- xml.idStatus(lEI[:idStatus]) if lEI.key?(:idStatus)
243
- xml.legalStatus(:s => lEI[:legalStatus])
244
- [:siren, :VAT, :trademark, :DUNS, :local].each do |val|
245
- if lEI.key?(val)
246
- xml.__send__(val, lEI[val])
247
- end
248
- end
249
- if lEI.key?(:asso)
250
- asso = lEI[:asso]
251
- xml.asso do
252
- if asso.key?(:waldec)
253
- xml.waldec(asso[:waldec])
254
- else
255
- xml.decl(asso[:decl]) if asso.key?(:decl)
256
- attrs = {:page => asso[:publ][:page]}
257
- attrs[:announce] = asso[:publ][:announce] if asso[:publ].key?(:announce)
258
- xml.publ(attrs, asso[:publ][:date])
259
- end
260
- end
261
- end
262
- end
263
- else
264
- if contact.key?(:list)
265
- xml.list(contact[:list])
266
- end
267
- if contact.key?(:individualInfos)
268
- iI = contact[:individualInfos]
269
- xml.individualInfos do
270
- xml.idStatus(iI[:idStatus]) if iI.key?(:idStatus)
271
- xml.birthDate(iI[:birthDate])
272
- if iI.key?(:birthCity)
273
- xml.birthCity(iI[:birthCity])
274
- end
275
- if iI.key?(:birthPc)
276
- xml.birthPc(iI[:birthPc])
277
- end
278
- xml.birthCc(iI[:birthCc])
279
- end
280
- end
281
- if contact.key?(:firstName)
282
- xml.firstName(contact[:firstName])
283
- end
284
- end
285
- if contact.key?(:reachable)
286
- if Hash === (reachable = contact[:reachable])
287
- xml.reachable(reachable, 1)
288
- else
289
- raise ArgumentError, "reachable has to be a Hash"
290
- end
291
- end
292
- end
293
- end
294
- end
239
+ xml.ext(:xmlns => EPPClient::SCHEMAS_URL['frnic']) do
240
+ xml.create do
241
+ xml.contact do
242
+ if contact.key?(:legalEntityInfos)
243
+ lEI = contact[:legalEntityInfos]
244
+ xml.legalEntityInfos do
245
+ xml.idStatus(lEI[:idStatus]) if lEI.key?(:idStatus)
246
+ xml.legalStatus(:s => lEI[:legalStatus])
247
+ [:siren, :VAT, :trademark, :DUNS, :local].each do |val|
248
+ xml.__send__(val, lEI[val]) if lEI.key?(val)
249
+ end
250
+ if lEI.key?(:asso)
251
+ asso = lEI[:asso]
252
+ xml.asso do
253
+ if asso.key?(:waldec)
254
+ xml.waldec(asso[:waldec])
255
+ else
256
+ xml.decl(asso[:decl]) if asso.key?(:decl)
257
+ attrs = { :page => asso[:publ][:page] }
258
+ attrs[:announce] = asso[:publ][:announce] if asso[:publ].key?(:announce)
259
+ xml.publ(attrs, asso[:publ][:date])
260
+ end
261
+ end
262
+ end
263
+ end
264
+ else
265
+ xml.list(contact[:list]) if contact.key?(:list)
266
+ if contact.key?(:individualInfos)
267
+ iI = contact[:individualInfos]
268
+ xml.individualInfos do
269
+ xml.idStatus(iI[:idStatus]) if iI.key?(:idStatus)
270
+ xml.birthDate(iI[:birthDate])
271
+ xml.birthCity(iI[:birthCity]) if iI.key?(:birthCity)
272
+ xml.birthPc(iI[:birthPc]) if iI.key?(:birthPc)
273
+ xml.birthCc(iI[:birthCc])
274
+ end
275
+ end
276
+ xml.firstName(contact[:firstName]) if contact.key?(:firstName)
277
+ end
278
+ if contact.key?(:reachable)
279
+ reachable = contact[:reachable]
280
+
281
+ fail ArgumentError, 'reachable has to be a Hash' unless reachable.is_a?(Hash)
282
+
283
+ xml.reachable(reachable, 1)
284
+ end
285
+ end
286
+ end
287
+ end
295
288
  end
296
289
 
297
290
  insert_extension(ret, ext)
@@ -370,8 +363,8 @@ module EPPClient
370
363
  def contact_create_process(xml) #:nodoc:
371
364
  ret = super
372
365
  if (creData = xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:creData', EPPClient::SCHEMAS_URL)).size > 0
373
- ret[:nhStatus] = creData.xpath('frnic:nhStatus', EPPClient::SCHEMAS_URL).attr('new').value == '1'
374
- ret[:idStatus] = creData.xpath('frnic:idStatus', EPPClient::SCHEMAS_URL).text
366
+ ret[:nhStatus] = creData.xpath('frnic:nhStatus', EPPClient::SCHEMAS_URL).attr('new').value == '1'
367
+ ret[:idStatus] = creData.xpath('frnic:idStatus', EPPClient::SCHEMAS_URL).text
375
368
  end
376
369
  ret
377
370
  end
@@ -380,52 +373,45 @@ module EPPClient
380
373
  # <tt>:ns</tt>, <tt>:dsData</tt> or <tt>:keyData</tt> records, AFNIC's
381
374
  # servers sends quite a strange error when there is.
382
375
  def domain_create(args)
383
- raise ArgumentError, "You can't create a domain with ns records, you must do an update afterwards" if args.key?(:ns)
384
- raise ArgumentError, "You can't create a domain with ds or key records, you must do an update afterwards" if args.key?(:dsData) || args.key?(:keyData)
376
+ fail ArgumentError, "You can't create a domain with ns records, you must do an update afterwards" if args.key?(:ns)
377
+ fail ArgumentError, "You can't create a domain with ds or key records, you must do an update afterwards" if args.key?(:dsData) || args.key?(:keyData)
385
378
  super
386
379
  end
387
380
 
388
381
  # Raises an exception, as contacts are deleted with a garbage collector.
389
- def contact_delete(args)
390
- raise NotImplementedError, "Contacts are deleted with a garbage collector"
382
+ def contact_delete(_args)
383
+ fail NotImplementedError, 'Contacts are deleted with a garbage collector'
391
384
  end
392
385
 
393
386
  def contact_update_xml(args) #:nodoc:
394
387
  ret = super
395
388
 
396
- if [:add, :rem].any? {|c| args.key?(c) && [:list, :reachable, :idStatus].any? {|k| args[c].key?(k)}}
397
- ext = extension do |xml|
398
- xml.ext( :xmlns => EPPClient::SCHEMAS_URL['frnic']) do
399
- xml.update do
400
- xml.contact do
401
- [:add, :rem].each do |c|
402
- if args.key?(c) && [:list, :reachable, :idStatus].any? {|k| args[c].key?(k)}
403
- xml.__send__(c) do
404
- if args[c].key?(:list)
405
- xml.list(args[c][:list])
406
- end
407
- if args[c].key?(:idStatus)
408
- xml.idStatus(args[c][:idStatus])
409
- end
410
- if args[c].key?(:reachable)
411
- if Hash === (reachable = args[c][:reachable])
412
- xml.reachable(reachable, 1)
413
- else
414
- raise ArgumentError, "reachable has to be a Hash"
415
- end
416
- end
417
- end
418
- end
419
- end
420
- end
421
- end
422
- end
423
- end
424
-
425
- return insert_extension(ret, ext)
426
- else
427
- return ret
389
+ return ret unless [:add, :rem].any? { |c| args.key?(c) && [:list, :reachable, :idStatus].any? { |k| args[c].key?(k) } }
390
+
391
+ ext = extension do |xml|
392
+ xml.ext(:xmlns => EPPClient::SCHEMAS_URL['frnic']) do
393
+ xml.update do
394
+ xml.contact do
395
+ [:add, :rem].each do |c|
396
+ next unless args.key?(c) && [:list, :reachable, :idStatus].any? { |k| args[c].key?(k) }
397
+ xml.__send__(c) do
398
+ xml.list(args[c][:list]) if args[c].key?(:list)
399
+ xml.idStatus(args[c][:idStatus]) if args[c].key?(:idStatus)
400
+ if args[c].key?(:reachable)
401
+ reachable = args[c][:reachable]
402
+
403
+ fail ArgumentError, 'reachable has to be a Hash' unless reachable.is_a?(Hash)
404
+
405
+ xml.reachable(reachable, 1)
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+ end
428
412
  end
413
+
414
+ insert_extension(ret, ext)
429
415
  end
430
416
 
431
417
  # Extends the EPPClient::Contact#contact_update so that the specific AFNIC
@@ -455,18 +441,18 @@ module EPPClient
455
441
  # * update status & authInfo
456
442
  def domain_update(args)
457
443
  if args.key?(:chg) && args[:chg].key?(:registrant)
458
- raise ArgumentError, "You need to do a trade or recover operation to change the registrant"
444
+ fail ArgumentError, 'You need to do a trade or recover operation to change the registrant'
459
445
  end
460
446
  has_contacts = args.key?(:add) && args[:add].key?(:contacts) || args.key?(:add) && args[:add].key?(:contacts)
461
447
  has_ns = args.key?(:add) && args[:add].key?(:ns) || args.key?(:add) && args[:add].key?(:ns)
462
448
  has_other = args.key?(:add) && args[:add].key?(:status) || args.key?(:add) && args[:add].key?(:status) || args.key?(:chg) && args[:chg].key?(:authInfo)
463
- if [has_contacts, has_ns, has_other].select {|v| v}.size > 1
464
- raise ArgumentError, "You can't update all that at one time"
449
+ if [has_contacts, has_ns, has_other].count { |v| v } > 1
450
+ fail ArgumentError, "You can't update all that at one time"
465
451
  end
466
452
  [:add, :rem].each do |ar|
467
- if args.key?(ar) && args[ar].key?(:ns) && String === args[ar][:ns].first
468
- args[ar][:ns] = args[ar][:ns].map {|ns| {:hostName => ns}}
469
- end
453
+ if args.key?(ar) && args[ar].key?(:ns) && args[ar][:ns].first.is_a?(String)
454
+ args[ar][:ns] = args[ar][:ns].map { |ns| { :hostName => ns } }
455
+ end
470
456
  end
471
457
  super
472
458
  end
@@ -481,20 +467,20 @@ module EPPClient
481
467
 
482
468
  def contact_afnic_qualification(xml) #:nodoc:
483
469
  contact = xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:quaData/frnic:contact', EPPClient::SCHEMAS_URL)
484
- ret = {:id => contact.xpath('frnic:id', EPPClient::SCHEMAS_URL).text}
470
+ ret = { :id => contact.xpath('frnic:id', EPPClient::SCHEMAS_URL).text }
485
471
  qP = contact.xpath('frnic:qualificationProcess', EPPClient::SCHEMAS_URL)
486
- ret[:qualificationProcess] = {:s => qP.attr('s').value}
472
+ ret[:qualificationProcess] = { :s => qP.attr('s').value }
487
473
  ret[:qualificationProcess][:lang] = qP.attr('lang').value if qP.attr('lang')
488
474
  if (leI = contact.xpath('frnic:legalEntityInfos', EPPClient::SCHEMAS_URL)).size > 0
489
- ret[:legalEntityInfos] = legalEntityInfos(leI)
475
+ ret[:legalEntityInfos] = legalEntityInfos(leI)
490
476
  end
491
477
  reach = contact.xpath('frnic:reachability', EPPClient::SCHEMAS_URL)
492
- ret[:reachability] = {:reStatus => reach.xpath('frnic:reStatus', EPPClient::SCHEMAS_URL).text}
478
+ ret[:reachability] = { :reStatus => reach.xpath('frnic:reStatus', EPPClient::SCHEMAS_URL).text }
493
479
  if (voice = reach.xpath('frnic:voice', EPPClient::SCHEMAS_URL)).size > 0
494
- ret[:reachability][:voice] = voice.text
480
+ ret[:reachability][:voice] = voice.text
495
481
  end
496
482
  if (email = reach.xpath('frnic:email', EPPClient::SCHEMAS_URL)).size > 0
497
- ret[:reachability][:email] = email.text
483
+ ret[:reachability][:email] = email.text
498
484
  end
499
485
  ret
500
486
  end
@@ -504,23 +490,23 @@ module EPPClient
504
490
  def domain_afnic_trade_response(xml) #:nodoc:
505
491
  dom = xml.xpath('epp:extension/frnic:ext/frnic:resData/frnic:trdData/frnic:domain', EPPClient::SCHEMAS_URL)
506
492
  ret = {
507
- :name => dom.xpath('frnic:name', EPPClient::SCHEMAS_URL).text,
508
- :trStatus => dom.xpath('frnic:trStatus', EPPClient::SCHEMAS_URL).text,
509
- :reID => dom.xpath('frnic:reID', EPPClient::SCHEMAS_URL).text,
510
- :reDate => DateTime.parse(dom.xpath('frnic:reDate', EPPClient::SCHEMAS_URL).text),
511
- :acID => dom.xpath('frnic:acID', EPPClient::SCHEMAS_URL).text,
493
+ :name => dom.xpath('frnic:name', EPPClient::SCHEMAS_URL).text,
494
+ :trStatus => dom.xpath('frnic:trStatus', EPPClient::SCHEMAS_URL).text,
495
+ :reID => dom.xpath('frnic:reID', EPPClient::SCHEMAS_URL).text,
496
+ :reDate => DateTime.parse(dom.xpath('frnic:reDate', EPPClient::SCHEMAS_URL).text),
497
+ :acID => dom.xpath('frnic:acID', EPPClient::SCHEMAS_URL).text,
512
498
  }
513
499
 
514
500
  # FIXME: there are discrepencies between the 1.2 xmlschema, the documentation and the reality, I'm trying to stick to reality here.
515
501
  %w(reHldID acHldID).each do |f|
516
- if (field = dom.xpath("frnic:#{f}", EPPClient::SCHEMAS_URL)).size > 0
517
- ret[f.to_sym] = field.text
518
- end
502
+ if (field = dom.xpath("frnic:#{f}", EPPClient::SCHEMAS_URL)).size > 0
503
+ ret[f.to_sym] = field.text
504
+ end
519
505
  end
520
506
  %w(rhDate ahDate).each do |f|
521
- if (field = dom.xpath("frnic:#{f}", EPPClient::SCHEMAS_URL)).size > 0
522
- ret[f.to_sym] = DateTime.parse(field.text)
523
- end
507
+ if (field = dom.xpath("frnic:#{f}", EPPClient::SCHEMAS_URL)).size > 0
508
+ ret[f.to_sym] = DateTime.parse(field.text)
509
+ end
524
510
  end
525
511
  ret
526
512
  end