Class: EPP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/epp-client/response.rb

Overview

An EPP XML Response

Instance Method Summary collapse

Constructor Details

#initialize(xml_string) ⇒ Response

Creates an instance of an EPP::Response

Parameters:

  • xml_string (String)

    XML Response



7
8
9
10
# File 'lib/epp-client/response.rb', line 7

def initialize(xml_string)
  @xml = XML::Parser.string(xml_string).parse
  @xml.root.namespaces.default_prefix = 'e'
end

Instance Method Details

#codeInteger

Response code

Returns:

  • (Integer)

    response code



24
25
26
# File 'lib/epp-client/response.rb', line 24

def code
  @code ||= result['code'].to_i
end

#dataXML::Node+

Response data

Returns:

  • (XML::Node, Array<XML::Node>)

    response data



53
54
55
56
57
58
# File 'lib/epp-client/response.rb', line 53

def data
  @data ||= begin
    list = @xml.find('/e:epp/e:response/e:resData/node()').reject { |n| n.empty? }
    list.size > 1 ? list : list[0]
  end
end

#error_reasonString

Error reason

Returns:

  • (String)

    error reason



42
43
44
45
46
47
48
49
# File 'lib/epp-client/response.rb', line 42

def error_reason
  unless defined?(@error_reason)
    reason = result.find('e:extValue/e:reason/text()').first
    @error_reason = reason && reason.content.strip
  end

  @error_reason
end

#error_valueXML::Node

Descriptive Error Information

Returns:

  • (XML::Node)

    error information



36
37
38
# File 'lib/epp-client/response.rb', line 36

def error_value
  @error_value ||= result.find('e:extValue/e:value/node()').first
end

#extensionXML::Node+

Response extension block

Returns:

  • (XML::Node, Array<XML::Node>)

    extension



68
69
70
71
72
73
# File 'lib/epp-client/response.rb', line 68

def extension
  @extension ||= begin
    list = @xml.find('/e:epp/e:response/e:extension/node()').reject { |n| n.empty? }
    list.size > 1 ? list : list[0]
  end
end

#inspectObject

See Also:

  • Object#inspect


76
77
78
# File 'lib/epp-client/response.rb', line 76

def inspect
  @xml.inspect
end

#messageString

Response message

Returns:

  • (String)

    response message



30
31
32
# File 'lib/epp-client/response.rb', line 30

def message
  @message ||= result.find('e:msg/text()').first.content.strip
end

#msgQXML::Node

Response Message Queue

Returns:

  • (XML::Node)

    message queue



62
63
64
# File 'lib/epp-client/response.rb', line 62

def msgQ
  @msgQ ||= @xml.find('/e:epp/e:response/e:msgQ').first
end

#pending?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/epp-client/response.rb', line 18

def pending?
  code == 1001
end

#success?Boolean

Indicates if the response is successful.

Returns:

  • (Boolean)

    if the response is successful



14
15
16
# File 'lib/epp-client/response.rb', line 14

def success?
  code == 1000
end

#to_s(opts = {}) ⇒ String

Convert the receiver to a string

Parameters:

  • opts (Hash) (defaults to: {})

    Formatting options, passed to the XML::Document

Returns:

  • (String)

    formatted XML response



90
91
92
# File 'lib/epp-client/response.rb', line 90

def to_s(opts = {})
  @xml.to_s({:indent => false}.merge(opts))
end

#to_xmlXML::Document

Returns the XML response document

Returns:

  • (XML::Document)

    XML response document



82
83
84
# File 'lib/epp-client/response.rb', line 82

def to_xml
  @xml
end