Module: NominetEPP::Operations::Create
- Included in:
- Client
- Defined in:
- lib/nominet-epp/operations/create.rb
Overview
EPP Create Operation
Instance Method Summary collapse
-
#create(name, acct, nameservers, options = {}) ⇒ false, Hash
Register a domain name with Nominet.
Instance Method Details
#create(name, acct, nameservers, options = {}) ⇒ false, Hash
Register a domain name with Nominet.
The returned hash has the following keys
-
(String)
:name
– Domain name registered -
(Time)
:crDate
– Domain creation date -
(Time)
:exDate
– Domain expiration date -
(Hash)
:account
– Created account data (if returned)
The :account
hash contains the following keys
-
(String)
:roid
– Account ID -
(String)
:name
– Account Name -
(Array)
:contacts
– Account contacts
The :contacts
array contains hashes of the following keys
-
(String)
:roid
– Contact ID -
(String)
:name
– Contact Name -
(String)
:type
– Contact type if set -
(Integer)
:order
– Contacts order in the list of contacts
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/nominet-epp/operations/create.rb', line 37 def create(name, acct, nameservers, = {}) raise ArgumentError, "options allowed keys are period, first_bill, recur_bill, auto_bill, next_bill, notes" unless (.keys - [:period, :first_bill, :recur_bill, :auto_bill, :next_bill, :notes]).empty? @resp = @client.create do domain('create') do |node, ns| node << XML::Node.new('name', name, ns) if period = .delete(:period) unit = period[-1..1] num = period.to_i.to_s p = XML::Node.new('period', num, ns); p['unit'] = unit node << p end # node << XML::Node.new('auto-period', '', ns) # placeholder node << XML::Node.new('account', nil, ns).tap do |acct_xml| acct_xml << create_account(acct, ns) end node << domain_ns_xml(nameservers, ns) # Enforce correct sequencing of option fields [:first_bill, :recur_bill, :auto_bill, :next_bill, :notes].each do |key| next if [key].nil? || [key] == '' node << XML::Node.new(key.to_s.gsub('_', '-'), [key], ns) end end end unless @resp.success? @error_info = { :name => node_value(@resp.data, '//domain:failData/domain:name/node()'), :reason => node_value(@resp.data, '//domain:failData/domain:reason/node()') } return false end creData = @resp.data.find('//domain:creData', namespaces).first h = { :name => node_value(creData, 'domain:name'), :crDate => Time.parse(node_value(creData, 'domain:crDate')), :exDate => Time.parse(node_value(creData, 'domain:exDate')) } unless creData.find('domain:account').first.nil? h[:account] = created_account(creData.find('domain:account/account:creData', namespaces).first) end h end |