Module: Dnsimple::Client::Registrar

Included in:
RegistrarService
Defined in:
lib/dnsimple/client/registrar.rb

Instance Method Summary collapse

Instance Method Details

#available?(name, options = {}) ⇒ Boolean

Checks the availability of a domain name.

Parameters:

  • name (#to_s)

    The domain name to check.

Returns:

  • (Boolean)

    true if the domain is available

Raises:

See Also:



31
32
33
# File 'lib/dnsimple/client/registrar.rb', line 31

def available?(name, options = {})
  check(name, options)["status"] == "available"
end

#check(name, options = {}) ⇒ Hash

Checks the availability of a domain name.

Parameters:

  • name (#to_s)

    The domain name to check.

Returns:

  • (Hash)

    The response containing the status, price, and more details.

Raises:

See Also:



13
14
15
16
17
18
19
20
21
# File 'lib/dnsimple/client/registrar.rb', line 13

def check(name, options = {})
  response = begin
    client.get(Client.versioned("/domains/#{name}/check"), options)
  rescue NotFoundError => e
    e.response
  end

  response.parsed_response
end

#extended_attributes(tld, options = {}) ⇒ Array<Struct::ExtendedAttribute> Also known as: list_extended_attributes

List the extended attributes for a TLD.

Parameters:

  • tld (#to_s)

    The TLD name.

Returns:

Raises:

See Also:



97
98
99
100
101
# File 'lib/dnsimple/client/registrar.rb', line 97

def extended_attributes(tld, options = {})
  response = client.get(Client.versioned("/extended_attributes/#{tld}"), options)

  response.map { |r| Struct::ExtendedAttribute.new(r) }
end

#prices(options = {}) ⇒ Array<Struct::Price> Also known as: list_prices

List all the TLD prices.

Returns:

Raises:

See Also:



111
112
113
114
115
# File 'lib/dnsimple/client/registrar.rb', line 111

def prices(options = {})
  response = client.get(Client.versioned("/prices"), options)

  response.map { |r| Struct::Price.new(r["price"]) }
end

#register(name, registrant_id, extended_attributes = {}, options = {}) ⇒ Struct::Domain

Registers a domain.

Parameters:

  • name (#to_s)

    The domain name to register.

  • registrant_id (Fixnum)

    The id of the contact to use as registrant.

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

Returns:

Raises:

See Also:



46
47
48
49
50
51
# File 'lib/dnsimple/client/registrar.rb', line 46

def register(name, registrant_id, extended_attributes = {}, options = {})
  options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes })
  response = client.post(Client.versioned("/domain_registrations"), options)

  Struct::Domain.new(response["domain"])
end

#renew(name, options = {}) ⇒ Struct::Domain

Renew a domain.

Parameters:

  • name (#to_s)

    The domain name to renew.

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

Returns:

Raises:

See Also:



81
82
83
84
85
86
# File 'lib/dnsimple/client/registrar.rb', line 81

def renew(name, options = {})
  options = Extra.deep_merge(options, { domain: { name: name }})
  response = client.post(Client.versioned("/domain_renewals"), options)

  Struct::Domain.new(response["domain"])
end

#transfer(name, auth_code, registrant_id, extended_attributes = {}, options = {}) ⇒ Struct::TransferOrder

Transfers a domain.

Parameters:

  • name (#to_s)

    The domain name to register.

  • auth_code (String)
  • registrant_id (Fixnum)

    The id of the contact to use as registrant.

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

Returns:

Raises:

See Also:



65
66
67
68
69
70
# File 'lib/dnsimple/client/registrar.rb', line 65

def transfer(name, auth_code, registrant_id, extended_attributes = {}, options = {})
  options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes, transfer_order: { authinfo: auth_code }})
  response = client.post(Client.versioned("/domain_transfers"), options)

  Struct::TransferOrder.new(response["transfer_order"])
end