Module: Dnsimple::Client::Contacts
- Included in:
- ContactsService
- Defined in:
- lib/dnsimple/client/contacts.rb
Instance Method Summary collapse
-
#contact(contact, options = {}) ⇒ Struct::Contact
Gets a contact from the account.
-
#contacts(options = {}) ⇒ Array<Struct::Contact>
(also: #list, #list_contacts)
Lists the contacts in the account.
-
#create_contact(attributes = {}, options = {}) ⇒ Struct::Contact
(also: #create)
Creates a contact in the account.
-
#delete_contact(contact, options = {}) ⇒ void
(also: #delete)
Deletes a contact from the account.
-
#update_contact(contact, attributes = {}, options = {}) ⇒ Struct::Contact
(also: #update)
Updates a contact in the account.
Instance Method Details
#contact(contact, options = {}) ⇒ Struct::Contact
Gets a contact from the account.
46 47 48 49 50 |
# File 'lib/dnsimple/client/contacts.rb', line 46 def contact(contact, = {}) response = client.get(Client.versioned("/contacts/#{contact}"), ) Struct::Contact.new(response["contact"]) end |
#contacts(options = {}) ⇒ Array<Struct::Contact> Also known as: list, list_contacts
Lists the contacts in the account.
12 13 14 15 16 |
# File 'lib/dnsimple/client/contacts.rb', line 12 def contacts( = {}) response = client.get(Client.versioned("/contacts"), ) response.map { |r| Struct::Contact.new(r["contact"]) } end |
#create_contact(attributes = {}, options = {}) ⇒ Struct::Contact Also known as: create
Creates a contact in the account.
28 29 30 31 32 33 34 |
# File 'lib/dnsimple/client/contacts.rb', line 28 def create_contact(attributes = {}, = {}) Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address]) = .merge(contact: attributes) response = client.post(Client.versioned("/contacts"), ) Struct::Contact.new(response["contact"]) end |
#delete_contact(contact, options = {}) ⇒ void Also known as: delete
This method returns an undefined value.
Deletes a contact from the account.
WARNING: this cannot be undone.
81 82 83 |
# File 'lib/dnsimple/client/contacts.rb', line 81 def delete_contact(contact, = {}) client.delete(Client.versioned("contacts/#{contact}"), ) end |
#update_contact(contact, attributes = {}, options = {}) ⇒ Struct::Contact Also known as: update
Updates a contact in the account.
62 63 64 65 66 67 |
# File 'lib/dnsimple/client/contacts.rb', line 62 def update_contact(contact, attributes = {}, = {}) = .merge(contact: attributes) response = client.put(Client.versioned("/contacts/#{contact}"), ) Struct::Contact.new(response["contact"]) end |