Class: Dnsimple::Client::ContactsService

Inherits:
ClientService show all
Defined in:
lib/dnsimple/client/contacts_service.rb

Instance Attribute Summary

Attributes inherited from ClientService

#client

Instance Method Summary collapse

Instance Method Details

#create(attributes = {}) ⇒ Contact

Creates a contact in the account.

Parameters:

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

Returns:

Raises:

See Also:



25
26
27
28
29
30
31
# File 'lib/dnsimple/client/contacts_service.rb', line 25

def create(attributes = {})
  Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address])
  options  = { contact: attributes }
  response = client.post("v1/contacts", options)

  Contact.new(response["contact"])
end

#delete(contact) ⇒ void

This method returns an undefined value.

Deletes a contact from the account.

WARNING: this cannot be undone.

Parameters:

  • contact (Fixnum)

    The contact id.

Raises:

See Also:



76
77
78
# File 'lib/dnsimple/client/contacts_service.rb', line 76

def delete(contact)
  client.delete("v1/contacts/#{contact}")
end

#find(contact) ⇒ Contact

Gets a contact from the account.

Parameters:

  • contact (Fixnum)

    The contact id.

Returns:

Raises:

See Also:



42
43
44
45
46
# File 'lib/dnsimple/client/contacts_service.rb', line 42

def find(contact)
  response = client.get("v1/contacts/#{contact}")

  Contact.new(response["contact"])
end

#listArray<Contact>

Lists the contacts in the account.

Returns:

Raises:

See Also:



11
12
13
14
15
# File 'lib/dnsimple/client/contacts_service.rb', line 11

def list
  response = client.get("v1/contacts")

  response.map { |r| Contact.new(r["contact"]) }
end

#update(contact, attributes = {}) ⇒ Contact

Updates a contact in the account.

Parameters:

  • contact (Fixnum)

    The contact id.

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

Returns:

Raises:

See Also:



58
59
60
61
62
63
# File 'lib/dnsimple/client/contacts_service.rb', line 58

def update(contact, attributes = {})
  options  = { contact: attributes }
  response = client.put("v1/contacts/#{contact}", options)

  Contact.new(response["contact"])
end