Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc examples not working #6

Open
Tombar opened this issue Jun 18, 2014 · 7 comments
Open

Doc examples not working #6

Tombar opened this issue Jun 18, 2014 · 7 comments

Comments

@Tombar
Copy link

Tombar commented Jun 18, 2014

Hello

Im trying to use the examples in the doc and they are not working for me, could you check and let me know if i'm doing something wrong or the docs are outdated/wrong?

If trying either domain:check string payload or domain:check XML::Node payload examples i get the following error.

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/epp-client-1.0.0/lib/epp-client/commands/read_write_command.rb:13:in `<<':  Nodes belong to different documents.  You must first import the node by calling XML::Document.import. (LibXML::XML::Error)

domain:check string payload sample

require "epp-client"

client = EPP::Client.new('user', 'pass', 'host', { :port => 1234} )

client.hello

client.check <<-EOXML
  <domain:check
   xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
    <domain:name>example.com</domain:name>
    <domain:name>example.net</domain:name>
  </domain:check>
EOXML

puts client.last_request
puts client.last_response

client.logout

domain:check XML::Node payload sample

require "epp-client"

client = EPP::Client.new('user', 'pass', 'host', { :port => 1234} )

client.hello

xml = XML::Node.new('check')
ns = XML::Namespace.new(xml, 'domain', 'urn:ietf:params:xml:ns:domain-1.0')
xml.namespaces.namespace = ns

%w(example.com example.net).each do |name|
      xml << XML::Node.new('name', name, ns)
end

puts client.last_request
puts client.last_response

client.logout

If I tried with the domain:check block I get a different error this time..

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/epp-client-1.0.0/lib/epp-client/client.rb:106:in `check': wrong number of arguments (0 for 1) (ArgumentError)
    from test2.rb:8:in `<main>'

domain:check XML::Node payload sample

require "epp-client"

client = EPP::Client.new('user', 'pass', 'host', { :port => 1234} )

client.hello

client.check do |xml|
  xml << (check = XML::Node.new('check'))
  ns = XML::Namespace.new(check, 'domain', 'urn:ietf:params:xml:ns:domain-1.0')
  check.namespaces.namespace = ns

  %w(example.com example.net example.org).each do |name|
    check << XML::Node.new('name', name, ns)
  end

  check
end

puts client.last_request
puts client.last_response

client.logout

I'm using ruby 1.9.3 and gem version 1.0

Regards

M

@geoffgarside
Copy link
Contributor

Hi,
Sorry the interface has been overhauled for 1.0.0 and I've neglected to update the README file. While I get something together to document the updated interface you can check the tests to see how the different types of requests can be created now.

@Tombar
Copy link
Author

Tombar commented Jun 18, 2014

Ok, thanks for your quick response.

Could you provide just a brief working example of checking a domain availability.

Regards

M

@geoffgarside
Copy link
Contributor

I've pushed up a quick set of examples in the README file

resp = client.check EPP::Domain::Check.new('example.com', 'example.net', 'example.org')
resp.available?('example.com') #=> true
resp.available?('example.net') #=> false
resp.available?('example.org') #=> false

if you've only got one name you want to check then you can use

resp = client.check EPP::Domain::Check.new('example.com')
resp.available? #=> true

as you don't have to pass the name to the #available? method when theres only one item being checked.

@Tombar
Copy link
Author

Tombar commented Jun 18, 2014

Thank you very much!

@Tombar
Copy link
Author

Tombar commented Jun 19, 2014

@geoffgarside sorry to bother you again, but your example is just partially working for me..

The check is working, but the resp.available? isn't.

My code

require "epp-client"

client = EPP::Client.new('user', 'pass', 'host', { :port => 1234} )
client.hello
resp = client.check EPP::Domain::Check.new('example.com', 'example.org')
puts resp.class
resp.available?('example.com') 

My output

EPP::Response
new.rb:7:in `<main>': undefined method `available?' for #<EPP::Response:0x00000001f00220> (NoMethodError)

It's looks to me, like the client.check response is of type EPP::Response instead of EPP::Domain::CheckResponse, am I doing something really stupid or missing something?

FTR, gem epp-client installed is version 1.0.0

Regards

M

@geoffgarside
Copy link
Contributor

Damn,
Most of my use of this code is in m247/nominet-epp so I'd forgotten how low the interface was with this. The interface was quite influenced by the needs for testing the generated XML.

I've updated the README. I'd forgotten that you need to pass the EPP::Response to something like EPP::Domain::CheckResponse.new. It makes me think that it might be worth adding another method to the likes of EPP::Domain::Check where it can specify the response class to use.

@Tombar
Copy link
Author

Tombar commented Jun 20, 2014

I've just see how you guys do it on the nominet-epp., I will try to backport the logic into the epp-client and send a pull request.

I'll let you know if I need some help with the test cases.

Thanks for all your help Sir!

Regards

M

Tombar added a commit to Tombar/epp-client that referenced this issue Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants