nominet-epp 0.0.3 → 0.0.4

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.
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.0.4 / 2011-01-31
2
+ ==================
3
+
4
+ * Operations now cache their responses, accessible through `Client#last_response`
5
+ * Last response messages are available through `Client#last_message`
6
+
1
7
  0.0.3 / 2011-01-17
2
8
  ==================
3
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/lib/nominet-epp.rb CHANGED
@@ -28,6 +28,21 @@ module NominetEPP
28
28
  "#<#{self.class} #{@tag}@#{@server}>"
29
29
  end
30
30
 
31
+ # Returns the last EPP::Response received
32
+ #
33
+ # @return [EPP::Response] last received response
34
+ def last_response
35
+ @resp
36
+ end
37
+
38
+ # Returns the last EPP message received
39
+ #
40
+ # @return [String] last EPP message
41
+ # @see #last_response
42
+ def last_message
43
+ last_response.message
44
+ end
45
+
31
46
  # @return [Hash] Nominet Namespaces by prefixes
32
47
  def namespaces
33
48
  { :domain => 'http://www.nominet.org.uk/epp/xml/nom-domain-2.0',
@@ -9,7 +9,7 @@ module NominetEPP
9
9
  # @return [true] the domain name is available
10
10
  # @return [Hash<String,Boolean>] availability by domain name
11
11
  def check(*names)
12
- resp = @client.check do
12
+ @resp = @client.check do
13
13
  domain('check') do |node, ns|
14
14
  names.each do |name|
15
15
  node << XML::Node.new('name', name, ns)
@@ -17,10 +17,10 @@ module NominetEPP
17
17
  end
18
18
  end
19
19
 
20
- return false unless resp.success?
20
+ return false unless @resp.success?
21
21
 
22
- @check_limit = check_abuse_limit(resp.data)
23
- results = resp.data.find('//domain:name', namespaces)
22
+ @check_limit = check_abuse_limit(@resp.data)
23
+ results = @resp.data.find('//domain:name', namespaces)
24
24
  if results.size > 1
25
25
  hash = {}
26
26
  results.each {|node| hash[node.content.strip] = (node['avail'] == '1') }
@@ -37,7 +37,7 @@ module NominetEPP
37
37
  def create(name, acct, nameservers, options = {})
38
38
  raise ArgumentError, "options allowed keys are period, first_bill, recur_bill, auto_bill, next_bill, notes" unless (options.keys - [:period, :first_bill, :recur_bill, :auto_bill, :next_bill, :notes]).empty?
39
39
 
40
- resp = @client.create do
40
+ @resp = @client.create do
41
41
  domain('create') do |node, ns|
42
42
  node << XML::Node.new('name', name, ns)
43
43
 
@@ -55,9 +55,9 @@ module NominetEPP
55
55
  end
56
56
  end
57
57
 
58
- return false unless resp.success?
58
+ return false unless @resp.success?
59
59
 
60
- creData = resp.data.find('/domain:creData', namespaces).first
60
+ creData = @resp.data.find('/domain:creData', namespaces).first
61
61
  h = { :name => node_value(creData, 'domain:name'),
62
62
  :crDate => Time.parse(node_value(creData, 'domain:crDate')),
63
63
  :exDate => Time.parse(node_value(creData, 'domain:exDate')) }
@@ -7,13 +7,13 @@ module NominetEPP
7
7
  # @param [String] name Domain name
8
8
  # @return [Boolean] success status
9
9
  def delete(name)
10
- resp = @client.delete do
10
+ @resp = @client.delete do
11
11
  domain('delete') do |node, ns|
12
12
  node << XML::Node.new('name', name, ns)
13
13
  end
14
14
  end
15
15
 
16
- resp.success?
16
+ @resp.success?
17
17
  end
18
18
  end
19
19
  end
@@ -21,7 +21,7 @@ module NominetEPP
21
21
  # @return [false] fork failed
22
22
  # @return [Hash] new account details
23
23
  def fork(account_num, *names)
24
- resp = @client.update do
24
+ @resp = @client.update do
25
25
  account('fork') do |node, ns|
26
26
  node << XML::Node.new('roid', account_num, ns)
27
27
  names.each do |name|
@@ -30,19 +30,19 @@ module NominetEPP
30
30
  end
31
31
  end
32
32
 
33
- return false unless resp.success?
33
+ return false unless @resp.success?
34
34
 
35
35
  hash = {
36
- :roid => node_value(resp.data, '//account:creData/account:roid'),
37
- :name => node_value(resp.data, '//account:creData/account:name'),
38
- :crDate => node_value(resp.data, '//account:creData/account:crDate'),
36
+ :roid => node_value(@resp.data, '//account:creData/account:roid'),
37
+ :name => node_value(@resp.data, '//account:creData/account:name'),
38
+ :crDate => node_value(@resp.data, '//account:creData/account:crDate'),
39
39
  :contact => {
40
- :roid => node_value(resp.data, '//account:creData/account:contact/contact:creData/contact:roid'),
41
- :name => node_value(resp.data, '//account:creData/account:contact/contact:creData/contact:name')
40
+ :roid => node_value(@resp.data, '//account:creData/account:contact/contact:creData/contact:roid'),
41
+ :name => node_value(@resp.data, '//account:creData/account:contact/contact:creData/contact:name')
42
42
  }
43
43
  }
44
44
 
45
- contact = resp.data.find('//account:creData/account:contact', namespaces).first
45
+ contact = @resp.data.find('//account:creData/account:contact', namespaces).first
46
46
  hash[:contact][:type] = contact['type']
47
47
  hash[:contact][:order] = contact['order']
48
48
 
@@ -9,7 +9,7 @@ module NominetEPP
9
9
  def info(entity, id)
10
10
  raise ArgumentError, "entity must be :domain, :contact or :account" unless [:domain, :contact, :account].include?(entity)
11
11
 
12
- resp = @client.info do
12
+ @resp = @client.info do
13
13
  case entity
14
14
  when :domain
15
15
  domain('info') { |node, ns| node << XML::Node.new('name', id, ns) }
@@ -20,8 +20,8 @@ module NominetEPP
20
20
  end
21
21
  end
22
22
 
23
- return false unless resp.success?
24
- self.send(:"info_#{entity}", resp.data)
23
+ return false unless @resp.success?
24
+ self.send(:"info_#{entity}", @resp.data)
25
25
  end
26
26
 
27
27
  private
@@ -16,21 +16,21 @@ module NominetEPP
16
16
  raise ArgumentError, "type must be :expiry or :month" unless [:expiry, :month].include?(type)
17
17
 
18
18
  date = date.strftime("%Y-%m") if date.respond_to?(:strftime)
19
- resp = @client.info do
19
+ @resp = @client.info do
20
20
  domain('list') do |node, ns|
21
21
  node << XML::Node.new(type, date, ns)
22
22
  node << XML::Node.new('fields', fields, ns)
23
23
  end
24
24
  end
25
25
 
26
- return nil unless resp.success?
26
+ return nil unless @resp.success?
27
27
 
28
28
  if fields == 'none'
29
- resp.data.find('//domain:name', namespaces).map do |node|
29
+ @resp.data.find('//domain:name', namespaces).map do |node|
30
30
  node.content.strip
31
31
  end
32
32
  else
33
- resp.data.find('//domain:infData', namespaces).map do |infData|
33
+ @resp.data.find('//domain:infData', namespaces).map do |infData|
34
34
  hash = {}
35
35
  infData.children.reject{|n| n.empty?}.each do |node|
36
36
  key = node.name.gsub('-', '_').to_sym
@@ -14,7 +14,7 @@ module NominetEPP
14
14
  raise ArgumentError, "entity must be :domain or :account" unless [:domain, :account].include?(entity)
15
15
  raise ArgumentError, "type must be 'investigation' or 'opt-out'" unless %w(investigation opt-out).include?(type)
16
16
 
17
- resp = @client.update do
17
+ @resp = @client.update do
18
18
  case type
19
19
  when 'investigation'
20
20
  lock_investigation(entity, id)
@@ -23,7 +23,7 @@ module NominetEPP
23
23
  end
24
24
  end
25
25
 
26
- return resp.success?
26
+ return @resp.success?
27
27
  end
28
28
  private
29
29
  # Create +account:lock+ XML element for opt-out lock
@@ -12,7 +12,7 @@ module NominetEPP
12
12
  # @return [false] merge failed
13
13
  # @return [Response] merge succeded
14
14
  def merge(target, sources = {})
15
- resp = @client.update do
15
+ @resp = @client.update do
16
16
  account('merge') do |node, ns|
17
17
  node << XML::Node.new('roid', target, ns)
18
18
 
@@ -32,9 +32,9 @@ module NominetEPP
32
32
  end
33
33
  end
34
34
 
35
- return false unless resp.success?
35
+ return false unless @resp.success?
36
36
 
37
- resp # Need to test this to see what gets returned
37
+ @resp # Need to test this to see what gets returned
38
38
  end
39
39
  end
40
40
  end
@@ -2,6 +2,7 @@ module NominetEPP
2
2
  module Operations
3
3
  # EPP Poll Operation
4
4
  module Poll
5
+ # Error for indicating a failed poll ack response
5
6
  class AckError < RuntimeError; end
6
7
 
7
8
  # Poll the EPP server for events.
@@ -18,7 +18,7 @@ module NominetEPP
18
18
 
19
19
  raise ArgumentError, "period suffix must either be 'm' or 'y'" unless %w(m y).include?(unit)
20
20
 
21
- resp = @client.renew do
21
+ @resp = @client.renew do
22
22
  domain('renew') do |node, ns|
23
23
  node << XML::Node.new('name', name, ns)
24
24
  p = XML::Node.new('period', num, ns);
@@ -27,10 +27,10 @@ module NominetEPP
27
27
  end
28
28
  end
29
29
 
30
- return false unless resp.success?
30
+ return false unless @resp.success?
31
31
 
32
- renName = node_value(resp.data, '//domain:renData/domain:name')
33
- renExp = node_value(resp.data, '//domain:renData/domain:exDate')
32
+ renName = node_value(@resp.data, '//domain:renData/domain:name')
33
+ renExp = node_value(@resp.data, '//domain:renData/domain:exDate')
34
34
 
35
35
  raise "Renewed name #{renName} does not match #{name}" if renName != name
36
36
  return Time.parse(renExp)
@@ -24,13 +24,13 @@ module NominetEPP
24
24
  def transfer(type, *args)
25
25
  raise ArgumentError, "type must be :release, :approve, :reject" unless [:release, :approve, :reject].include?(type)
26
26
 
27
- resp = @client.transfer do |transfer|
27
+ @resp = @client.transfer do |transfer|
28
28
  transfer['op'] = type.to_s
29
29
  transfer << self.send(:"transfer_#{type}", *args)
30
30
  end
31
31
 
32
32
  if type == :release
33
- case resp.code
33
+ case @resp.code
34
34
  when 1000
35
35
  { :result => true }
36
36
  when 1001
@@ -39,8 +39,8 @@ module NominetEPP
39
39
  false
40
40
  end
41
41
  else
42
- return false unless resp.success?
43
- nCase, domainList = resp.data
42
+ return false unless @resp.success?
43
+ nCase, domainList = @resp.data
44
44
  { :case_id => node_value(nCase,'//n:Case/n:case-id'),
45
45
  :domains => domainList.find('//n:domain-name', namespaces).map{|n| n.content.strip} }
46
46
  end
@@ -14,7 +14,7 @@ module NominetEPP
14
14
  raise ArgumentError, "entity must be :domain or :account" unless [:domain, :account].include?(entity)
15
15
  raise ArgumentError, "type must be 'investigation' or 'opt-out'" unless %w(investigation opt-out).include?(type)
16
16
 
17
- resp = @client.update do
17
+ @resp = @client.update do
18
18
  case type
19
19
  when 'investigation'
20
20
  lock_investigation(entity, id)
@@ -23,7 +23,7 @@ module NominetEPP
23
23
  end
24
24
  end
25
25
 
26
- return resp.success?
26
+ return @resp.success?
27
27
  end
28
28
  private
29
29
  # Create +account:unlock+ XML element for opt-out lock
@@ -13,7 +13,7 @@ module NominetEPP
13
13
  # @return [false] unrenew failed
14
14
  # @return [Hash<String, Time>] hash of domains and expiry times
15
15
  def unrenew(*names)
16
- resp = @client.update do
16
+ @resp = @client.update do
17
17
  domain('unrenew') do |node, ns|
18
18
  names.each do |name|
19
19
  node << XML::Node.new('name', name, ns)
@@ -21,10 +21,10 @@ module NominetEPP
21
21
  end
22
22
  end
23
23
 
24
- return false unless resp.success?
24
+ return false unless @resp.success?
25
25
 
26
26
  hash = {}
27
- resp.data.find('//domain:renData', namespaces).each do |node|
27
+ @resp.data.find('//domain:renData', namespaces).each do |node|
28
28
  renName = node_value(node, 'domain:name')
29
29
  renExp = node_value(node, 'domain:exDate')
30
30
  hash[renName] = Time.parse(renExp)
@@ -6,11 +6,11 @@ module NominetEPP
6
6
  # @param [String] id Domain, Account or Contact to update
7
7
  # @param [Hash] fields Fields to update
8
8
  def update(entity, id, fields = {})
9
- resp = @client.update do
9
+ @resp = @client.update do
10
10
  self.send(:"update_#{entity}", id, fields)
11
11
  end
12
12
 
13
- return resp.success?
13
+ return @resp.success?
14
14
  end
15
15
  private
16
16
  # Generate +domain:update+ payload
data/nominet-epp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nominet-epp}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Geoff Garside"]
12
- s.date = %q{2011-01-17}
12
+ s.date = %q{2011-01-31}
13
13
  s.description = %q{Client for communicating with the Nominet EPP}
14
14
  s.email = %q{geoff@geoffgarside.co.uk}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nominet-epp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoff Garside
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-17 00:00:00 +00:00
18
+ date: 2011-01-31 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency