Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

registrar-client

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

registrar-client

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

Registrar Client

This library provides a common API for communicating with multiple registrars. This is necessary since different registrars support different TLDs and different add-on services.

Usage

To construct a client, first require both the generic API interface as well as a specific provider. Construct the provider and pass it to the client interface:

require 'registrar'
require 'registrar/provider/enom'

# set url, username and password to Enom API endpoint, username and password respectively
provider = Registrar::Provider::Enom.new(url, username, password)
client = Registrar::Client.new(provider)

To split a domain into its TLD and its remaining part:

name = 'example.com'
client.parse(name)
=> ['example','com']

To check the availability of a domain name for registration:

client.available?(name)
=> true

To register a domain name, first construct contact:

registrant = Registrar::Contact.new(
  :first_name => 'Anthony',
  :last_name => 'Eden',
  :address_1 => '123 SW 1st Street',
  :city => 'Anywhere',
  :country => 'US',
  :postal_code => '12121',
  :phone => '444 555 1212',
  :email => 'anthony@dnsimple.com'
)

Next pass the name plus the contact (as the registrant) to the purchase method:

order = client.purchase(name, registrant)

The resulting order may be complete...

domains = order.domains if order.complete?
=> [#<Registrar::Domain:0x10034d298>]
domain = domains[0]
=> 
domain.name
=> "example.com"

Or the resulting order may be in process...

order.status unless order.complete?
=> :open

The status of the domain may be open in cases where a domain is not registered in real-time. Quite often country-code top level domains are not real-time and require additional out-of-band processing and documentation.

If you need to pass in additional purchase options:

purchase_options = Registrar::PurchaseOptions.new
purchase_options.name_servers << Registrar::NameServer.new('ns1.example.com')
purchase_options.name_servers << Registrar::NameServer.new('ns2.example.com')
purchase_options.extended_attributes << Registrar::ExtendedAttribute.new('name', 'value')
purchase_options.number_of_years = 2

order = client.purchase(name, registrant, purchase_options)
domain = order.domain
=> #<Registrar::Domain:"example.com">

FAQs

Package last updated on 20 Apr 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc