epp-eis 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +5 -0
  3. data/Guardfile +5 -0
  4. data/README.markdown +57 -0
  5. data/Rakefile +1 -0
  6. data/epp-eis.gemspec +25 -0
  7. data/lib/epp-eis/contact.rb +271 -0
  8. data/lib/epp-eis/domain.rb +410 -0
  9. data/lib/epp-eis/extensions.rb +22 -0
  10. data/lib/epp-eis/nsset.rb +246 -0
  11. data/lib/epp-eis/session.rb +94 -0
  12. data/lib/epp-eis/version.rb +5 -0
  13. data/lib/epp-eis.rb +8 -0
  14. data/spec/legaldocs/test.pdf +0 -0
  15. data/spec/lib/epp-eis/contact_spec.rb +107 -0
  16. data/spec/lib/epp-eis/domain_spec.rb +189 -0
  17. data/spec/lib/epp-eis/nsset_spec.rb +87 -0
  18. data/spec/lib/epp-eis/session_spec.rb +18 -0
  19. data/spec/spec_helper.rb +10 -0
  20. data/spec/support/file_mocks.rb +7 -0
  21. data/spec/xml/requests/contact/check_contact.xml +11 -0
  22. data/spec/xml/requests/contact/create_contact.xml +23 -0
  23. data/spec/xml/requests/contact/delete_contact.xml +11 -0
  24. data/spec/xml/requests/contact/info_contact.xml +11 -0
  25. data/spec/xml/requests/contact/update_contact.xml +29 -0
  26. data/spec/xml/requests/domain/create_domain.xml +21 -0
  27. data/spec/xml/requests/domain/delete_domain.xml +16 -0
  28. data/spec/xml/requests/domain/get_results.xml +9 -0
  29. data/spec/xml/requests/domain/list_domains.xml +9 -0
  30. data/spec/xml/requests/domain/transfer_domain.xml +17 -0
  31. data/spec/xml/requests/domain/update_domain.xml +28 -0
  32. data/spec/xml/requests/nsset/check_nsset.xml +12 -0
  33. data/spec/xml/requests/nsset/create_nsset.xml +20 -0
  34. data/spec/xml/requests/nsset/delete_nsset.xml +11 -0
  35. data/spec/xml/requests/nsset/info_nsset.xml +11 -0
  36. data/spec/xml/requests/nsset/update_nsset.xml +22 -0
  37. data/spec/xml/requests/session/hello.xml +4 -0
  38. data/spec/xml/responses/contact/check_contact_1000.xml +23 -0
  39. data/spec/xml/responses/contact/create_contact_1000.xml +18 -0
  40. data/spec/xml/responses/contact/delete_contact_1000.xml +12 -0
  41. data/spec/xml/responses/contact/get_results_list_contacts_1000.xml +24 -0
  42. data/spec/xml/responses/contact/info_contact_1000.xml +35 -0
  43. data/spec/xml/responses/contact/update_contact_1000.xml +12 -0
  44. data/spec/xml/responses/domain/check_domain_1000.xml +23 -0
  45. data/spec/xml/responses/domain/check_domain_available_1000.xml +19 -0
  46. data/spec/xml/responses/domain/check_domain_taken_1000.xml +20 -0
  47. data/spec/xml/responses/domain/create_domain_1000.xml +19 -0
  48. data/spec/xml/responses/domain/delete_domain_1000.xml +12 -0
  49. data/spec/xml/responses/domain/get_results_list_domains_1000.xml +18 -0
  50. data/spec/xml/responses/domain/info_domain_1000.xml +27 -0
  51. data/spec/xml/responses/domain/list_domains_1000.xml +17 -0
  52. data/spec/xml/responses/domain/renew_domain_1000.xml +18 -0
  53. data/spec/xml/responses/domain/transfer_domain_1000.xml +12 -0
  54. data/spec/xml/responses/domain/update_domain_1000.xml +12 -0
  55. data/spec/xml/responses/nsset/check_nsset_1000.xml +22 -0
  56. data/spec/xml/responses/nsset/create_nsset_1000.xml +18 -0
  57. data/spec/xml/responses/nsset/delete_nsset_1000.xml +12 -0
  58. data/spec/xml/responses/nsset/info_nsset_1000.xml +33 -0
  59. data/spec/xml/responses/nsset/update_nsset_1000.xml +12 -0
  60. data/spec/xml/responses/session/hello.xml +36 -0
  61. metadata +214 -0
@@ -0,0 +1,410 @@
1
+ module Epp
2
+ module Eis
3
+
4
+ XML_NS_DOMAIN = 'http://www.nic.cz/xml/epp/domain-1.4'
5
+
6
+ XML_SCHEMALOC = 'http://www.nic.cz/xml/epp/domain-1.4.xsd domain-1.4.xsd'
7
+
8
+ class DomainCreateResponse
9
+ def initialize(response)
10
+ @response = Nokogiri::XML(response)
11
+ end
12
+
13
+ def code
14
+ @response.css('epp response result').first['code'].to_i
15
+ end
16
+
17
+ def message
18
+ @response.css('epp response result msg').text
19
+ end
20
+
21
+ def domain_name
22
+ @response.css('domain|creData domain|name', 'domain' => XML_NS_DOMAIN).text
23
+ end
24
+
25
+ def domain_create_date
26
+ @response.css('domain|creData domain|crDate', 'domain' => XML_NS_DOMAIN).text
27
+ end
28
+
29
+ def domain_expire_date
30
+ @response.css('domain|creData domain|exDate', 'domain' => XML_NS_DOMAIN).text
31
+ end
32
+ end
33
+
34
+ class DomainDeleteResponse
35
+ def initialize(response)
36
+ @response = Nokogiri::XML(response)
37
+ end
38
+
39
+ def code
40
+ @response.css('epp response result').first['code'].to_i
41
+ end
42
+
43
+ def message
44
+ @response.css('epp response result msg').text
45
+ end
46
+ end
47
+
48
+ class DomainTransferResponse
49
+ def initialize(response)
50
+ @response = Nokogiri::XML(response)
51
+ end
52
+
53
+ def code
54
+ @response.css('epp response result').first['code'].to_i
55
+ end
56
+
57
+ def message
58
+ @response.css('epp response result msg').text
59
+ end
60
+ end
61
+
62
+ class DomainUpdateResponse
63
+ def initialize(response)
64
+ @response = Nokogiri::XML(response)
65
+ end
66
+
67
+ def code
68
+ @response.css('epp response result').first['code'].to_i
69
+ end
70
+
71
+ def message
72
+ @response.css('epp response result msg').text
73
+ end
74
+ end
75
+
76
+ class DomainInfoResponse
77
+ def initialize(response)
78
+ @response = Nokogiri::XML(response)
79
+ end
80
+
81
+ def code
82
+ @response.css('epp response result').first['code'].to_i
83
+ end
84
+
85
+ def message
86
+ @response.css('epp response result msg').text
87
+ end
88
+
89
+ def domain_name
90
+ @response.css('domain|infData domain|name', 'domain' => XML_NS_DOMAIN).text
91
+ end
92
+
93
+ def domain_roid
94
+ @response.css('domain|infData domain|roid', 'domain' => XML_NS_DOMAIN).text
95
+ end
96
+
97
+ def domain_status
98
+ @response.css('domain|infData domain|status', 'domain' => XML_NS_DOMAIN).text
99
+ end
100
+
101
+ def domain_registrant
102
+ @response.css('domain|infData domain|registrant', 'domain' => XML_NS_DOMAIN).text
103
+ end
104
+
105
+ def domain_admin
106
+ @response.css('domain|infData domain|admin', 'domain' => XML_NS_DOMAIN).text
107
+ end
108
+
109
+ def domain_nsset
110
+ @response.css('domain|infData domain|nsset', 'domain' => XML_NS_DOMAIN).text
111
+ end
112
+
113
+ def domain_clid
114
+ @response.css('domain|infData domain|clID', 'domain' => XML_NS_DOMAIN).text
115
+ end
116
+
117
+ def domain_crid
118
+ @response.css('domain|infData domain|crID', 'domain' => XML_NS_DOMAIN).text
119
+ end
120
+
121
+ def domain_create_date
122
+ @response.css('domain|infData domain|crDate', 'domain' => XML_NS_DOMAIN).text
123
+ end
124
+
125
+ def domain_expire_date
126
+ @response.css('domain|infData domain|exDate', 'domain' => XML_NS_DOMAIN).text
127
+ end
128
+
129
+ def domain_authinfo
130
+ @response.css('domain|infData domain|authInfo', 'domain' => XML_NS_DOMAIN).text
131
+ end
132
+ end
133
+
134
+ class DomainRenewResponse
135
+ def initialize(response)
136
+ @response = Nokogiri::XML(response)
137
+ end
138
+
139
+ def code
140
+ @response.css('epp response result').first['code'].to_i
141
+ end
142
+
143
+ def message
144
+ @response.css('epp response result msg').text
145
+ end
146
+
147
+ def domain_name
148
+ @response.css('domain|renData domain|name', 'domain' => XML_NS_DOMAIN).text
149
+ end
150
+
151
+ def domain_expire_date
152
+ @response.css('domain|renData domain|exDate', 'domain' => XML_NS_DOMAIN).text
153
+ end
154
+ end
155
+
156
+ class DomainCheck
157
+ attr_accessor :name, :available, :reason
158
+
159
+ def initialize(name, available, reason)
160
+ @name = name
161
+ @available = available
162
+ @reason = reason
163
+ end
164
+
165
+ def available?
166
+ @available
167
+ end
168
+ end
169
+
170
+ class DomainCheckResponse
171
+
172
+ def initialize(response)
173
+ @response = Nokogiri::XML(response)
174
+ end
175
+
176
+ def code
177
+ @response.css('epp response result').first['code'].to_i
178
+ end
179
+
180
+ def message
181
+ @response.css('epp response result msg').text
182
+ end
183
+
184
+ def items
185
+ @response.css('domain|chkData domain|cd', 'domain' => XML_NS_DOMAIN).collect do |domain|
186
+ DomainCheck.new(
187
+ domain.css('domain|name', 'domain' => XML_NS_DOMAIN).text,
188
+ domain.css('domain|name', 'domain' => XML_NS_DOMAIN).first['avail'].to_i == 1,
189
+ domain.css('domain|reason', 'domain' => XML_NS_DOMAIN).text
190
+ )
191
+ end
192
+ end
193
+ end
194
+
195
+ module DomainCommands
196
+
197
+ # Create a new domain.
198
+ #
199
+ # Domain names with IDN characters õ, ä. ö. ü, š, ž will be allowed. If a domain name contains at least one of
200
+ # these characters then it must be translated to PUNYCODE before domain create.
201
+ #
202
+ # domain - Domain name to be registered
203
+ # nsset - Nameserver id
204
+ # registrant - Registrant contact id
205
+ # admin - Admin contact id, or array of id-s
206
+ # legal_document - Legal document binary data
207
+ # legal_doc_type - Legal document type (pdf, ddoc)
208
+ #
209
+ # Returns DomainCreateResponse object
210
+ def create_domain(domain, nsset, registrant, admins, legal_document, legal_doc_type)
211
+ builder = build_epp_request do |xml|
212
+ xml.command {
213
+ xml.create {
214
+ xml.create('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
215
+ xml.parent.namespace = xml.parent.namespace_definitions.first
216
+ xml.name domain
217
+ xml.period '1', 'unit' => 'y'
218
+ xml.nsset nsset
219
+ xml.registrant registrant
220
+ [admins].flatten.each { |admin| xml.admin admin }
221
+ }
222
+ }
223
+ add_legal_document(xml, legal_document, legal_doc_type)
224
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
225
+ }
226
+ end
227
+
228
+ DomainCreateResponse.new(send_request(builder.to_xml))
229
+ end
230
+
231
+ # Delete domain.
232
+ #
233
+ # domain - Domain name to be registered
234
+ # legal_document - Legal document binary data
235
+ # legal_doc_type - Legal document type (pdf, ddoc)
236
+ #
237
+ # Returns DomainDeleteResponse object
238
+ def delete_domain(domain, legal_document, legal_doc_type)
239
+ builder = build_epp_request do |xml|
240
+ xml.command {
241
+ xml.delete {
242
+ xml.delete('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
243
+ xml.parent.namespace = xml.parent.namespace_definitions.first
244
+ xml.name domain
245
+ }
246
+ }
247
+ add_legal_document(xml, legal_document, legal_doc_type)
248
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
249
+ }
250
+ end
251
+
252
+ DomainDeleteResponse.new(send_request(builder.to_xml))
253
+ end
254
+
255
+ # Will return detailed information about the domain. The information will include domain password field. The field
256
+ # will be populated with a real value if the domain owner executed the function. Non-owner will see empty domain
257
+ # password field value.
258
+ #
259
+ # domain - Domain name to be queried
260
+ #
261
+ # Returns DomainInfoResponse object
262
+ def info_domain(domain)
263
+ builder = build_epp_request do |xml|
264
+ xml.command {
265
+ xml.info {
266
+ xml.info('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
267
+ xml.parent.namespace = xml.parent.namespace_definitions.first
268
+ xml.name domain
269
+ }
270
+ }
271
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
272
+ }
273
+ end
274
+
275
+ DomainInfoResponse.new(send_request(builder.to_xml))
276
+ end
277
+
278
+ # Updates domain expiration period for another year.
279
+ #
280
+ # domain - Domain to be renewed
281
+ # current_expire_date - Current expiration date of the domain in YYYY-MM-DD format
282
+ #
283
+ # Returns DomainRenewResponse object with server response information
284
+ def renew_domain(domain, current_expire_date)
285
+ builder = build_epp_request do |xml|
286
+ xml.command {
287
+ xml.renew {
288
+ xml.renew('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
289
+ xml.parent.namespace = xml.parent.namespace_definitions.first
290
+ xml.name domain
291
+ xml.curExpDate current_expire_date
292
+ xml.period '1', 'unit' => 'y'
293
+ }
294
+ }
295
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
296
+ }
297
+ end
298
+
299
+ DomainRenewResponse.new(send_request(builder.to_xml))
300
+ end
301
+
302
+ # Used to transfer domain ownership from one registrar to another.
303
+ #
304
+ # domain - Name of the domain to be transferred
305
+ # auth_info - Domain authorization code
306
+ #
307
+ # Returns DomainTransferResponse object
308
+ def transfer_domain(domain, auth_info, legal_document, legal_doc_type)
309
+ builder = build_epp_request do |xml|
310
+ xml.command {
311
+ xml.transfer('op' => 'request') {
312
+ xml.transfer('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
313
+ xml.parent.namespace = xml.parent.namespace_definitions.first
314
+ xml.name domain
315
+ xml.authInfo auth_info
316
+ }
317
+ }
318
+ add_legal_document(xml, legal_document, legal_doc_type)
319
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
320
+ }
321
+ end
322
+
323
+ DomainTransferResponse.new(send_request(builder.to_xml))
324
+ end
325
+
326
+ # Used to update domain information.
327
+ #
328
+ # domain - Domain name to be updated
329
+ # add_admins - Array of admin contact ids to be added. Set to nil or empty array if no changes needed
330
+ # rem_admins - Array of admin contact ids to be removed. Set to nil or empty array if no changes needed
331
+ # nsset - Domain nsset id to be changed. Set to nil if no changes needed
332
+ # registrant - Domain registrant contact id to be changed. Set to nil if no changes needed
333
+ # auth_info - Domain authorization code to be changed. Set to nil if no changes needed
334
+ # legal_document - Legal document binary data
335
+ # legal_doc_type - Legal document type (pdf, ddoc)
336
+ #
337
+ # Returns DomainUpdateResponse object
338
+ def update_domain(domain, add_admins, rem_admins, nsset, registrant, auth_info, legal_document, legal_doc_type)
339
+ builder = build_epp_request do |xml|
340
+ xml.command {
341
+ xml.update {
342
+ xml.update('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
343
+ xml.parent.namespace = xml.parent.namespace_definitions.first
344
+ xml.name domain
345
+ if !add_admins.nil? && !add_admins.empty?
346
+ xml.add {
347
+ add_admins.each { |add_admin| xml.admin add_admin }
348
+ }
349
+ end
350
+ if !rem_admins.nil? && !rem_admins.empty?
351
+ xml.rem {
352
+ rem_admins.each { |rem_admin| xml.admin rem_admin }
353
+ }
354
+ end
355
+ if [nsset, registrant, auth_info].any?{ |item| !item.nil? }
356
+ xml.chg {
357
+ xml.nsset nsset if nsset
358
+ xml.registrant registrant if registrant
359
+ xml.auth_info auth_info if auth_info
360
+ }
361
+ end
362
+ }
363
+ }
364
+ add_legal_document(xml, legal_document, legal_doc_type)
365
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
366
+ }
367
+ end
368
+
369
+ DomainUpdateResponse.new(send_request(builder.to_xml))
370
+ end
371
+
372
+ def list_domains
373
+ list_command('listDomains')
374
+ end
375
+
376
+ # Check availability for a domain or a list of domains.
377
+ #
378
+ # Returns DomainCheckResponse object with server response information
379
+ def check_domain(*domains)
380
+ builder = build_epp_request do |xml|
381
+ xml.command {
382
+ xml.check {
383
+ xml.check('xmlns:domain' => XML_NS_DOMAIN, 'xsi:schemaLocation' => XML_SCHEMALOC) {
384
+ xml.parent.namespace = xml.parent.namespace_definitions.first
385
+ domains.each do |domain|
386
+ xml.name domain
387
+ end
388
+ }
389
+ }
390
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
391
+ }
392
+ end
393
+
394
+ DomainCheckResponse.new(send_request(builder.to_xml))
395
+ end
396
+
397
+ # Shortcut function to check whether domain is available.
398
+ #
399
+ # domain - Domain name to be checked
400
+ #
401
+ # Returns true if domain is available and false if it is not.
402
+ def is_domain_available?(domain)
403
+ results = check_domain(domain).items
404
+ results.nil? ? false : results.first.available?
405
+ end
406
+ end
407
+ end
408
+ end
409
+
410
+ Epp::Server.send(:include, Epp::Eis::DomainCommands)
@@ -0,0 +1,22 @@
1
+ require 'base64'
2
+
3
+ # EIS specific EPP extensions
4
+ module Epp
5
+ module Eis
6
+ module EisExtensions
7
+
8
+ private
9
+
10
+ def append_legal_document(xml, legal_document, legal_doc_type)
11
+ xml.extension {
12
+ xml.extdata('xmlns:eis' => 'urn:ee:eis:xml:epp:eis-1.0', 'xsi:schemaLocation' => 'urn:ee:eis:xml:epp:eis-1.0 eis-1.0.xsd') {
13
+ xml.parent.namespace = xml.parent.namespace_definitions.first
14
+ xml.legalDocument Base64.encode64(legal_document), 'type' => legal_doc_type
15
+ }
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ Epp::Server.send(:include, Epp::Eis::EisExtensions)
@@ -0,0 +1,246 @@
1
+ module Epp
2
+ module Eis
3
+
4
+ XML_NS_NSSET = 'http://www.nic.cz/xml/epp/nsset-1.2'
5
+
6
+ XML_SCHEMALOC = 'http://www.nic.cz/xml/epp/nsset-1.2 nsset-1.2.xsd'
7
+
8
+ class NssetCheck
9
+ attr_accessor :name, :available
10
+
11
+ def initialize(name, available)
12
+ @name = name
13
+ @available = available
14
+ end
15
+
16
+ def available?
17
+ @available
18
+ end
19
+ end
20
+
21
+ class NssetCheckResponse
22
+
23
+ def initialize(response)
24
+ @response = Nokogiri::XML(response)
25
+ end
26
+
27
+ def code
28
+ @response.css('epp response result').first['code'].to_i
29
+ end
30
+
31
+ def message
32
+ @response.css('epp response result msg').text
33
+ end
34
+
35
+ def items
36
+ @response.css('nsset|chkData nsset|cd', 'nsset' => XML_NS_NSSET).collect do |nsset|
37
+ NssetCheck.new(
38
+ nsset.css('nsset|id', 'nsset' => XML_NS_NSSET).text,
39
+ nsset.css('nsset|id', 'nsset' => XML_NS_NSSET).first['avail'].to_i == 1
40
+ )
41
+ end
42
+ end
43
+ end
44
+
45
+ class NssetCreateResponse
46
+ def initialize(response)
47
+ @response = Nokogiri::XML(response)
48
+ end
49
+
50
+ def code
51
+ @response.css('epp response result').first['code'].to_i
52
+ end
53
+
54
+ def message
55
+ @response.css('epp response result msg').text
56
+ end
57
+
58
+ def nsset_id
59
+ @response.css('nsset|creData nsset|id', 'nsset' => XML_NS_NSSET).text
60
+ end
61
+
62
+ def nsset_create_date
63
+ @response.css('nsset|creData nsset|crDate', 'nsset' => XML_NS_NSSET).text
64
+ end
65
+ end
66
+
67
+ class NssetDeleteResponse
68
+ def initialize(response)
69
+ @response = Nokogiri::XML(response)
70
+ end
71
+
72
+ def code
73
+ @response.css('epp response result').first['code'].to_i
74
+ end
75
+
76
+ def message
77
+ @response.css('epp response result msg').text
78
+ end
79
+ end
80
+
81
+ class NssetInfoResponse
82
+ def initialize(response)
83
+ @response = Nokogiri::XML(response)
84
+ end
85
+
86
+ def code
87
+ @response.css('epp response result').first['code'].to_i
88
+ end
89
+
90
+ def message
91
+ @response.css('epp response result msg').text
92
+ end
93
+
94
+ def nsset_id
95
+ @response.css('nsset|infData nsset|id', 'nsset' => XML_NS_NSSET).text
96
+ end
97
+
98
+ def nsset_roid
99
+ @response.css('nsset|infData nsset|roid', 'nsset' => XML_NS_NSSET).text
100
+ end
101
+
102
+ def nsset_status
103
+ @response.css('nsset|infData nsset|status', 'nsset' => XML_NS_NSSET).first['s']
104
+ end
105
+
106
+ def nameservers
107
+ @response.css('nsset|infData nsset|ns', 'nsset' => XML_NS_NSSET).inject(Array.new) do |memo, nsset|
108
+ memo << [nsset.css('nsset|name', 'nsset' => XML_NS_NSSET).text, nsset.css('nsset|addr', 'nsset' => XML_NS_NSSET).text]
109
+ end
110
+ end
111
+ end
112
+
113
+ class NssetUpdateResponse
114
+ def initialize(response)
115
+ @response = Nokogiri::XML(response)
116
+ end
117
+
118
+ def code
119
+ @response.css('epp response result').first['code'].to_i
120
+ end
121
+
122
+ def message
123
+ @response.css('epp response result msg').text
124
+ end
125
+ end
126
+
127
+ module NssetCommands
128
+
129
+ # Check availability for a nsset identification.
130
+ def check_nsset(*nssets)
131
+ builder = build_epp_request do |xml|
132
+ xml.command {
133
+ xml.check {
134
+ xml.check('xmlns:nsset' => XML_NS_NSSET, 'xsi:schemaLocation' => XML_SCHEMALOC) {
135
+ xml.parent.namespace = xml.parent.namespace_definitions.first
136
+ nssets.each { |nsset| xml.id_ nsset }
137
+ }
138
+ }
139
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
140
+ }
141
+ end
142
+
143
+ NssetCheckResponse.new(send_request(builder.to_xml))
144
+ end
145
+
146
+ # Create a new nameserver object
147
+ def create_nsset(nsset, nameservers, contact)
148
+ builder = build_epp_request do |xml|
149
+ xml.command {
150
+ xml.create {
151
+ xml.create('xmlns:nsset' => XML_NS_NSSET, 'xsi:schemaLocation' => XML_SCHEMALOC) {
152
+ xml.parent.namespace = xml.parent.namespace_definitions.first
153
+ xml.id_ nsset
154
+ nameservers.each do |nameserver|
155
+ xml.ns {
156
+ xml.name nameserver[0]
157
+ xml.addr nameserver[1]
158
+ }
159
+ end
160
+ xml.tech contact
161
+ }
162
+ }
163
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
164
+ }
165
+ end
166
+
167
+ NssetCreateResponse.new(send_request(builder.to_xml))
168
+ end
169
+
170
+ # Delete nameserver object. Can only be deleted if object does not have relations to other objects.
171
+ def delete_nsset(nsset)
172
+ builder = build_epp_request do |xml|
173
+ xml.command {
174
+ xml.delete {
175
+ xml.delete('xmlns:nsset' => XML_NS_NSSET, 'xsi:schemaLocation' => XML_SCHEMALOC) {
176
+ xml.parent.namespace = xml.parent.namespace_definitions.first
177
+ xml.id_ nsset
178
+ }
179
+ }
180
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
181
+ }
182
+ end
183
+
184
+ NssetDeleteResponse.new(send_request(builder.to_xml))
185
+ end
186
+
187
+ # Returns intormation about existing nameserver object.
188
+ def info_nsset(nsset)
189
+ builder = build_epp_request do |xml|
190
+ xml.command {
191
+ xml.info {
192
+ xml.info('xmlns:nsset' => XML_NS_NSSET, 'xsi:schemaLocation' => XML_SCHEMALOC) {
193
+ xml.parent.namespace = xml.parent.namespace_definitions.first
194
+ xml.id_ nsset
195
+ }
196
+ }
197
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
198
+ }
199
+ end
200
+
201
+ NssetInfoResponse.new(send_request(builder.to_xml))
202
+ end
203
+
204
+ def list_nssets
205
+ list_command('listNssets')
206
+ end
207
+
208
+ # Updates nameserver object. Update has been divided into three sections. Depending on the section that is used,
209
+ # update can add, remove and/or change data all at once.
210
+ def update_nsset(nsset, add_nameservers, add_contact, rem_nameserver, rem_contact)
211
+ builder = build_epp_request do |xml|
212
+ xml.command {
213
+ xml.update {
214
+ xml.update('xmlns:nsset' => XML_NS_NSSET, 'xsi:schemaLocation' => XML_SCHEMALOC) {
215
+ xml.parent.namespace = xml.parent.namespace_definitions.first
216
+ xml.id_ nsset
217
+ if add_nameservers or add_contact
218
+ xml.add {
219
+ add_nameservers.each do |nameserver|
220
+ xml.ns {
221
+ xml.name nameserver[0]
222
+ xml.addr nameserver[1]
223
+ }
224
+ end if add_nameservers
225
+ xml.tech add_contact if add_contact
226
+ }
227
+ end
228
+ if rem_nameserver or rem_contact
229
+ xml.rem {
230
+ xml.name rem_nameserver
231
+ xml.tech rem_contact
232
+ }
233
+ end
234
+ }
235
+ }
236
+ xml.clTRID UUIDTools::UUID.timestamp_create.to_s
237
+ }
238
+ end
239
+
240
+ NssetUpdateResponse.new(send_request(builder.to_xml))
241
+ end
242
+ end
243
+ end
244
+ end
245
+
246
+ Epp::Server.send(:include, Epp::Eis::NssetCommands)