Class: EPPClient::SmallRegistry

Inherits:
Base
  • Object
show all
Includes:
SecDNS
Defined in:
lib/epp-client/smallregistry.rb

Overview

This handles the Smallregistry specificites.

See www.smallregistry.net/faqs/quelles-sont-les-specificites-du-serveur-epp

Constant Summary collapse

SCHEMAS_SR =
%w(
  sr-1.0
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ SmallRegistry

Sets the default for Smallregistry, that is, server and port, according to Smallregistry’s documentation. www.smallregistry.net/faqs/quelles-sont-les-specificites-du-serveur-epp

Required Attributes

:client_id

the tag or username used with <login> requests.

:password

the password used with <login> requests.

:ssl_cert

the file containing the client certificate.

:ssl_key

the file containing the key of the certificate.

Optional Attributes

:test

sets the server to be the test server.

See EPPClient for other attributes.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/epp-client/smallregistry.rb', line 36

def initialize(attrs)
  unless attrs.key?(:client_id) && attrs.key?(:password) && attrs.key?(:ssl_cert) && attrs.key?(:ssl_key)
    raise ArgumentError, 'client_id, password, ssl_cert and ssl_key are required'
  end
  if attrs.delete(:test) == true
    attrs[:server] ||= 'epp.test.smallregistry.net'
    attrs[:port] ||= 2700
  else
    attrs[:server] ||= 'epp.smallregistry.net'
    attrs[:port] ||= 700
  end
  @services = EPPClient::SCHEMAS_URL.values_at('domain', 'contact')
  super(attrs)
  @extensions << EPPClient::SCHEMAS_URL['sr']
end

Instance Method Details

#contact_create(contact) ⇒ Object

Extends the EPPClient::Contact#contact_create so that the specific smallregistry’s information are sent, the additionnal informations are :

one of :

:org

indicating that the contact is an organisation with the following informations :

:companySerial

the company’s SIREN / RPPS / whatever serial number is required.

:person

indicating that the contact is a human person with the following informations :

:birthDate

the person’s birth date.

:birthPlace

the person’s birth place.



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

def contact_create(contact)
  super # placeholder so that I can add some doc
end

#contact_create_xml(contact) ⇒ Object

:nodoc:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/epp-client/smallregistry.rb', line 105

def contact_create_xml(contact) #:nodoc:
  ret = super

  ext = extension do |xml|
    xml.ext(:xmlns => EPPClient::SCHEMAS_URL['sr']) do
      xml.create do
        xml.contact do
          if contact.key?(:org)
            xml.org do
              xml.companySerial(contact[:org][:companySerial])
            end
          elsif contact.key?(:person)
            xml.person do
              xml.birthDate(contact[:person][:birthDate])
              xml.birthPlace(contact[:person][:birthPlace])
            end
          end
        end
      end
    end
  end

  insert_extension(ret, ext)
end

#contact_info(xml) ⇒ Object

Extends the EPPClient::Contact#contact_info so that the specific smallregistry’s informations are processed, the additionnal informations are :

one of :

:org

indicating that the contact is an organisation with the following informations :

:companySerial

the company’s SIREN / RPPS / whatever serial number is required.

:person

indicating that the contact is a human person with the following informations :

:birthDate

the person’s birth date.

:birthPlace

the person’s birth place.



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

def contact_info(xml)
  super # placeholder so that I can add some doc
end

#contact_info_process(xml) ⇒ Object

:nodoc:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/epp-client/smallregistry.rb', line 71

def contact_info_process(xml) #:nodoc:
  ret = super
  unless (contact = xml.xpath('epp:extension/sr:ext/sr:infData/sr:contact', EPPClient::SCHEMAS_URL)).empty?
    unless (person = contact.xpath('sr:person', EPPClient::SCHEMAS_URL)).empty?
      ret[:person] = {
        :birthDate => Date.parse(person.xpath('sr:birthDate', EPPClient::SCHEMAS_URL).text),
        :birthPlace => person.xpath('sr:birthPlace', EPPClient::SCHEMAS_URL).text,
      }
    end
    unless (org = contact.xpath('sr:org', EPPClient::SCHEMAS_URL)).empty?
      ret[:org] = { :companySerial => org.xpath('sr:companySerial', EPPClient::SCHEMAS_URL).text }
    end
  end
  ret
end

#contact_update(args) ⇒ Object

Extends the EPPClient::Contact#contact_update so that the specific afnic update informations can be sent, the additionnal informations are :

:chg

changes one of :

:org

indicating that the contact is an organisation with the following informations :

[<tt>:companySerial</tt>]
  the company's SIREN / RPPS / whatever serial number is required.
:person

indicating that the contact is a human person with the following informations :

:birthDate

the person’s birth date.

:birthPlace

the person’s birth place.



173
174
175
# File 'lib/epp-client/smallregistry.rb', line 173

def contact_update(args)
  super # placeholder so that I can add some doc
end

#contact_update_xml(args) ⇒ Object

:nodoc:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/epp-client/smallregistry.rb', line 130

def contact_update_xml(args) #:nodoc:
  ret = super

  return ret unless args.key?(:chg) && (args[:chg].key?(:org) || args[:chg].key?(:person))

  ext = extension do |xml|
    xml.ext(:xmlns => EPPClient::SCHEMAS_URL['sr']) do
      xml.update do
        xml.contact do
          if args[:chg].key?(:org)
            xml.org do
              xml.companySerial(args[:chg][:org][:companySerial])
            end
          elsif args[:chg].key?(:person)
            xml.person do
              xml.birthDate(args[:chg][:person][:birthDate])
              xml.birthPlace(args[:chg][:person][:birthPlace])
            end
          end
        end
      end
    end
  end

  insert_extension(ret, ext)
end