Module: Dnsimple::Client::Contacts
- Included in:
- ContactsService
- Defined in:
- lib/dnsimple/client/contacts.rb
Instance Method Summary collapse
-
#all_contacts(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Contact>
(also: #all)
Lists ALL the contacts in the account.
-
#contact(account_id, contact_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact>
Gets a contact from the account.
-
#contacts(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Contact>
(also: #list, #list_contacts)
Lists the contacts in the account.
-
#create_contact(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact>
(also: #create)
Creates a contact in the account.
-
#delete_contact(account_id, contact_id, options = {}) ⇒ Dnsimple::Response<nil>
(also: #delete)
Deletes a contact from the account.
-
#update_contact(account_id, contact_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact>
(also: #update)
Updates a contact in the account.
Instance Method Details
#all_contacts(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Contact> Also known as: all
Lists ALL the contacts in the account.
This method is similar to #contacts, but instead of returning the results of a specific page it iterates all the pages and returns the entire collection.
Please use this method carefully, as fetching the entire collection will increase the number of requests you send to the API server and you may eventually risk to hit the throttle limit.
45 46 47 |
# File 'lib/dnsimple/client/contacts.rb', line 45 def all_contacts(account_id, = {}) paginate(:contacts, account_id, ) end |
#contact(account_id, contact_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact>
Gets a contact from the account.
79 80 81 82 83 |
# File 'lib/dnsimple/client/contacts.rb', line 79 def contact(account_id, contact_id, = {}) response = client.get(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), ) Dnsimple::Response.new(response, Struct::Contact.new(response["data"])) end |
#contacts(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Contact> Also known as: list, list_contacts
Lists the contacts in the account.
21 22 23 24 25 |
# File 'lib/dnsimple/client/contacts.rb', line 21 def contacts(account_id, = {}) response = client.get(Client.versioned("/%s/contacts" % [account_id]), ) Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Contact.new(r) }) end |
#create_contact(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact> Also known as: create
Creates a contact in the account.
60 61 62 63 64 65 |
# File 'lib/dnsimple/client/contacts.rb', line 60 def create_contact(account_id, attributes, = {}) Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address]) response = client.post(Client.versioned("/%s/contacts" % [account_id]), attributes, ) Dnsimple::Response.new(response, Struct::Contact.new(response["data"])) end |
#delete_contact(account_id, contact_id, options = {}) ⇒ Dnsimple::Response<nil> Also known as: delete
Deletes a contact from the account.
WARNING: this cannot be undone.
116 117 118 119 120 |
# File 'lib/dnsimple/client/contacts.rb', line 116 def delete_contact(account_id, contact_id, = {}) response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), nil, ) Dnsimple::Response.new(response, nil) end |
#update_contact(account_id, contact_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Contact> Also known as: update
Updates a contact in the account.
96 97 98 99 100 |
# File 'lib/dnsimple/client/contacts.rb', line 96 def update_contact(account_id, contact_id, attributes, = {}) response = client.patch(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), attributes, ) Dnsimple::Response.new(response, Struct::Contact.new(response["data"])) end |