Class: Epp::Server

Inherits:
Object
  • Object
show all
Includes:
RequiresParameters
Defined in:
lib/epp/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RequiresParameters

#requires!

Constructor Details

#initialize(attributes = {}) ⇒ Server

Required Attrbiutes

  • :server - The EPP server to connect to

  • :tag - The tag or username used with <login> requests.

  • :password - The password used with <login> requests.

Optional Attributes

  • :port - The EPP standard port is 700. However, you can choose a different port to use.

  • :clTRID - The client transaction identifier is an element that EPP specifies MAY be used to uniquely identify the command to the server. You are responsible for maintaining your own transaction identifier space to ensure uniqueness. Defaults to “ABC-12345”

  • :old_server - Set to true to read and write frames in a way that is compatible with older EPP servers. Default is false.

  • :lang - Set custom language attribute. Default is ‘en’.

  • :services - Use custom EPP services in the <login> frame. The defaults use the EPP standard domain, contact and host 1.0 services.

  • :extensions - URLs to custom extensions to standard EPP. Use these to extend the standard EPP (e.g., Nominet uses extensions). Defaults to none.

  • :version - Set the EPP version. Defaults to “1.0”.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/epp/server.rb', line 22

def initialize(attributes = {})
  requires!(attributes, :tag, :password, :server)
  
  @tag        = attributes[:tag]
  @password   = attributes[:password]
  @server     = attributes[:server]
  @port       = attributes[:port]       || 700
  @old_server = attributes[:old_server] || false
  @lang       = attributes[:lang]       || 'en'
  @services   = attributes[:services]   || ["urn:ietf:params:xml:ns:domain-1.0", "urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:host-1.0"]
  @extensions = attributes[:extensions] || []
  @version    = attributes[:verison]    || "1.0"
  
  @logged_in  = false
end

Instance Attribute Details

#extensionsObject

Returns the value of attribute extensions.



5
6
7
# File 'lib/epp/server.rb', line 5

def extensions
  @extensions
end

#langObject

Returns the value of attribute lang.



5
6
7
# File 'lib/epp/server.rb', line 5

def lang
  @lang
end

#old_serverObject

Returns the value of attribute old_server.



5
6
7
# File 'lib/epp/server.rb', line 5

def old_server
  @old_server
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/epp/server.rb', line 5

def password
  @password
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/epp/server.rb', line 5

def port
  @port
end

#serverObject

Returns the value of attribute server.



5
6
7
# File 'lib/epp/server.rb', line 5

def server
  @server
end

#tagObject

Returns the value of attribute tag.



5
6
7
# File 'lib/epp/server.rb', line 5

def tag
  @tag
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/epp/server.rb', line 5

def version
  @version
end

Instance Method Details

#request(xml) ⇒ Object

Sends an XML request to the EPP server, and receives an XML response. <login> and <logout> requests are also wrapped around the request, so we can close the socket immediately after the request is made.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/epp/server.rb', line 42

def request(xml)
  open_connection
  
  @logged_in = true if 
  
  begin
    @response = send_request(xml)
  ensure
    if @logged_in && !@old_server
      @logged_in = false if logout
    end
    
    close_connection
  end
  
  return @response
end