Class: EPP::Client

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

Overview

Front facing EPP Client.

Establishes a connection to an EPP server and allows for sending commands to that EPP server.

Constant Summary collapse

DEFAULT_SERVICES =

Default Service URNs

Provided to make it easier for clients to add additional services to the default list.

Examples:

services = DEFAULT_SERVICES + %w(urn:ietf:params:xml:ns:secDNS-1.1)
EPP::Client.new('username','password','epp.example.com', :services => services)
[ Domain::NAMESPACE, Contact::NAMESPACE, Host::NAMESPACE ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, passwd, host, options = {}) ⇒ Client

Create new instance of EPP::Client.

Parameters:

  • tag (String)

    EPP Tag

  • passwd (String)

    EPP Tag password

  • host (String)

    EPP Host address

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

    Options

Options Hash (options):

  • :port (Integer)

    EPP Port number, default 700

  • :compatibility (Boolean)

    Compatibility mode, default false

  • :lang (String)

    EPP Language code, default ‘en’

  • :version (String)

    EPP protocol version, default ‘1.0’

  • :extensions (Array<String>)

    EPP Extension URNs

  • :services (Array<String>)

    EPP Service URNs

  • :address_family (String)

    ‘AF_INET’ or ‘AF_INET6’ or either of the appropriate socket constants. Will cause connections to be limited to this address family. Default try all addresses.



32
33
34
35
36
37
38
39
# File 'lib/epp-client/client.rb', line 32

def initialize(tag, passwd, host, options = {})
  @tag, @passwd, @host, @options = tag, passwd, host, options
  @conn = if options.delete(:compatibility) == true
    OldServer.new(tag, passwd, host, options)
  else
    Server.new(tag, passwd, host, options)
  end
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



41
42
43
# File 'lib/epp-client/client.rb', line 41

def host
  @host
end

#optionsObject (readonly)

Returns the value of attribute options.



41
42
43
# File 'lib/epp-client/client.rb', line 41

def options
  @options
end

#passwdObject (readonly)

Returns the value of attribute passwd.



41
42
43
# File 'lib/epp-client/client.rb', line 41

def passwd
  @passwd
end

#tagObject (readonly)

Returns the value of attribute tag.



41
42
43
# File 'lib/epp-client/client.rb', line 41

def tag
  @tag
end

Instance Method Details

#_last_errorResponseError

Deprecated.

Returns the last error received from a login or logout request

Returns:

  • (ResponseError)

    last error received from login/logout request



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

def _last_error
  warn "The #{self.class}#_last_error method is deprecated, please call #last_error"
  last_error
end

#_last_requestRequest

Deprecated.

Returns the last request sent to the EPP server

Returns:

  • (Request)

    last request sent to the EPP server



58
59
60
61
# File 'lib/epp-client/client.rb', line 58

def _last_request
  warn "The #{self.class}#_last_request method is deprecated, please call #last_request"
  last_request
end

#_last_responseResponse

Deprecated.

Returns the last response received from the EPP server

Returns:

  • (Response)

    last response received from the EPP server



74
75
76
77
# File 'lib/epp-client/client.rb', line 74

def _last_response
  warn "The #{self.class}#_last_response method is deprecated, please call #last_response"
  last_response
end

#ack(msgID) ⇒ Object



145
146
147
148
# File 'lib/epp-client/client.rb', line 145

def ack(msgID)
  ack = EPP::Commands::Poll.new(msgID)
  command(ack)
end

#ack_prepare(msgID) ⇒ Object



45
46
47
48
# File 'lib/epp-client/testing.rb', line 45

def ack_prepare(msgID)
  ack = EPP::Commands::Poll.new(msgID)
  prepare_request(ack)
end

#check(payload, extension = nil) ⇒ Object



106
107
108
109
# File 'lib/epp-client/client.rb', line 106

def check(payload, extension = nil)
  check = EPP::Commands::Check.new(payload)
  command(check, extension)
end

#check_prepare(payload, extension = nil) ⇒ Object

Request Preparation Methods



6
7
8
9
# File 'lib/epp-client/testing.rb', line 6

def check_prepare(payload, extension = nil)
  check = EPP::Commands::Check.new(payload)
  prepare_request(check, extension)
end

#compatibility?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/epp-client/client.rb', line 43

def compatibility?
  @conn.is_a?(OldServer)
end

#create(payload, extension = nil) ⇒ Object



111
112
113
114
# File 'lib/epp-client/client.rb', line 111

def create(payload, extension = nil)
  create = EPP::Commands::Create.new(payload)
  command(create, extension)
end

#create_prepare(payload, extension = nil) ⇒ Object



11
12
13
14
# File 'lib/epp-client/testing.rb', line 11

def create_prepare(payload, extension = nil)
  create = EPP::Commands::Create.new(payload)
  prepare_request(create, extension)
end

#delete(payload, extension = nil) ⇒ Object



116
117
118
119
# File 'lib/epp-client/client.rb', line 116

def delete(payload, extension = nil)
  delete = EPP::Commands::Delete.new(payload)
  command(delete, extension)
end

#delete_prepare(payload, extension = nil) ⇒ Object



16
17
18
19
# File 'lib/epp-client/testing.rb', line 16

def delete_prepare(payload, extension = nil)
  delete = EPP::Commands::Delete.new(payload)
  prepare_request(delete, extension)
end

#greetingObject



95
96
97
# File 'lib/epp-client/client.rb', line 95

def greeting
  @conn.greeting
end

#helloObject

Send hello command



100
101
102
103
104
# File 'lib/epp-client/client.rb', line 100

def hello
  @conn.connection do
    @conn.hello
  end
end

#info(payload, extension = nil) ⇒ Object



121
122
123
124
# File 'lib/epp-client/client.rb', line 121

def info(payload, extension = nil)
  info = EPP::Commands::Info.new(payload)
  command(info, extension)
end

#info_prepare(payload, extension = nil) ⇒ Object



21
22
23
24
# File 'lib/epp-client/testing.rb', line 21

def info_prepare(payload, extension = nil)
  info = EPP::Commands::Info.new(payload)
  prepare_request(info, extension)
end

#last_errorResponseError

Returns the last error received from a login or logout request

Returns:

  • (ResponseError)

    last error received from login/logout request



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

def last_error
  @conn.last_error
end

#last_requestRequest

Returns the last request sent to the EPP server

Returns:

  • (Request)

    last request sent to the EPP server



50
51
52
# File 'lib/epp-client/client.rb', line 50

def last_request
  @conn.last_request
end

#last_responseResponse

Returns the last response received from the EPP server

Returns:

  • (Response)

    last response received from the EPP server



66
67
68
# File 'lib/epp-client/client.rb', line 66

def last_response
  @conn.last_response
end

#load_response(xml_data) ⇒ Object

Response Preparation Methods



55
56
57
# File 'lib/epp-client/testing.rb', line 55

def load_response(xml_data)
  EPP::Response.new(xml_data)
end

#pollObject



141
142
143
144
# File 'lib/epp-client/client.rb', line 141

def poll
  poll = EPP::Commands::Poll.new
  command(poll)
end

#poll_prepareObject



41
42
43
44
# File 'lib/epp-client/testing.rb', line 41

def poll_prepare
  poll = EPP::Commands::Poll.new
  prepare_request(poll)
end

#prepare_request(cmd, extension = nil) ⇒ Object



50
51
52
# File 'lib/epp-client/testing.rb', line 50

def prepare_request(cmd, extension = nil)
  @conn.prepare_request(cmd, extension)
end

#renew(payload, extension = nil) ⇒ Object



126
127
128
129
# File 'lib/epp-client/client.rb', line 126

def renew(payload, extension = nil)
  renew = EPP::Commands::Renew.new(payload)
  command(renew, extension)
end

#renew_prepare(payload, extension = nil) ⇒ Object



26
27
28
29
# File 'lib/epp-client/testing.rb', line 26

def renew_prepare(payload, extension = nil)
  renew = EPP::Commands::Renew.new(payload)
  prepare_request(renew, extension)
end

#transfer(op, payload, extension = nil) ⇒ Object



131
132
133
134
# File 'lib/epp-client/client.rb', line 131

def transfer(op, payload, extension = nil)
  transfer = EPP::Commands::Transfer.new(op, payload)
  command(transfer, extension)
end

#transfer_prepare(op, payload, extension = nil) ⇒ Object



31
32
33
34
# File 'lib/epp-client/testing.rb', line 31

def transfer_prepare(op, payload, extension = nil)
  transfer = EPP::Commands::Transfer.new(op, payload)
  prepare_request(transfer, extension)
end

#update(payload, extension = nil) ⇒ Object



136
137
138
139
# File 'lib/epp-client/client.rb', line 136

def update(payload, extension = nil)
  update = EPP::Commands::Update.new(payload)
  command(update, extension)
end

#update_prepare(payload, extension = nil) ⇒ Object



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

def update_prepare(payload, extension = nil)
  update = EPP::Commands::Update.new(payload)
  prepare_request(update, extension)
end