Class: EnomAPI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/enom-api/client.rb

Overview

Client

Instance Method Summary collapse

Constructor Details

#initialize(user, passwd, server = 'reseller.enom.com') ⇒ Client

Returns a new instance of Client.

Parameters:

  • user (String)

    eNom Account ID

  • passwd (String)

    eNom Account Password

  • server (String) (defaults to: 'reseller.enom.com')

    Server to connect to. Use ‘resellertest.enom.com’ for test.



11
12
13
14
# File 'lib/enom-api/client.rb', line 11

def initialize(user, passwd, server = 'reseller.enom.com')
  @user, @server = user, server
  @conn = Interface.new(user, passwd, server)
end

Instance Method Details

#check(*names) ⇒ Boolean, Hash<String, Boolean>

Checks status of domain names

Parameters:

  • *names (Array<String>)

    Names of domains to check the status of.

Returns:

  • (Boolean)

    when 1 name provided, whether the domain is available or not

  • (Hash<String, Boolean>)

    when multiple names provided, hash of names and whether the domain is available or not

Raises:

  • (ArgumentError)

    if more than 30 names are provided



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/enom-api/client.rb', line 70

def check(*names)
  raise ArgumentError, "maximum number of names is 30" if names.size > 30
  xml = send_recv(:Check, :DomainList => names.join(','))

  info = (1..xml.DomainCount.to_i).map do |i|
    [xml.send("Domain#{i}"), xml.send("RRPCode#{i}") == '210']
  end.flatten

  return info[1] if info.size == 2
  Hash[*info]
end

#check_ns_status(name) ⇒ Hash, false

Checks the status of a nameserver registered with eNom.

Parameters:

  • name (String)

    nameserver to check

Returns:

  • (Hash)

    the nameserver :name and :ipaddress

  • (false)

    the nameserver is not registered with eNom



87
88
89
90
91
92
# File 'lib/enom-api/client.rb', line 87

def check_ns_status(name)
  xml = send_recv(:CheckNSStatus, :CheckNSName => name)

  return false if xml.RRPCode != '200'
  { :name => xml.CheckNsStatus.name, :ipaddress => xml.CheckNsStatus.ipaddress }
end

#delete_nameserver(name) ⇒ Boolean

Delete a registered nameserver from eNom

Parameters:

  • name (String)

    nameserver to delete from the registry

Returns:

  • (Boolean)

    true if deleted successfully, false if not



98
99
100
101
# File 'lib/enom-api/client.rb', line 98

def delete_nameserver(name)
  xml = send_recv(:DeleteNameServer, :NS => name)
  return xml.RRPCode == '200' && xml.NsSuccess == '1'
end

#delete_registration(domain) ⇒ true, Hash

Deletes a domain registration.

The domain registration must be less than 5 days old. eNom requires an EndUserIP to be sent with the request, this is set to 127.0.0.1.

Parameters:

  • domain (String)

    Name of the registered domain

Returns:

  • (true)

    if successfully deleted

  • (Hash)

    Error details with :string, :source and :section information



111
112
113
114
115
116
117
118
119
# File 'lib/enom-api/client.rb', line 111

def delete_registration(domain)
  xml = send_recv(:DeleteRegistration, split_domain(domain).merge(:EndUserIP => "127.000.000.001"))

  return true if xml.DomainDeleted?

  { :string => xml.ErrString,
    :source => xml.ErrSource,
    :section => xml.ErrSection }
end

#extend(domain, period = 1) ⇒ String, false

Parameters:

  • domain (String)

    Domain name to renew

  • period (String) (defaults to: 1)

    Number of years to extend the registration by

Returns:

  • (String)

    Order ID of the renewal

  • (false)

    the order did not succeed



279
280
281
282
283
284
# File 'lib/enom-api/client.rb', line 279

def extend(domain, period = 1)
  xml = send_recv(:Extend, split_domain(domain).merge(:NumYears => period.to_i))

  return false if xml.RRPCode != '200'
  xml.OrderID
end

#get_contacts(domain) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/enom-api/client.rb', line 543

def get_contacts(domain)
  xml = send_recv(:GetContacts, split_domain(domain))
  xml = xml.GetContacts

  out = {}
  out[:registrant]      = Registrant.from_xml(xml.Registrant)
  out[:aux_billing]     = Registrant.from_xml(xml.AuxBilling)
  out[:administrative]  = Registrant.from_xml(xml.Admin)
  out[:technical]       = Registrant.from_xml(xml.Tech)
  out[:billing]         = Registrant.from_xml(xml.Billing)
  out
end

#get_dns(domain) ⇒ Array<String>, false

Gets the list of nameserver for a domain.

Parameters:

  • domain (String)

    name of domain to collect nameservers of

Returns:

  • (Array<String>)

    array of nameservers

  • (false)

    no nameservers for the domain



126
127
128
129
130
131
132
133
# File 'lib/enom-api/client.rb', line 126

def get_dns(domain)
  xml = send_recv(:GetDNS, split_domain(domain))
  return false if xml.RRPCode != '200'

  nameservers = []
  xml.dns { nameservers << xml.strip }
  nameservers
end

#get_domain_countHash

Get the number of domains in the account in specific groups.

The groups of domains and their result keys are:

  • (Integer) :registered – Registered

  • (Integer) :hosted – Hosted

  • (Integer) :expiring – Expiring

  • (Integer) :expired – Expired

  • (Integer) :redemption – Redemption

  • (Integer) :extended_redemption – Extended Redemption

  • (Integer) :processing – Processing

  • (Integer) :watch_list – Watch List

Returns:

  • (Hash)

    Hash of number of domains in each group



148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/enom-api/client.rb', line 148

def get_domain_count
  xml = send_recv(:GetDomainCount)

  { :registered =>          xml.RegisteredCount.to_i,
    :hosted =>              xml.HostCount.to_i,
    :expiring =>            xml.ExpiringCount.to_i,
    :expired =>             xml.ExpiredDomainsCount.to_i,
    :redemption =>          xml.RGP.to_i,
    :extended_redemption => xml.ExtendedRGP.to_i,
    :processing =>          xml.ProcessCount.to_i,
    :watch_list =>          xml.WatchlistCount.to_i }
end

#get_domain_exp(domain) ⇒ Time

Get the expiration date of a domain

Parameters:

  • domain (String)

    Domain name

Returns:

  • (Time)

    expiration date of the domain in UTC



165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/enom-api/client.rb', line 165

def get_domain_exp(domain)
  xml = send_recv(:GetDomainExp, split_domain(domain))
  fmt = "%m/%d/%Y %l:%M:%S %p %z"
  str = "%s %s" % [xml.ExpirationDate.strip, xml.TimeDifference.strip]

  if Time.respond_to?(:strptime)
    Time.strptime(str, fmt).utc
  else
    dt = DateTime.strptime(str, fmt).new_offset(0)  # UTC time
    Time.utc(dt.year, dt.mon, dt.mday, dt.hour, dt.min, dt.sec + dt.sec_fraction)
  end
end

#get_domain_info(domain) ⇒ Hash

Get the domain information for a domain

The information returned includes the following

  • (Time) :expires – Expiration date

  • (String) :status – Status

  • (Array) :nameservers – Nameserver names

Parameters:

  • domain (String)

    Domain name

Returns:

  • (Hash)

    information for the domain



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/enom-api/client.rb', line 187

def get_domain_info(domain)
  xml = send_recv(:GetDomainInfo, split_domain(domain))
  xml = xml.GetDomainInfo

  nameservers = []
  xml.services.entry do |entry,_|
    next unless entry['name'] == 'dnsserver'
    entry.configuration.dns do |dns,_|
      nameservers << dns.to_s
    end
  end

  { :expires => Time.parse(xml.status.expiration.strip),
    :status => xml.status.registrationstatus.strip,
    :nameservers => nameservers }
end

#get_domain_status(domain) ⇒ Hash #get_domain_status(domain, order_id, order_type = :purchase) ⇒ Hash

Get the registration status of a domain. Used for TLDs which do not register in real time.

The hash returned includes the following information:

  • (String) :order_id – Order ID

  • (Integer) :in_account – In Account, one of 0, 1, 2

  • (String) :description – Description of In Account

  • (Time) :expires – Expiration Date

The :in_account field will have one of the following numeric values and meanings

  • 0: Domain is not in the eNom database

  • 1: Domain is in the eNom database and the recievers account

  • 2: Domain is in the eNom database but not the receivers account

The :description field contains a textual representation of the :in_account value, it will not necessarily match those given above. The meanings however should be correct.

Overloads:

  • #get_domain_status(domain) ⇒ Hash

    Parameters:

    • domain (String)

      Name of the domain to get status for

  • #get_domain_status(domain, order_id, order_type = :purchase) ⇒ Hash

    Parameters:

    • domain (String)

      Name of the domain to get status for

    • order_id (String)

      Order ID to get information for

    • order_type (Symbol) (defaults to: :purchase)

      Type of order information to obtain, :purchase, :transfer, or :extend

Returns:

  • (Hash)

    Hash of registration information



229
230
231
232
233
234
235
236
237
# File 'lib/enom-api/client.rb', line 229

def get_domain_status(domain, order_id = nil, order_type = :purchase)
  order_opts = order_id.nil? ? {} : { :OrderID => order_id, :OrderType => order_type }
  xml = send_recv(:GetDomainStatus, split_domain(domain).merge(order_opts))

  { :orderid => xml.OrderID,
    :in_account => xml.InAccount.to_i,
    :description => xml.StatusDesc,
    :expires => Time.parse(xml.ExpDate.strip) }
end

#get_expired_domainsHash

Get a list of the domains in the Expired, Redemption and Extended Redemption groups.

The returned hash has the following keys

  • (Array) :expired – Expired domains

  • (Array) :redemption – Domains in Redemption Grace Period (RGP)

  • (Array) :extended_redemption – Domains in Extended RGP

Each array contains hashes with the following keys

  • (String) :name – The domain name

  • (String) :id – The domains eNom registry ID

  • (Time) :date – Expiration date of the domain

  • (BOOL) :locked – Domain locked status

Returns:

  • (Hash)

    Hash of expired domains information



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/enom-api/client.rb', line 253

def get_expired_domains
  xml = send_recv(:GetExpiredDomains)

  domains = {:expired => [], :extended_redemption => [], :redemption => []}
  xml.DomainDetail do
    case xml.status
    when /Expired/i
      domains[:expired]
    when /Extended RGP/i
      domains[:extended_redemption]
    when /RGP/i
      domains[:redemption]
    end << {
      :name => xml.DomainName,
      :id => xml.DomainNameID,
      :date => Time.parse(xml.send('expiration-date')),
      :locked => xml.lockstatus =~ /Locked/i
    }
  end
  domains
end

#get_ext_attributes(tld) ⇒ Array

Get the list of extended attributes required by a TLD

The returned array of extended attributes contains hashes of the attribute details. The details include the following information

  • (String) :id – eNom internal attribute ID

  • (String) :name – Form parameter name

  • (String) :title – Short definition of the parameter value

  • (BOOL) :application – Attribute required for Registrant contact

  • (BOOL) :user_defined – Attribute value must be provided by user

  • (BOOL) :required – Attribute is required

  • (String) :description – Long definition of the parameter value

  • (String) :is_child – Is a child of another

  • (Array) :options – Array of options for the attribute

Attribute options include the following information

  • (String) :id – eNom internal attribute option ID

  • (String) :value – Value of the option

  • (String) :title – Short definition of the parameter value

  • (String) :description – Long definition of the parameter value

Parameters:

  • tld (String)

    Top Level Domain

Returns:

  • (Array)

    extended attributes, their details and valid options



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/enom-api/client.rb', line 308

def get_ext_attributes(tld)
  xml = send_recv(:GetExtAttributes, :TLD => tld)

  attrs = []
  xml.Attributes do
    xml.Attribute do
      h = {
        :id => xml.ID,
        :name => xml.Name,
        :title => xml.Title,
        :application => xml.Application == '2',
        :user_defined => xml.UserDefined?,
        :required => xml.Required?,
        :description => xml.Description,
        :is_child => xml.IsChild?,
        :options => Array.new }
      attrs << h
      xml.Options do
        xml.Option do
          h[:options] << {
            :id => xml.ID,
            :value => xml.Value,
            :title => xml.Title,
            :description => xml.Description
          }
        end
      end
    end
  end
  attrs
end

#get_extend_info(domain) ⇒ Hash

Get renewal information for a domain

The returned hash contains the following keys

  • (Time) :expiration – Time the domain expires

  • (Integer) :max_extension – Maximum number of years which can be added

  • (Integer) :min_extension – Minimum number of years which can be added

  • (BOOL) :registrar_hold – Registrar hold state

  • (Float) :balance – Current account balance

  • (Float) :available – Available account balance

Parameters:

  • domain (String)

    Domain name

Returns:

  • (Hash)

    Renewal information



352
353
354
355
356
357
358
359
360
361
# File 'lib/enom-api/client.rb', line 352

def get_extend_info(domain)
  xml = send_recv(:GetExtendInfo, split_domain(domain))

  { :expiration => Time.parse(xml.Expiration),
    :max_extension => xml.MaxExtension.to_i,
    :min_extension => xml.MinAllowed.to_i,
    :registrar_hold => xml.RegistrarHold?,
    :balance => xml.Balance.to_f,
    :available => xml.AvailableBalance.to_f }
end

#get_order_detail(order_id) ⇒ Hash

Get detailed information about an order

The returned hash contains the following keys

  • (Boolean) :result – Order exists

  • (Float) :amount – Billed amount

  • (Array) :details – Details

  • (String) :status – Order Status

The :details result key array contains hashes with the following keys

  • (String) :product_type – Order detail item type

  • (String) :description – Description of the detail

  • (String) :status – Status of the order detail

  • (Integer) :quantity – Number of the details of this type

  • (Float) :amount – Amount paid for detail

Parameters:

  • order_id (String)

    ID of the order

Returns:

  • (Hash)

    order information



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/enom-api/client.rb', line 380

def get_order_detail(order_id)
  xml = send_recv(:GetOrderDetail, :OrderID => order_id)

  info = {}
  xml.Order do
    info[:result] = xml.Result?
    info[:amount] = xml.OrderBillAmount
    info[:status] = xml.OrderStatus       # If this doesn't exist, then its under OrderDetail
    info[:details] = []

    xml.OrderDetail do
      info[:details] << {
        :product_type => xml.ProductType,
        :description => xml.Description,
        :status => xml.Status,
        :quantity => xml.Quantity.to_i,
        :amount => xml.AmountPaid
      }
    end
  end
  info
end

#get_order_list(options = {}) ⇒ Array

Get list of the account orders

The returned array contains hashes with the following keys

  • (String) :id – Order ID number

  • (Time) :date – Date the order was placed

  • (String) :status – Status of the order

  • (BOOL) :processed – Whether the order has been processed

Parameters:

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

    Options to get the order list with

Options Hash (options):

  • :start (Integer)

    Starting offset in order list

  • :begin (String, #strftime)

    String date or Date of earliest order to retrieve. If omitted then 6 months of orders are retrieved

  • :end (String, #strftime)

    String date or Date or lastest order to retrieve. If omitted then the end is today

Returns:

  • (Array)

    orders of :id, :date, :status and :processed



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/enom-api/client.rb', line 418

def get_order_list(options = {})
  xml = send_recv(:GetOrderList, :Start => (options[:start] || 1)) do |h|
    h[:BeginDate] = if options[:begin].respond_to?(:strftime)
      options[:begin].strftime("%m/%d/%Y")
    else
      options[:begin]
    end

    h[:EndDate] = if options[:end].respond_to?(:strftime)
      options[:end].strftime("%m/%d/%Y")
    else
      options[:end]
    end
  end

  out = []
  xml.OrderList do
    xml.OrderDetail do
      { :id => xml.OrderID,
        :date => Time.parse(xml.OrderDate),
        :status => xml.StatusDesc,
        :processed => xml.OrderProcessFlag? }
    end
  end
  out
end

#get_reg_lock(domain) ⇒ Boolean

Get the registrar lock setting for a domain

Parameters:

  • domain (String)

    Domain name to check registrar lock of

Returns:

  • (Boolean)

    locked state, true = locked



474
475
476
477
# File 'lib/enom-api/client.rb', line 474

def get_reg_lock(domain)
  xml = send_recv(:GetRegLock, split_domain(domain))
  xml.RegLock?
end

#get_registration_status(domain) ⇒ Hash

Get the registration status of a domain.

The returned hash has the following keys

  • (BOOL) :hold – Registrar hold set

  • (String) :registration – Registration status of the domain

  • (String) :purchase – Purchase status of the domain

Registration status will be one of

  1. Processing

  2. Registered

  3. Hosted

  4. Null

Purchase status will be one of

  1. Processing

  2. Paid

  3. Null

Parameters:

  • domain (String)

    Domain name to get registration status of

Returns:

  • (Hash)

    :hold and :status



465
466
467
468
# File 'lib/enom-api/client.rb', line 465

def get_registration_status(domain)
  xml = send_recv(:GetRegistrationStatus, split_domain(domain))
  { :hold => xml.RegistrarHold?, :registration => xml.RegistrationStatus, :purchase => xml.PurchaseStatus }
end

#get_tld_listArray<String>

Get the list of TLDs available for the account

Returns:

  • (Array<String>)

    array of TLDs available to the account



482
483
484
485
486
487
488
489
490
491
492
# File 'lib/enom-api/client.rb', line 482

def get_tld_list
  xml = send_recv(:GetTLDList)

  tlds = []
  xml.tldlist.tld do |tld,_|
    tld.tld do
      tlds << tld.to_s unless tld.to_s == ''
    end
  end
  tlds
end

#get_whois_contact(domain) ⇒ Hash

Gets the WHOIS contact details for a domain

The returned hash has the following keys

  • (Hash<Symbol,Registrant>) :contacts – Registrant object

  • (Time) :updated_date – Domain last update time

  • (Time) :created_date – Domain creation date

  • (Time) :expiry_date – Domain expiration date

  • (Array) :nameservers – Array of name server names

  • (String) :status – Registrar lock status

Parameters:

  • domain (String)

    Domain name to retrieve WHOIS information for

Returns:

  • (Hash)

    response data



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/enom-api/client.rb', line 506

def get_whois_contact(domain)
  xml = send_recv(:GetWhoisContact, split_domain(domain))

  out = {:contacts => {}}
  xml.GetWhoisContacts do
    xml.contacts.contact do |contact,_|
      case contact['ContactType']
      when 'Registrant'
        out[:contacts][:registrant] = Registrant.from_xml(contact)
      when 'Administrative'
        out[:contacts][:administrative] = Registrant.from_xml(contact)
      when 'Technical'
        out[:contacts][:technical] = Registrant.from_xml(contact)
      when 'Billing'
        out[:contacts][:billing] = Registrant.from_xml(contact)
      end
    end

    xml.send("rrp-info") do
      out[:updated_date] = Time.parse(xml.send("updated-date"))
      out[:created_date] = Time.parse(xml.send("created-date"))
      out[:expiry_date]  = Time.parse(xml.send("registration-expiration-date"))
      out[:nameservers]  = Array.new
      xml.nameserver do
        xml.nameserver do
          out[:nameservers] << xml.to_s.downcase
        end
      end
      xml.status do
        out[:status] = xml.status # != registration status from get_domain_info. = lock status
      end
    end
  end

  out
end

#inspectObject

:nodoc:



15
16
17
# File 'lib/enom-api/client.rb', line 15

def inspect # :nodoc:
  "#<#{self.class} #{@user}@#{@server}>"
end

#modify_ns(domain, *nameservers) ⇒ Object

Modify the name servers for a domain.

Parameters:

  • domain (String)

    Domain name to set the nameserver of

  • nameservers (String, ...)

    Nameservers to set for the domain

Raises:

  • (RuntimeError)

    if number of nameservers exceeds 12



625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/enom-api/client.rb', line 625

def modify_ns(domain, *nameservers)
  raise "Maximum nameserver limit is 12" if nameservers.size > 12
  xml = send_recv(:ModifyNS, split_domain(domain)) do |d|
    if nameservers.empty?
      d['NS1'] = ''
    else
      nameservers.each_with_index do |n,i|
        d["NS#{i+1}"] = n
      end
    end
  end
  xml.RRPCode == '200'
end

#purchase(domain, registrant, nameservers, options = {}) ⇒ Hash

Purchase a domain name.

The returned hash has the following keys

  • (Symbol) :result – Either :registered or :ordered. The latter if the TLD does not support real time registrations.

  • (String) :order_id – Order ID of the purchase

Parameters:

  • domain (String)

    Domain name to register

  • registrant (Registrant)

    Registrant of the domain

  • nameservers (Array<String>, nil)

    Nameservers to set for the domain, nil sends blank NS1

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

    Options to configure the registration

Options Hash (options):

  • :period (Integer)

    Number of years to register the domain for

Returns:

  • (Hash)

    :result => :registered and :order_id if successful

  • (Hash)

    :result => :ordered and :order_id if not a Real Time TLD

Raises:

  • (RuntimeError)

    if more than 12 nameservers are passed

  • (ResponseError)

    if regisration failed



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/enom-api/client.rb', line 682

def purchase(domain, registrant, nameservers, options = {})
  raise "Maximum nameserver limit is 12" if nameservers.size > 12
  opts = registrant.to_post_data('Registrant')
  opts[:NumYears] = options.delete(:period) if options.has_key?(:period)

  xml = send_recv(:Purchase, split_domain(domain).merge(opts)) do |d|
    if nameservers.empty?
      d['NS1'] = ''
    else
      nameservers.each_with_index do |n,i|
        d["NS#{i+1}"] = n
      end
    end
  end

  case xml.RRPCode.to_i
  when 200
    return { :result => :registered, :order_id => xml.OrderID }
  when 1300
    raise ResponseError.new([xml.RRPText]) if xml.IsRealTimeTLD?
    return { :result => :ordered, :order_id => xml.OrderID }
  end
end

#push_domain(domain, account_id, push_contact = true) ⇒ Boolean

Push a domain to another eNom account.

This is much like a domain transfer except it is wholly within the scope of eNoms registration system.

Parameters:

  • domain (String)

    Domain name to push

  • account_id (String)

    eNom Account ID to push the domain to

  • push_contact (Boolean) (defaults to: true)

    Should push the domain contact information

Returns:

  • (Boolean)

    whether the push was successful or not



565
566
567
568
569
# File 'lib/enom-api/client.rb', line 565

def push_domain(domain, , push_contact = true)
  xml = send_recv(:PushDomain, split_domain(domain).merge(
    :AccountID => , :PushContact => (push_contact ? 1 : 0)))
  xml.PushDomain?
end

#register_nameserver(nameserver, ip) ⇒ Object

Register a domain name server

Parameters:

  • nameserver (String)

    Nameserver to register

  • ip (String)

    IPv4 Address of the nameserver

Returns:

  • true if registration was successful

Raises:



577
578
579
580
# File 'lib/enom-api/client.rb', line 577

def register_nameserver(nameserver, ip)
  send_recv(:RegisterNameServer, :Add => 'true', :NSName => nameserver, :IP => ip)
  true  # send_recv will raise a ResponseError if ErrCount > 0
end

#search {|q| ... } ⇒ Array

Perform a search.

The returned array contains hashes with the following keys

  • (String) :id – Domain ID within the eNom registry

  • (String) :name – Domain name

  • (BOOL) :auto_renew – Whether auto-renew is set on the domain

  • (Time) :expires – Expiration date of the domain

  • (String) :status – Registration status of the domain

  • (Array) :nameservers – Nameserver names

Yields:

  • (q)

    block to build up search query

Yield Parameters:

Returns:

  • (Array)

    Array of hashes of search results including domain ID, name, auto_renew status, expiration date status and nameservers



34
35
36
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
# File 'lib/enom-api/client.rb', line 34

def search(&block)
  response = @conn.search(&block)
  xml = XML::Parser.string(response).parse

  o = Hash.new
  d = Demolisher.demolish(xml)
  d.send("interface-response") do
    d.DomainSearch do
      o[:total_results] = d.TotalResults.to_s.to_i
      o[:start_position] = d.StartPosition.to_s.to_i
      o[:next_position]  = d.NextPosition.to_s.to_i

      d.Domains do
        o[:results] = Array.new
        d.Domain do
          o[:results] << {
            :id => d.DomainNameID,
            :name => "#{d.SLD}.#{d.TLD}",
            :auto_renew => d.AutoRenew?,
            :expires => Time.parse(d.ExpDate),
            :status => d.DomainRegistrationStatus,
            :nameservers => (d.NameServers && d.NameServers.to_s.split(",")) }
        end
      end
    end
  end
  o
end

#set_reg_lock(domain, new_state) ⇒ false, String

Sets the registrar lock on a domain name.

Parameters:

  • domain (String)

    Domain to set the lock on

  • new_state (Boolean)

    True to lock, False to unlock

Returns:

  • (false)

    if setting failed

  • (String)

    lock status



588
589
590
591
592
593
594
# File 'lib/enom-api/client.rb', line 588

def set_reg_lock(domain, new_state) # true to lock, false to unlock
  xml = send_recv(:SetRegLock, split_domain(domain).merge(:UnlockRegistrar => (new_state ? '0' : '1')))

  ret = xml.RegistrarLock.strip
  return false if ret == 'Failed'
  ret
end

#status_domain(domain, type = 'Purchase') ⇒ Hash

Gets information about a domain

The returned hash contains the following keys

  • (BOOL) :known – Whether the domain is known to eNom

  • (BOOL) :in_account – Whether the domain belongs to the account

  • (String) :last_order_id – Last Order ID for the domain if domain belongs to the account

Parameters:

  • domain (String)

    Domain to check the status of

  • type (String) (defaults to: 'Purchase')

    Order Type to query with, one of ‘Purchase’, ‘Transfer’ or ‘Extend’

Returns:

  • (Hash)

    of information about the domain

Raises:

  • (ArgumentError)


649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/enom-api/client.rb', line 649

def status_domain(domain, type = 'Purchase')
  raise ArgumentError, "type must be Purchase, Transfer or Extend" unless %w(purchase transfer extend).include?(type.downcase)
  begin
    xml = send_recv(:StatusDomain, split_domain(domain).merge(:OrderType => type))

    xml.DomainStatus do
      return { :known => (xml.Known == 'Known'),
        :in_account => xml.InAccount?,  # It'll be either 0 or 1 here, case 2 raises an exception
        :last_order_id => xml.OrderID }
    end
  rescue ResponseError => e
    if e.messages.include?("The domain does not belong to this account")
      # It returns an error if the domain is known to eNom but in another account
      return { :known => true, :in_account => false }
    end
  end
end

#update_expired_domains(domain, years = 1) ⇒ String

Reactivates an expired domain in real time.

Parameters:

  • domain (String)

    Expired Domain name to register

  • years (Number) (defaults to: 1)

    Number of years to register the domain for

Returns:

  • (String)

    response status



601
602
603
604
605
606
607
# File 'lib/enom-api/client.rb', line 601

def update_expired_domains(domain, years = 1) # Like :extend, but for expired domains
  xml = send_recv(:UpdateExpiredDomains, :DomainName => domain, :NumYears => years.to_i)
  xml = xml.ReactivateDomainName

  return false unless xml.Status?
  xml.OrderID
end

#update_nameserver(nameserver, old_ip, new_ip) ⇒ Boolean

Change the IP address of a registered name server.

Parameters:

  • nameserver (String)

    Nameserver to update the IP address of

  • old_ip (String)

    Old IPv4 address of the nameserver

  • new_ip (String)

    New IPv4 address of the nameserver

Returns:

  • (Boolean)

    success or failure of the update



615
616
617
618
# File 'lib/enom-api/client.rb', line 615

def update_nameserver(nameserver, old_ip, new_ip)
  xml = send_recv(:RegisterNameServer, :NS => nameserver, :OldIP => old_ip, :NewIP => new_ip)
  xml.NSSuccess?
end