Module: EPPClient::Poll

Included in:
Base
Defined in:
lib/epp-client/poll.rb

Overview

This implements the poll EPP commands.

Constant Summary collapse

PARSERS =
{}

Instance Method Summary collapse

Instance Method Details

#poll_ack(mid = @msgQ_id) ⇒ Object

sends a <epp:poll op="ack" msgID="<mid>"> command to the server. Most of the time, you should not pass any argument, as it will “do the right thing”.



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

def poll_ack(mid = @msgQ_id)
  response = send_request(poll_ack_xml(mid))

  get_result(response)
end

#poll_ack_xml(mid) ⇒ Object

:nodoc:



55
56
57
58
59
# File 'lib/epp-client/poll.rb', line 55

def poll_ack_xml(mid) #:nodoc:
  command do |xml|
    xml.poll(:op => :ack, :msgID => mid)
  end
end

#poll_reqObject

sends a <epp:poll op="req"> command to the server.

if there is a message in the queue, returns a hash with the following keys :

:qDate

the date and time that the message was enqueued.

:msg, :msg_xml

a human readble message, the :msg version has all the possible xml stripped, whereas the :msg_xml contains the original message.

:obj, :obj_xml

contains a possible <epp:resData> object, the original one in :obj_xml, and if a parser is available, the parsed one in :obj.



22
23
24
25
26
# File 'lib/epp-client/poll.rb', line 22

def poll_req
  response = send_request(poll_req_xml)

  get_result(:xml => response, :callback => :poll_req_process)
end

#poll_req_process(xml) ⇒ Object

:nodoc:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/epp-client/poll.rb', line 30

def poll_req_process(xml) #:nodoc:
  ret = {}
  unless (date = xml.xpath('epp:msgQ/epp:qDate', EPPClient::SCHEMAS_URL)).empty?
    ret[:qDate] = DateTime.parse(date.text)
  end
  unless (msg = xml.xpath('epp:msgQ/epp:msg', EPPClient::SCHEMAS_URL)).empty?
    ret[:msg] = msg.text
    ret[:msg_xml] = msg.to_s
  end
  if !(obj = xml.xpath('epp:resData', EPPClient::SCHEMAS_URL)).empty? ||
     !(obj = xml.xpath('epp:extension', EPPClient::SCHEMAS_URL)).empty?
    ret[:obj_xml] = obj.to_s
    PARSERS.each do |xpath, parser|
      next if obj.xpath(xpath, EPPClient::SCHEMAS_URL).empty?
      ret[:obj] = case parser
                  when Symbol
                    send(parser, xml)
                  else
                    raise NotImplementedError
                  end
    end
  end
  ret
end

#poll_req_xmlObject

:nodoc:



4
5
6
7
8
# File 'lib/epp-client/poll.rb', line 4

def poll_req_xml #:nodoc:
  command do |xml|
    xml.poll(:op => :req)
  end
end