Module: Dnsimple::Client::Collaborators

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

Instance Method Summary collapse

Instance Method Details

#add_collaborator(account_id, domain_id, attributes, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Collaborator>

Add a collaborator to the domain.

Examples:

Add collaborator

client.domains.add_collaborator(1010, "example.com", email: "[email protected]")

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or name

  • user (Hash)

    attributes

  • attributes (String)

    :email user email (mandatory)

  • request (Hash)

    options

Returns:

Raises:

See Also:



44
45
46
47
48
49
# File 'lib/dnsimple/client/collaborators.rb', line 44

def add_collaborator(, domain_id, attributes, options = {})
  Extra.validate_mandatory_attributes(attributes, [:email])
  response = client.post(Client.versioned("/%s/domains/%s/collaborators" % [, domain_id]), attributes, options)

  Dnsimple::Response.new(response, Struct::Collaborator.new(response["data"]))
end

#collaborators(account_id, domain_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Collaborator>

Lists the collaborators for a domain.

Examples:

List collaborators in the first page

client.domains.collaborators(1010, "example.com")

List collaborators, provide a specific page

client.domains.collaborators(1010, "example.com", page: 2)

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or name

  • request (Hash)

    options

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

    a customizable set of options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

Returns:

Raises:

See Also:



23
24
25
26
27
# File 'lib/dnsimple/client/collaborators.rb', line 23

def collaborators(, domain_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/collaborators" % [, domain_id]), Options::ListOptions.new(options))

  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Collaborator.new(r) })
end

#remove_collaborator(account_id, domain_id, contact_id, options = {}) ⇒ Dnsimple::Response<nil>

Removes a collaborator from the domain.

WARNING: this cannot be undone.

Examples:

Remove collaborator

client.domains.remove_collaborator(1010, "example.com", 999)

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or name

  • contact_id (#to_s)

    the contact ID

  • request (Hash)

    options

Returns:

Raises:

See Also:



68
69
70
71
72
# File 'lib/dnsimple/client/collaborators.rb', line 68

def remove_collaborator(, domain_id, contact_id, options = {})
  response = client.delete(Client.versioned("/%s/domains/%s/collaborators/%s" % [, domain_id, contact_id]), options)

  Dnsimple::Response.new(response, nil)
end