dnsimple 2.2.0 → 3.0.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -1
- data/CHANGELOG.md +13 -2
- data/CONTRIBUTING.md +35 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +30 -82
- data/dnsimple.gemspec +2 -1
- data/lib/dnsimple.rb +0 -2
- data/lib/dnsimple/client.rb +64 -64
- data/lib/dnsimple/client/clients.rb +82 -58
- data/lib/dnsimple/client/contacts.rb +74 -37
- data/lib/dnsimple/client/domains.rb +82 -28
- data/lib/dnsimple/client/domains_email_forwards.rb +107 -0
- data/lib/dnsimple/client/identity.rb +38 -0
- data/lib/dnsimple/client/oauth.rb +42 -0
- data/lib/dnsimple/client/registrar.rb +64 -72
- data/lib/dnsimple/client/registrar_auto_renewal.rb +41 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +74 -0
- data/lib/dnsimple/client/tlds.rb +88 -0
- data/lib/dnsimple/client/webhooks.rb +82 -0
- data/lib/dnsimple/client/zones.rb +68 -0
- data/lib/dnsimple/client/zones_records.rb +127 -0
- data/lib/dnsimple/default.rb +10 -17
- data/lib/dnsimple/error.rb +5 -8
- data/lib/dnsimple/extra.rb +1 -1
- data/lib/dnsimple/response.rb +80 -0
- data/lib/dnsimple/struct.rb +13 -14
- data/lib/dnsimple/struct/account.rb +13 -0
- data/lib/dnsimple/struct/contact.rb +6 -3
- data/lib/dnsimple/struct/domain.rb +10 -10
- data/lib/dnsimple/struct/domain_check.rb +16 -0
- data/lib/dnsimple/struct/email_forward.rb +11 -1
- data/lib/dnsimple/struct/oauth_token.rb +19 -0
- data/lib/dnsimple/struct/record.rb +25 -7
- data/lib/dnsimple/struct/tld.rb +22 -0
- data/lib/dnsimple/struct/user.rb +3 -7
- data/lib/dnsimple/struct/webhook.rb +13 -0
- data/lib/dnsimple/struct/whois_privacy.rb +8 -5
- data/lib/dnsimple/struct/zone.rb +25 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/client_service_spec.rb +37 -0
- data/spec/dnsimple/client/contacts_spec.rb +108 -78
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +190 -0
- data/spec/dnsimple/client/domains_spec.rb +121 -58
- data/spec/dnsimple/client/identity_spec.rb +56 -0
- data/spec/dnsimple/client/oauth_spec.rb +48 -0
- data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +80 -0
- data/spec/dnsimple/client/registrar_spec.rb +109 -122
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +119 -0
- data/spec/dnsimple/client/tlds_spec.rb +139 -0
- data/spec/dnsimple/client/webhooks_spec.rb +142 -0
- data/spec/dnsimple/client/zones_records_spec.rb +277 -0
- data/spec/dnsimple/client/zones_spec.rb +109 -0
- data/spec/dnsimple/client_spec.rb +34 -46
- data/spec/dnsimple/extra_spec.rb +22 -0
- data/spec/{files → fixtures.http}/badgateway.http +14 -14
- data/spec/fixtures.http/checkDomain/success.http +17 -0
- data/spec/fixtures.http/createContact/created.http +17 -0
- data/spec/fixtures.http/createDomain/created.http +16 -0
- data/spec/fixtures.http/createEmailForward/created.http +17 -0
- data/spec/fixtures.http/createWebhook/created.http +17 -0
- data/spec/fixtures.http/createZoneRecord/created.http +17 -0
- data/spec/fixtures.http/deleteContact/success.http +13 -0
- data/spec/fixtures.http/deleteDomain/success.http +13 -0
- data/spec/fixtures.http/deleteEmailForward/success.http +12 -0
- data/spec/fixtures.http/deleteWebhook/success.http +13 -0
- data/spec/fixtures.http/deleteZoneRecord/success.http +13 -0
- data/spec/fixtures.http/disableAutoRenewal/success.http +12 -0
- data/spec/fixtures.http/disableWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/enableAutoRenewal/success.http +12 -0
- data/spec/fixtures.http/enableWhoisPrivacy/created.http +17 -0
- data/spec/fixtures.http/enableWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/getContact/success.http +17 -0
- data/spec/fixtures.http/getDomain/success.http +16 -0
- data/spec/fixtures.http/getEmailForward/success.http +17 -0
- data/spec/fixtures.http/getTld/success.http +17 -0
- data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +17 -0
- data/spec/fixtures.http/getTldExtendedAttributes/success.http +17 -0
- data/spec/fixtures.http/getWebhook/success.http +17 -0
- data/spec/fixtures.http/getWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/getZone/success.http +17 -0
- data/spec/fixtures.http/getZoneRecord/success.http +17 -0
- data/spec/fixtures.http/listContacts/success.http +17 -0
- data/spec/fixtures.http/listDomains/success.http +16 -0
- data/spec/fixtures.http/listEmailForwards/success.http +17 -0
- data/spec/fixtures.http/listTlds/success.http +17 -0
- data/spec/fixtures.http/listWebhooks/success.http +17 -0
- data/spec/fixtures.http/listZoneRecords/success.http +17 -0
- data/spec/fixtures.http/listZones/success.http +17 -0
- data/spec/fixtures.http/notfound-contact.http +12 -0
- data/spec/fixtures.http/notfound-domain.http +12 -0
- data/spec/fixtures.http/notfound-emailforward.http +12 -0
- data/spec/fixtures.http/notfound-record.http +12 -0
- data/spec/fixtures.http/notfound-webhook.http +12 -0
- data/spec/fixtures.http/notfound-zone.http +12 -0
- data/spec/fixtures.http/oauthAccessToken/success.http +17 -0
- data/spec/fixtures.http/pages-1of3.http +16 -0
- data/spec/fixtures.http/pages-2of3.http +16 -0
- data/spec/fixtures.http/pages-3of3.http +16 -0
- data/spec/fixtures.http/registerDomain/success.http +17 -0
- data/spec/fixtures.http/renewDomain/error-tooearly.http +15 -0
- data/spec/fixtures.http/renewDomain/success.http +17 -0
- data/spec/fixtures.http/resetDomainToken/success.http +17 -0
- data/spec/fixtures.http/response.http +16 -0
- data/spec/fixtures.http/transferDomain/error-indnsimple.http +15 -0
- data/spec/fixtures.http/transferDomain/error-missing-authcode.http +15 -0
- data/spec/fixtures.http/transferDomain/success.http +17 -0
- data/spec/fixtures.http/transferDomainOut/success.http +13 -0
- data/spec/fixtures.http/updateContact/success.http +17 -0
- data/spec/fixtures.http/updateZoneRecord/success.http +17 -0
- data/spec/fixtures.http/whoami/success.http +16 -0
- data/spec/fixtures.http/whoami/success_account.http +16 -0
- data/spec/fixtures.http/whoami/success_user.http +16 -0
- data/spec/spec_helper.rb +0 -6
- data/spec/support/helpers.rb +4 -4
- metadata +161 -238
- data/lib/dnsimple/client/certificates.rb +0 -100
- data/lib/dnsimple/client/domains_autorenewal.rb +0 -35
- data/lib/dnsimple/client/domains_forwards.rb +0 -71
- data/lib/dnsimple/client/domains_privacy.rb +0 -35
- data/lib/dnsimple/client/domains_records.rb +0 -90
- data/lib/dnsimple/client/domains_sharing.rb +0 -54
- data/lib/dnsimple/client/domains_zones.rb +0 -22
- data/lib/dnsimple/client/name_servers.rb +0 -71
- data/lib/dnsimple/client/services.rb +0 -37
- data/lib/dnsimple/client/services_domains.rb +0 -68
- data/lib/dnsimple/client/templates.rb +0 -88
- data/lib/dnsimple/client/templates_domains.rb +0 -23
- data/lib/dnsimple/client/templates_records.rb +0 -88
- data/lib/dnsimple/client/users.rb +0 -39
- data/lib/dnsimple/client/vanity_name_servers.rb +0 -39
- data/lib/dnsimple/compatibility.rb +0 -46
- data/lib/dnsimple/struct/certificate.rb +0 -56
- data/lib/dnsimple/struct/membership.rb +0 -22
- data/lib/dnsimple/struct/price.rb +0 -16
- data/lib/dnsimple/struct/service.rb +0 -19
- data/lib/dnsimple/struct/template.rb +0 -19
- data/lib/dnsimple/struct/template_record.rb +0 -24
- data/lib/dnsimple/struct/transfer_order.rb +0 -10
- data/spec/dnsimple/client/certificates_spec.rb +0 -196
- data/spec/dnsimple/client/domains_autorenewals_spec.rb +0 -72
- data/spec/dnsimple/client/domains_forwards_spec.rb +0 -146
- data/spec/dnsimple/client/domains_privacy_spec.rb +0 -74
- data/spec/dnsimple/client/domains_records_spec.rb +0 -191
- data/spec/dnsimple/client/domains_sharing_spec.rb +0 -109
- data/spec/dnsimple/client/domains_zones_spec.rb +0 -40
- data/spec/dnsimple/client/name_servers_spec.rb +0 -131
- data/spec/dnsimple/client/services_domains_spec.rb +0 -101
- data/spec/dnsimple/client/services_spec.rb +0 -69
- data/spec/dnsimple/client/templates_domains_spec.rb +0 -38
- data/spec/dnsimple/client/templates_records_spec.rb +0 -180
- data/spec/dnsimple/client/templates_spec.rb +0 -166
- data/spec/dnsimple/client/users_spec.rb +0 -70
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +0 -61
- data/spec/dnsimple/compatibility_spec.rb +0 -57
- data/spec/files/2fa/error-badtoken.http +0 -22
- data/spec/files/2fa/error-required.http +0 -23
- data/spec/files/2fa/exchange-token.http +0 -22
- data/spec/files/certificates/configure/success.http +0 -19
- data/spec/files/certificates/get/success.http +0 -19
- data/spec/files/certificates/list/success.http +0 -19
- data/spec/files/certificates/notfound.http +0 -19
- data/spec/files/certificates/purchase/success.http +0 -19
- data/spec/files/certificates/submit/success.http +0 -19
- data/spec/files/contacts/contact/success.http +0 -19
- data/spec/files/contacts/contacts/success.http +0 -23
- data/spec/files/contacts/create_contact/badrequest-missingcontact.http +0 -19
- data/spec/files/contacts/create_contact/badrequest-validationerror.http +0 -19
- data/spec/files/contacts/create_contact/created.http +0 -22
- data/spec/files/contacts/delete_contact/success-204.http +0 -18
- data/spec/files/contacts/delete_contact/success.http +0 -19
- data/spec/files/contacts/notfound-contact.http +0 -19
- data/spec/files/contacts/update_contact/success.http +0 -21
- data/spec/files/domains/create_domain/created.http +0 -21
- data/spec/files/domains/create_forward/created.http +0 -22
- data/spec/files/domains/create_membership/success.http +0 -21
- data/spec/files/domains/create_record/created.http +0 -21
- data/spec/files/domains/delete_domain/success-204.http +0 -18
- data/spec/files/domains/delete_domain/success.http +0 -19
- data/spec/files/domains/delete_forward/success.http +0 -17
- data/spec/files/domains/delete_membership/success.http +0 -17
- data/spec/files/domains/delete_record/success-204.http +0 -18
- data/spec/files/domains/delete_record/success.http +0 -19
- data/spec/files/domains/disable_auto_renewal/success.http +0 -21
- data/spec/files/domains/disable_whois_privacy/success.http +0 -21
- data/spec/files/domains/domain/success.http +0 -21
- data/spec/files/domains/domains/success.http +0 -21
- data/spec/files/domains/enable_auto_renewal/success.http +0 -21
- data/spec/files/domains/enable_whois_privacy/success.http +0 -22
- data/spec/files/domains/forward/success.http +0 -21
- data/spec/files/domains/forwards/success.http +0 -21
- data/spec/files/domains/memberships/success.http +0 -21
- data/spec/files/domains/notfound-domain.http +0 -19
- data/spec/files/domains/notfound-forward.http +0 -19
- data/spec/files/domains/notfound-membership.http +0 -19
- data/spec/files/domains/record/success.http +0 -19
- data/spec/files/domains/records/success.http +0 -19
- data/spec/files/domains/update_record/success.http +0 -21
- data/spec/files/domains/zone/success.http +0 -21
- data/spec/files/nameservers/change/success.http +0 -23
- data/spec/files/nameservers/deregister/success.http +0 -17
- data/spec/files/nameservers/name_servers/success.http +0 -23
- data/spec/files/nameservers/notfound-domain.http +0 -19
- data/spec/files/nameservers/register/badrequest-valueerror.http +0 -19
- data/spec/files/nameservers/register/success.http +0 -21
- data/spec/files/nameservers/vanity_name_servers/disabled.http +0 -23
- data/spec/files/nameservers/vanity_name_servers/enabled.http +0 -23
- data/spec/files/registrar/check/available.http +0 -19
- data/spec/files/registrar/check/registered.http +0 -21
- data/spec/files/registrar/extended_attributes/success.http +0 -21
- data/spec/files/registrar/prices/success.http +0 -21
- data/spec/files/registrar/register/badrequest-missingdomain.http +0 -19
- data/spec/files/registrar/register/badrequest-missingregistrant.http +0 -19
- data/spec/files/registrar/register/success.http +0 -21
- data/spec/files/registrar/renew/badrequest-missingrenewal.http +0 -19
- data/spec/files/registrar/renew/badrequest-unable.http +0 -19
- data/spec/files/registrar/renew/success.http +0 -21
- data/spec/files/registrar/transfer/success.http +0 -21
- data/spec/files/services/applied/success.http +0 -21
- data/spec/files/services/apply/success.http +0 -21
- data/spec/files/services/available/success.http +0 -21
- data/spec/files/services/notfound-service.http +0 -19
- data/spec/files/services/service/success.http +0 -21
- data/spec/files/services/services/success.http +0 -21
- data/spec/files/services/unapply/success.http +0 -21
- data/spec/files/subscriptions/subscription/success.http +0 -21
- data/spec/files/templates/apply_template/success.http +0 -21
- data/spec/files/templates/create_template/created.http +0 -22
- data/spec/files/templates/delete_template/success-204.http +0 -21
- data/spec/files/templates/delete_template/success.http +0 -21
- data/spec/files/templates/notfound-template.http +0 -19
- data/spec/files/templates/template/success.http +0 -21
- data/spec/files/templates/templates/success.http +0 -21
- data/spec/files/templates/update_template/success.http +0 -21
- data/spec/files/templates_records/create_record/created.http +0 -22
- data/spec/files/templates_records/delete_record/success-204.http +0 -19
- data/spec/files/templates_records/delete_record/success.http +0 -21
- data/spec/files/templates_records/notfound-template-record.http +0 -19
- data/spec/files/templates_records/record/success.http +0 -21
- data/spec/files/templates_records/records/success.http +0 -21
- data/spec/files/templates_records/update_record/success.http +0 -21
- data/spec/files/users/user/success.http +0 -21
@@ -1,14 +1,9 @@
|
|
1
1
|
module Dnsimple
|
2
2
|
class Client
|
3
3
|
|
4
|
-
# @return [Dnsimple::Client::CertificatesService] The certificate-related API proxy.
|
5
|
-
def certificates
|
6
|
-
@services[:certificates] ||= Client::CertificatesService.new(self)
|
7
|
-
end
|
8
|
-
|
9
4
|
# @return [Dnsimple::Client::ContactsService] The contact-related API proxy.
|
10
5
|
def contacts
|
11
|
-
@services[:
|
6
|
+
@services[:domains] ||= Client::ContactsService.new(self)
|
12
7
|
end
|
13
8
|
|
14
9
|
# @return [Dnsimple::Client::DomainsService] The domain-related API proxy.
|
@@ -16,9 +11,14 @@ module Dnsimple
|
|
16
11
|
@services[:domains] ||= Client::DomainsService.new(self)
|
17
12
|
end
|
18
13
|
|
19
|
-
# @return [Dnsimple::Client::
|
20
|
-
def
|
21
|
-
@services[:
|
14
|
+
# @return [Dnsimple::Client::IdentityService] The identity-related API proxy.
|
15
|
+
def identity
|
16
|
+
@services[:auth] ||= Client::IdentityService.new(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Dnsimple::Client::OauthService] The oauth-related API proxy.
|
20
|
+
def oauth
|
21
|
+
@services[:oauth] ||= Client::OauthService.new(self)
|
22
22
|
end
|
23
23
|
|
24
24
|
# @return [Dnsimple::Client::RegistrarService] The registrar-related API proxy.
|
@@ -26,100 +26,124 @@ module Dnsimple
|
|
26
26
|
@services[:registrar] ||= Client::RegistrarService.new(self)
|
27
27
|
end
|
28
28
|
|
29
|
-
# @return [Dnsimple::Client::
|
30
|
-
def
|
31
|
-
@services[:
|
29
|
+
# @return [Dnsimple::Client::TldsService] The tld-related API proxy.
|
30
|
+
def tlds
|
31
|
+
@services[:tlds] ||= Client::TldsService.new(self)
|
32
32
|
end
|
33
33
|
|
34
|
-
# @return [Dnsimple::Client::
|
35
|
-
def
|
36
|
-
@services[:
|
34
|
+
# @return [Dnsimple::Client::ZonesService] The zone-related API proxy.
|
35
|
+
def zones
|
36
|
+
@services[:zones] ||= Client::ZonesService.new(self)
|
37
37
|
end
|
38
38
|
|
39
|
-
# @return [Dnsimple::Client::
|
40
|
-
def
|
41
|
-
@services[:
|
39
|
+
# @return [Dnsimple::Client::WebhooksService] The webhooks-related API proxy.
|
40
|
+
def webhooks
|
41
|
+
@services[:webhooks] ||= Client::WebhooksService.new(self)
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
|
+
# @!class Struct
|
45
46
|
class ClientService < ::Struct.new(:client)
|
46
|
-
end
|
47
47
|
|
48
|
+
# Internal helper that loops over a paginated response and returns all the records in the collection.
|
49
|
+
#
|
50
|
+
# @api private
|
51
|
+
#
|
52
|
+
# @param [Symbol] method The client method to execute
|
53
|
+
# @param [Array] args The args to call the method with
|
54
|
+
# @return [Dnsimple::CollectionResponse]
|
55
|
+
def paginate(method, *args)
|
56
|
+
current_page = 0
|
57
|
+
total_pages = nil
|
58
|
+
collection = []
|
59
|
+
options = args.pop
|
60
|
+
response = nil
|
61
|
+
|
62
|
+
begin
|
63
|
+
current_page += 1
|
64
|
+
query = Extra.deep_merge(options, query: { page: current_page, per_page: 100 })
|
65
|
+
|
66
|
+
response = send(method, *(args + [query]))
|
67
|
+
total_pages ||= response.total_pages
|
68
|
+
collection.concat(response.data)
|
69
|
+
end while current_page < total_pages
|
48
70
|
|
49
|
-
|
71
|
+
CollectionResponse.new(response.http_response, collection)
|
72
|
+
end
|
50
73
|
|
51
|
-
class CertificatesService < ClientService
|
52
|
-
include Client::Certificates
|
53
74
|
end
|
54
75
|
|
55
76
|
|
56
|
-
|
77
|
+
require_relative 'contacts'
|
57
78
|
|
58
79
|
class ContactsService < ClientService
|
59
80
|
include Client::Contacts
|
60
81
|
end
|
61
82
|
|
62
83
|
|
63
|
-
|
64
|
-
|
65
|
-
require 'dnsimple/client/domains_autorenewal'
|
66
|
-
require 'dnsimple/client/domains_privacy'
|
67
|
-
require 'dnsimple/client/domains_sharing'
|
68
|
-
require 'dnsimple/client/domains_forwards'
|
69
|
-
require 'dnsimple/client/domains_zones'
|
84
|
+
require_relative 'domains'
|
85
|
+
require_relative 'domains_email_forwards'
|
70
86
|
|
71
87
|
class DomainsService < ClientService
|
72
88
|
include Client::Domains
|
73
|
-
include Client::
|
74
|
-
include Client::DomainsAutorenewal
|
75
|
-
include Client::DomainsPrivacy
|
76
|
-
include Client::DomainsSharing
|
77
|
-
include Client::DomainsForwards
|
78
|
-
include Client::DomainsZones
|
89
|
+
include Client::DomainsEmailForwards
|
79
90
|
end
|
80
91
|
|
81
92
|
|
82
|
-
|
83
|
-
require 'dnsimple/client/vanity_name_servers'
|
93
|
+
require_relative 'identity'
|
84
94
|
|
85
|
-
class
|
86
|
-
include Client::
|
87
|
-
include Client::VanityNameServers
|
95
|
+
class IdentityService < ClientService
|
96
|
+
include Client::Identity
|
88
97
|
end
|
89
98
|
|
90
99
|
|
91
|
-
|
100
|
+
require_relative 'oauth'
|
101
|
+
|
102
|
+
class OauthService < ClientService
|
103
|
+
include Client::Oauth
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
require_relative 'registrar'
|
108
|
+
require_relative 'registrar_auto_renewal'
|
109
|
+
require_relative 'registrar_whois_privacy'
|
92
110
|
|
93
111
|
class RegistrarService < ClientService
|
94
112
|
include Client::Registrar
|
113
|
+
include Client::RegistrarAutoRenewal
|
114
|
+
include Client::RegistrarWhoisPrivacy
|
95
115
|
end
|
96
116
|
|
97
117
|
|
98
|
-
|
99
|
-
require 'dnsimple/client/services_domains'
|
118
|
+
require_relative 'tlds'
|
100
119
|
|
101
|
-
class
|
102
|
-
include Client::
|
103
|
-
include Client::ServicesDomains
|
120
|
+
class TldsService < ClientService
|
121
|
+
include Client::Tlds
|
104
122
|
end
|
105
123
|
|
106
124
|
|
107
|
-
|
108
|
-
|
109
|
-
require 'dnsimple/client/templates_records'
|
125
|
+
require_relative 'zones'
|
126
|
+
require_relative 'zones_records'
|
110
127
|
|
111
|
-
class
|
112
|
-
include Client::
|
113
|
-
include Client::
|
114
|
-
include Client::TemplatesRecords
|
128
|
+
class ZonesService < ClientService
|
129
|
+
include Client::Zones
|
130
|
+
include Client::ZonesRecords
|
115
131
|
end
|
116
132
|
|
133
|
+
require_relative 'webhooks'
|
117
134
|
|
118
|
-
|
119
|
-
|
120
|
-
class UsersService < ClientService
|
121
|
-
include Client::Users
|
135
|
+
class WebhooksService < ClientService
|
136
|
+
include Client::Webhooks
|
122
137
|
end
|
123
138
|
|
124
139
|
end
|
140
|
+
|
141
|
+
# This module exposes static helpers for the API v2.
|
142
|
+
#
|
143
|
+
# Compared to the full, extended API methods provided by the various client services,
|
144
|
+
# these static methods return directly the underlying data objects.
|
145
|
+
# Therefore, it's not possible to access response metadata such as throttling or pagination info.
|
146
|
+
module V2
|
147
|
+
extend Client::Identity::StaticHelpers
|
148
|
+
end
|
125
149
|
end
|
@@ -4,66 +4,99 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the contacts in the account.
|
6
6
|
#
|
7
|
-
# @see
|
7
|
+
# @see https://developer.dnsimple.com/v2/contacts/#list
|
8
|
+
# @see #all_contacts
|
8
9
|
#
|
9
|
-
# @
|
10
|
+
# @example List contacts in the first page
|
11
|
+
# client.contacts.list(1010)
|
10
12
|
#
|
11
|
-
# @
|
12
|
-
|
13
|
-
|
13
|
+
# @example List contacts, provide a specific page
|
14
|
+
# client.contacts.list(1010, query: { page: 2 })
|
15
|
+
#
|
16
|
+
# @param [Fixnum] account_id the account ID
|
17
|
+
# @param [Hash] options the filtering and sorting option
|
18
|
+
# @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Contact>]
|
19
|
+
#
|
20
|
+
# @raise [Dnsimple::RequestError]
|
21
|
+
def contacts(account_id, options = {})
|
22
|
+
response = client.get(Client.versioned("/%s/contacts" % [account_id]), options)
|
14
23
|
|
15
|
-
response.map { |r| Struct::Contact.new(r
|
24
|
+
Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Contact.new(r) })
|
16
25
|
end
|
17
26
|
alias :list :contacts
|
18
27
|
alias :list_contacts :contacts
|
19
28
|
|
29
|
+
# Lists ALL the contacts in the account.
|
30
|
+
#
|
31
|
+
# This method is similar to {#contacts}, but instead of returning the results of a specific page
|
32
|
+
# it iterates all the pages and returns the entire collection.
|
33
|
+
#
|
34
|
+
# Please use this method carefully, as fetching the entire collection will increase the number of requests
|
35
|
+
# you send to the API server and you may eventually risk to hit the throttle limit.
|
36
|
+
#
|
37
|
+
# @see https://developer.dnsimple.com/v2/contacts/#list
|
38
|
+
# @see #contacts
|
39
|
+
#
|
40
|
+
# @param [Fixnum] account_id the account ID
|
41
|
+
# @param [Hash] options the filtering and sorting option
|
42
|
+
# @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Contact>]
|
43
|
+
#
|
44
|
+
# @raise [Dnsimple::RequestError]
|
45
|
+
def all_contacts(account_id, options = {})
|
46
|
+
paginate(:contacts, account_id, options)
|
47
|
+
end
|
48
|
+
alias :all :all_contacts
|
49
|
+
|
20
50
|
# Creates a contact in the account.
|
21
51
|
#
|
22
|
-
# @see
|
52
|
+
# @see https://developer.dnsimple.com/v2/contacts/#create
|
23
53
|
#
|
54
|
+
# @param [Fixnum] account_id the account ID
|
24
55
|
# @param [Hash] attributes
|
25
|
-
# @
|
56
|
+
# @param [Hash] options
|
57
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::Contact>]
|
26
58
|
#
|
27
|
-
# @raise [RequestError]
|
28
|
-
def create_contact(attributes
|
59
|
+
# @raise [Dnsimple::RequestError]
|
60
|
+
def create_contact(account_id, attributes, options = {})
|
29
61
|
Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address])
|
30
|
-
|
31
|
-
response = client.post(Client.versioned("/contacts"), options)
|
62
|
+
response = client.post(Client.versioned("/%s/contacts" % [account_id]), attributes, options)
|
32
63
|
|
33
|
-
Struct::Contact.new(response["
|
64
|
+
Dnsimple::Response.new(response, Struct::Contact.new(response["data"]))
|
34
65
|
end
|
35
66
|
alias :create :create_contact
|
36
67
|
|
37
68
|
# Gets a contact from the account.
|
38
69
|
#
|
39
|
-
# @see
|
70
|
+
# @see https://developer.dnsimple.com/v2/contacts/#get
|
40
71
|
#
|
41
|
-
# @param [Fixnum]
|
42
|
-
# @
|
72
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
73
|
+
# @param [#to_s] contact_id the contact ID
|
74
|
+
# @param [Hash] options
|
75
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::Contact>]
|
43
76
|
#
|
44
|
-
# @raise [NotFoundError]
|
45
|
-
# @raise [RequestError]
|
46
|
-
def contact(
|
47
|
-
response = client.get(Client.versioned("/contacts
|
77
|
+
# @raise [Dnsimple::NotFoundError]
|
78
|
+
# @raise [Dnsimple::RequestError]
|
79
|
+
def contact(account_id, contact_id, options = {})
|
80
|
+
response = client.get(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), options)
|
48
81
|
|
49
|
-
Struct::Contact.new(response["
|
82
|
+
Dnsimple::Response.new(response, Struct::Contact.new(response["data"]))
|
50
83
|
end
|
51
84
|
|
52
85
|
# Updates a contact in the account.
|
53
86
|
#
|
54
|
-
# @see
|
87
|
+
# @see https://developer.dnsimple.com/v2/contacts/#update
|
55
88
|
#
|
56
|
-
# @param [Fixnum]
|
89
|
+
# @param [Fixnum] account_id the account ID
|
90
|
+
# @param [#to_s] contact_id the contact ID
|
57
91
|
# @param [Hash] attributes
|
58
|
-
# @
|
92
|
+
# @param [Hash] options
|
93
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::Contact>]
|
59
94
|
#
|
60
|
-
# @raise [
|
61
|
-
|
62
|
-
|
63
|
-
options = options.merge(contact: attributes)
|
64
|
-
response = client.put(Client.versioned("/contacts/#{contact}"), options)
|
95
|
+
# @raise [Dnsimple::RequestError]
|
96
|
+
def update_contact(account_id, contact_id, attributes, options = {})
|
97
|
+
response = client.patch(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), attributes, options)
|
65
98
|
|
66
|
-
Struct::Contact.new(response["
|
99
|
+
Dnsimple::Response.new(response, Struct::Contact.new(response["data"]))
|
67
100
|
end
|
68
101
|
alias :update :update_contact
|
69
102
|
|
@@ -71,15 +104,19 @@ module Dnsimple
|
|
71
104
|
#
|
72
105
|
# WARNING: this cannot be undone.
|
73
106
|
#
|
74
|
-
# @see
|
107
|
+
# @see https://developer.dnsimple.com/v2/contacts/#delete
|
75
108
|
#
|
76
|
-
# @param [Fixnum]
|
77
|
-
# @
|
109
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
110
|
+
# @param [#to_s] contact_id the contact ID
|
111
|
+
# @param [Hash] options
|
112
|
+
# @return [Dnsimple::Response<nil>]
|
78
113
|
#
|
79
|
-
# @raise [NotFoundError]
|
80
|
-
# @raise [RequestError]
|
81
|
-
def delete_contact(
|
82
|
-
client.delete(Client.versioned("contacts
|
114
|
+
# @raise [Dnsimple::NotFoundError]
|
115
|
+
# @raise [Dnsimple::RequestError]
|
116
|
+
def delete_contact(account_id, contact_id, options = {})
|
117
|
+
response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), nil, options)
|
118
|
+
|
119
|
+
Dnsimple::Response.new(response, nil)
|
83
120
|
end
|
84
121
|
alias :delete :delete_contact
|
85
122
|
|
@@ -4,68 +4,122 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the domains in the account.
|
6
6
|
#
|
7
|
-
# @see
|
7
|
+
# @see https://developer.dnsimple.com/v2/domains/#list
|
8
|
+
# @see #all_domains
|
8
9
|
#
|
10
|
+
# @example List domains in the first page
|
11
|
+
# client.domains.list(1010)
|
12
|
+
#
|
13
|
+
# @example List domains, provide a specific page
|
14
|
+
# client.domains.list(1010, query: { page: 2 })
|
15
|
+
#
|
16
|
+
# @param [Fixnum] account_id the account ID
|
9
17
|
# @param [Hash] options the filtering and sorting option
|
10
|
-
# @return [
|
18
|
+
# @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Domain>]
|
11
19
|
#
|
12
|
-
# @raise [RequestError]
|
13
|
-
def domains(options = {})
|
14
|
-
response = client.get(Client.versioned("/domains"), options)
|
20
|
+
# @raise [Dnsimple::RequestError]
|
21
|
+
def domains(account_id, options = {})
|
22
|
+
response = client.get(Client.versioned("/%s/domains" % [account_id]), options)
|
15
23
|
|
16
|
-
response.map { |r| Struct::Domain.new(r
|
24
|
+
Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Domain.new(r) })
|
17
25
|
end
|
18
26
|
alias :list :domains
|
19
27
|
alias :list_domains :domains
|
20
28
|
|
29
|
+
# Lists ALL the domains in the account.
|
30
|
+
#
|
31
|
+
# This method is similar to {#domains}, but instead of returning the results of a specific page
|
32
|
+
# it iterates all the pages and returns the entire collection.
|
33
|
+
#
|
34
|
+
# Please use this method carefully, as fetching the entire collection will increase the number of requests
|
35
|
+
# you send to the API server and you may eventually risk to hit the throttle limit.
|
36
|
+
#
|
37
|
+
# @see https://developer.dnsimple.com/v2/domains/#list
|
38
|
+
# @see #domains
|
39
|
+
#
|
40
|
+
# @param [Fixnum] account_id the account ID
|
41
|
+
# @param [Hash] options the filtering and sorting option
|
42
|
+
# @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Domain>]
|
43
|
+
#
|
44
|
+
# @raise [Dnsimple::RequestError]
|
45
|
+
def all_domains(account_id, options = {})
|
46
|
+
paginate(:domains, account_id, options)
|
47
|
+
end
|
48
|
+
alias :all :all_domains
|
49
|
+
|
21
50
|
# Creates a domain in the account.
|
22
51
|
#
|
23
|
-
# @see
|
52
|
+
# @see https://developer.dnsimple.com/v2/domains/#create
|
24
53
|
#
|
54
|
+
# @param [Fixnum] account_id the account ID
|
25
55
|
# @param [Hash] attributes
|
26
|
-
# @
|
56
|
+
# @param [Hash] options
|
57
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::Domain>]
|
27
58
|
#
|
28
|
-
# @raise [RequestError]
|
29
|
-
def create_domain(attributes
|
59
|
+
# @raise [Dnsimple::RequestError]
|
60
|
+
def create_domain(account_id, attributes, options = {})
|
30
61
|
Extra.validate_mandatory_attributes(attributes, [:name])
|
31
|
-
options = options.merge(
|
32
|
-
response = client.post(Client.versioned("/domains"), options)
|
62
|
+
options = options.merge(attributes)
|
63
|
+
response = client.post(Client.versioned("/%s/domains" % [account_id]), attributes, options)
|
33
64
|
|
34
|
-
Struct::Domain.new(response["
|
65
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
35
66
|
end
|
36
67
|
alias :create :create_domain
|
37
68
|
|
38
69
|
# Gets a domain from the account.
|
39
70
|
#
|
40
|
-
# @see
|
71
|
+
# @see https://developer.dnsimple.com/v2/domains/#get
|
41
72
|
#
|
42
|
-
# @param [
|
43
|
-
# @
|
73
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
74
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
75
|
+
# @param [Hash] options
|
76
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::Domain>]
|
44
77
|
#
|
45
|
-
# @raise [NotFoundError]
|
46
|
-
# @raise [RequestError]
|
47
|
-
def domain(
|
48
|
-
response = client.get(Client.versioned("/domains
|
78
|
+
# @raise [Dnsimple::NotFoundError]
|
79
|
+
# @raise [Dnsimple::RequestError]
|
80
|
+
def domain(account_id, domain_id, options = {})
|
81
|
+
response = client.get(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), options)
|
49
82
|
|
50
|
-
Struct::Domain.new(response["
|
83
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
51
84
|
end
|
52
85
|
|
53
86
|
# Deletes a domain from the account.
|
54
87
|
#
|
55
88
|
# WARNING: this cannot be undone.
|
56
89
|
#
|
57
|
-
# @see
|
90
|
+
# @see https://developer.dnsimple.com/v2/domains/#delete
|
58
91
|
#
|
59
|
-
# @param [
|
60
|
-
# @
|
92
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
93
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
94
|
+
# @param [Hash] options
|
95
|
+
# @return [Dnsimple::Response<nil>]
|
61
96
|
#
|
62
|
-
# @raise [NotFoundError]
|
63
|
-
# @raise [RequestError]
|
64
|
-
def delete_domain(
|
65
|
-
client.delete(Client.versioned("/domains
|
97
|
+
# @raise [Dnsimple::NotFoundError]
|
98
|
+
# @raise [Dnsimple::RequestError]
|
99
|
+
def delete_domain(account_id, domain_id, options = {})
|
100
|
+
response = client.delete(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), nil, options)
|
101
|
+
|
102
|
+
Dnsimple::Response.new(response, nil)
|
66
103
|
end
|
67
104
|
alias :delete :delete_domain
|
68
105
|
|
106
|
+
# Resets the domain token.
|
107
|
+
#
|
108
|
+
# @see https://developer.dnsimple.com/v2/domains/#reset-token
|
109
|
+
#
|
110
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
111
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
112
|
+
# @param [Hash] options
|
113
|
+
# @return [Dnsimple::Response<nil>]
|
114
|
+
#
|
115
|
+
# @raise [Dnsimple::NotFoundError]
|
116
|
+
# @raise [Dnsimple::RequestError]
|
117
|
+
def reset_domain_token(account_id, domain_id, options = {})
|
118
|
+
response = client.post(Client.versioned("/%s/domains/%s/token" % [account_id, domain_id]), nil, options)
|
119
|
+
|
120
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
121
|
+
end
|
122
|
+
|
69
123
|
end
|
70
124
|
end
|
71
125
|
end
|