Module: Dnsimple::Client::Domains

Included in:
DomainsService
Defined in:
lib/dnsimple/client/domains.rb

Instance Method Summary collapse

Instance Method Details

#create_domain(attributes = {}, options = {}) ⇒ Struct::Domain Also known as: create

Creates a domain in the account.

Parameters:

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

Returns:

Raises:

See Also:



29
30
31
32
33
34
35
# File 'lib/dnsimple/client/domains.rb', line 29

def create_domain(attributes = {}, options = {})
  Extra.validate_mandatory_attributes(attributes, [:name])
  options  = options.merge({ domain: attributes })
  response = client.post(Client.versioned("/domains"), options)

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

#delete_domain(domain, options = {}) ⇒ void Also known as: delete

This method returns an undefined value.

Deletes a domain from the account.

WARNING: this cannot be undone.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Raises:

See Also:



64
65
66
# File 'lib/dnsimple/client/domains.rb', line 64

def delete_domain(domain, options = {})
  client.delete(Client.versioned("/domains/#{domain}"), options)
end

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

Gets a domain from the account.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Returns:

Raises:

See Also:



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

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

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

#domains(options = {}) ⇒ Array<Struct::Domain> Also known as: list, list_domains

Lists the domains in the account.

Parameters:

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

    the filtering and sorting option

Returns:

Raises:

See Also:



13
14
15
16
17
# File 'lib/dnsimple/client/domains.rb', line 13

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

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