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
@@ -0,0 +1,107 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module DomainsEmailForwards
|
4
|
+
|
5
|
+
# Lists the email forwards for the domain.
|
6
|
+
#
|
7
|
+
# @see https://developer.dnsimple.com/v2/domains/email-forwards/#list
|
8
|
+
#
|
9
|
+
# @example List email forwards in the first page
|
10
|
+
# client.domains.email_forwards(1010, "example.com")
|
11
|
+
#
|
12
|
+
# @example List email forwards, provide a specific page
|
13
|
+
# client.domains.email_forwards(1010, "example.com", query: { page: 2 })
|
14
|
+
#
|
15
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
16
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
17
|
+
# @param [Hash] options the filtering and sorting option
|
18
|
+
# @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::EmailForward>]
|
19
|
+
#
|
20
|
+
# @raise [Dnsimple::NotFoundError]
|
21
|
+
# @raise [Dnsimple::RequestError]
|
22
|
+
def email_forwards(account_id, domain_id, options = {})
|
23
|
+
response = client.get(Client.versioned("/%s/domains/%s/email_forwards" % [account_id, domain_id]), options)
|
24
|
+
|
25
|
+
Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::EmailForward.new(r) })
|
26
|
+
end
|
27
|
+
|
28
|
+
# Lists ALL the email forwards for the domain.
|
29
|
+
#
|
30
|
+
# This method is similar to {#email_forwards}, but instead of returning the results of a specific page
|
31
|
+
# it iterates all the pages and returns the entire collection.
|
32
|
+
#
|
33
|
+
# Please use this method carefully, as fetching the entire collection will increase the number of requests
|
34
|
+
# you send to the API server and you may eventually risk to hit the throttle limit.
|
35
|
+
#
|
36
|
+
# @see https://developer.dnsimple.com/v2/domains/email-forwards/#list
|
37
|
+
# @see #email_forwards
|
38
|
+
#
|
39
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
40
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
41
|
+
# @param [Hash] options the filtering and sorting option
|
42
|
+
# @return [Dnsimple::CollectionResponse<Dnsimple::Struct::EmailForward>]
|
43
|
+
#
|
44
|
+
# @raise [Dnsimple::RequestError]
|
45
|
+
def all_email_forwards(account_id, domain_id, options = {})
|
46
|
+
paginate(:email_forwards, account_id, domain_id, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Creates an email forward for the domain.
|
50
|
+
#
|
51
|
+
# @see https://developer.dnsimple.com/v2/domains/email-forwards/#create
|
52
|
+
#
|
53
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
54
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
55
|
+
# @param [Hash] attributes
|
56
|
+
# @param [Hash] options
|
57
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::EmailForward>]
|
58
|
+
#
|
59
|
+
# @raise [Dnsimple::RequestError]
|
60
|
+
def create_email_forward(account_id, domain_id, attributes, options = {})
|
61
|
+
Extra.validate_mandatory_attributes(attributes, [:from, :to])
|
62
|
+
response = client.post(Client.versioned("/%s/domains/%s/email_forwards" % [account_id, domain_id]), attributes, options)
|
63
|
+
|
64
|
+
Dnsimple::Response.new(response, Struct::EmailForward.new(response["data"]))
|
65
|
+
end
|
66
|
+
|
67
|
+
# Gets a email forward for the domain.
|
68
|
+
#
|
69
|
+
# @see https://developer.dnsimple.com/v2/domains/email-forwards/#get
|
70
|
+
#
|
71
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
72
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
73
|
+
# @param [#to_s] email_forward_id The email forward ID
|
74
|
+
# @param [Hash] options
|
75
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::EmailForward>]
|
76
|
+
#
|
77
|
+
# @raise [Dnsimple::NotFoundError]
|
78
|
+
# @raise [Dnsimple::RequestError]
|
79
|
+
def email_forward(account_id, domain_id, email_forward_id, options = {})
|
80
|
+
response = client.get(Client.versioned("/%s/domains/%s/email_forwards/%s" % [account_id, domain_id, email_forward_id]), options)
|
81
|
+
|
82
|
+
Dnsimple::Response.new(response, Struct::EmailForward.new(response["data"]))
|
83
|
+
end
|
84
|
+
|
85
|
+
# Deletes an email forward for the domain.
|
86
|
+
#
|
87
|
+
# WARNING: this cannot be undone.
|
88
|
+
#
|
89
|
+
# @see https://developer.dnsimple.com/v2/domains/email-forwards/#delete
|
90
|
+
#
|
91
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
92
|
+
# @param [#to_s] domain_id The domain ID or domain name
|
93
|
+
# @param [#to_s] email_forward_id The email forward ID
|
94
|
+
# @param [Hash] options
|
95
|
+
# @return [Dnsimple::Response<nil>]
|
96
|
+
#
|
97
|
+
# @raise [Dnsimple::NotFoundError]
|
98
|
+
# @raise [Dnsimple::RequestError]
|
99
|
+
def delete_email_forward(account_id, domain_id, email_forward_id, options = {})
|
100
|
+
response = client.delete(Client.versioned("/%s/domains/%s/email_forwards/%s" % [account_id, domain_id, email_forward_id]), nil, options)
|
101
|
+
|
102
|
+
Dnsimple::Response.new(response, nil)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module Identity
|
4
|
+
|
5
|
+
# Gets the information about the current authenticated context.
|
6
|
+
#
|
7
|
+
# @see https://developer.dnsimple.com/v2/identity/#whoami
|
8
|
+
#
|
9
|
+
# @param [Hash] options
|
10
|
+
# @return [Dnsimple::Response<Hash>]
|
11
|
+
# @raise [Dnsimple::RequestError]
|
12
|
+
def whoami(options = {})
|
13
|
+
response = client.get(Client.versioned("/whoami"), options)
|
14
|
+
|
15
|
+
data = response["data"]
|
16
|
+
account = data["account"] ? Struct::Account.new(data["account"]) : nil
|
17
|
+
user = data["user"] ? Struct::User.new(data["user"]) : nil
|
18
|
+
Response.new(response, { account: account, user: user })
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
module StaticHelpers
|
23
|
+
# Calls {Identity#whoami} and directly returns the response data.
|
24
|
+
#
|
25
|
+
# @see https://developer.dnsimple.com/v2/identity/#whoami
|
26
|
+
#
|
27
|
+
# @param [Dnsimple::Client] client the DNSimple client instance to use
|
28
|
+
# @param [Array] args the args for the {Identity#whoami} call
|
29
|
+
# @return [Hash]
|
30
|
+
# @raise [Dnsimple::RequestError]
|
31
|
+
def whoami(client, *args)
|
32
|
+
client.identity.whoami(*args).data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module Oauth
|
4
|
+
|
5
|
+
# Exchange the short-lived authorization code for an access token
|
6
|
+
# you can use to authenticate your API calls.
|
7
|
+
#
|
8
|
+
# @see https://developer.dnsimple.com/v2/oauth/
|
9
|
+
#
|
10
|
+
# @param client_id [String] Client Id you received when the application was registered with DNSimple.
|
11
|
+
# @param client_secret [String] Client Secret you received when the application was registered with DNSimple.
|
12
|
+
# @option options [String] :redirect_uri The redirect URL sent for the authorization, used to validate the request.
|
13
|
+
# @return [String] The url to redirect the user to authorize.
|
14
|
+
def exchange_authorization_for_token(code, client_id, client_secret, options = {})
|
15
|
+
attributes = { code: code, client_id: client_id, client_secret: client_secret, grant_type: "authorization_code" }
|
16
|
+
response = client.post(Client.versioned("/oauth/access_token"), attributes, options)
|
17
|
+
Struct::OauthToken.new(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gets the URL to authorize an user for an application via the OAuth2 flow.
|
21
|
+
#
|
22
|
+
# @see https://developer.dnsimple.com/v2/oauth/
|
23
|
+
#
|
24
|
+
# @param client_id [String] Client Id you received when the application was registered with DNSimple.
|
25
|
+
# @option options [String] :redirect_uri The URL to redirect to after authorizing.
|
26
|
+
# @option options [String] :scope The scopes to request from the user.
|
27
|
+
# @option options [String] :state A random string to protect against CSRF.
|
28
|
+
# @return [String] The URL to redirect the user to authorize.
|
29
|
+
def authorize_url(client_id, options = {})
|
30
|
+
site_url = client.base_url.sub("api.", "")
|
31
|
+
url = URI.join(site_url, "/oauth/authorize?client_id=#{client_id}")
|
32
|
+
|
33
|
+
options = options.merge(response_type: "code")
|
34
|
+
options.each do |key, value|
|
35
|
+
url.query += "&#{key}=#{value}"
|
36
|
+
end
|
37
|
+
url.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -2,119 +2,111 @@ module Dnsimple
|
|
2
2
|
class Client
|
3
3
|
module Registrar
|
4
4
|
|
5
|
-
# Checks
|
5
|
+
# Checks whether a domain is available to be registered.
|
6
6
|
#
|
7
|
-
# @see
|
7
|
+
# @see https://developer.dnsimple.com/v2/registrar/#check
|
8
8
|
#
|
9
|
-
# @
|
10
|
-
#
|
9
|
+
# @example Check whether example.com is available:
|
10
|
+
# client.registrar.check(1010, "example.com")
|
11
11
|
#
|
12
|
-
# @
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rescue NotFoundError => e
|
17
|
-
e.response
|
18
|
-
end
|
19
|
-
|
20
|
-
response.parsed_response
|
21
|
-
end
|
22
|
-
|
23
|
-
# Checks the availability of a domain name.
|
24
|
-
#
|
25
|
-
# @see http://developer.dnsimple.com/v1/domains/registry/#check
|
26
|
-
#
|
27
|
-
# @param [#to_s] name The domain name to check.
|
28
|
-
# @return [Boolean] true if the domain is available
|
12
|
+
# @param [Fixnum] account_id the account ID
|
13
|
+
# @param [#to_s] domain_name the domain name to check
|
14
|
+
# @param [Hash] options
|
15
|
+
# @return [Struct::DomainCheck]
|
29
16
|
#
|
30
17
|
# @raise [RequestError] When the request fails.
|
31
|
-
def
|
32
|
-
|
18
|
+
def check_domain(account_id, domain_name, options = {})
|
19
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/check" % [account_id, domain_name])
|
20
|
+
response = client.get(endpoint, options)
|
21
|
+
|
22
|
+
Dnsimple::Response.new(response, Struct::DomainCheck.new(response["data"]))
|
33
23
|
end
|
34
24
|
|
35
25
|
# Registers a domain.
|
36
26
|
#
|
37
|
-
# @see
|
27
|
+
# @see https://developer.dnsimple.com/v2/registrar/#register
|
28
|
+
#
|
29
|
+
# @example Initiate the registration of example.com using the contact 1234 as registrant
|
30
|
+
# including WHOIS privacy for the domain and enabling auto renewal:
|
31
|
+
# client.registrar.register(1010, "example.com", registrant_id: 1234, privacy: true, auto_renew: true)
|
38
32
|
#
|
39
|
-
# @param [
|
40
|
-
# @param [
|
41
|
-
# @param [Hash]
|
33
|
+
# @param [Fixnum] account_id the account ID
|
34
|
+
# @param [#to_s] domain_name the domain name to register
|
35
|
+
# @param [Hash] attributes
|
42
36
|
# @param [Hash] options
|
43
37
|
# @return [Struct::Domain]
|
44
38
|
#
|
45
39
|
# @raise [RequestError] When the request fails.
|
46
|
-
def
|
47
|
-
|
48
|
-
|
40
|
+
def register_domain(account_id, domain_name, attributes, options = {})
|
41
|
+
Extra.validate_mandatory_attributes(attributes, [:registrant_id])
|
42
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/registration" % [account_id, domain_name])
|
43
|
+
response = client.post(endpoint, attributes, options)
|
49
44
|
|
50
|
-
Struct::Domain.new(response["
|
45
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
51
46
|
end
|
52
47
|
|
53
|
-
#
|
48
|
+
# Renews a domain.
|
54
49
|
#
|
55
|
-
# @see
|
50
|
+
# @see https://developer.dnsimple.com/v2/registrar/#renew
|
56
51
|
#
|
57
|
-
# @
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# @param [
|
52
|
+
# @example Renew example.com for 3 years:
|
53
|
+
# client.registrar.renew(1010, "example.com", period: 3)
|
54
|
+
#
|
55
|
+
# @param [Fixnum] account_id the account ID
|
56
|
+
# @param [#to_s] domain_name the domain name to renew
|
57
|
+
# @param [Hash] attributes
|
61
58
|
# @param [Hash] options
|
62
|
-
# @return [Struct::
|
59
|
+
# @return [Struct::Domain]
|
63
60
|
#
|
64
61
|
# @raise [RequestError] When the request fails.
|
65
|
-
def
|
66
|
-
|
67
|
-
response = client.post(
|
62
|
+
def renew_domain(account_id, domain_name, attributes = nil, options = {})
|
63
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/renew" % [account_id, domain_name])
|
64
|
+
response = client.post(endpoint, attributes, options)
|
68
65
|
|
69
|
-
Struct::
|
66
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
70
67
|
end
|
71
68
|
|
72
|
-
#
|
69
|
+
# Starts the transfer of a domain to DNSimple.
|
73
70
|
#
|
74
|
-
# @see
|
71
|
+
# @see https://developer.dnsimple.com/v2/registrar/#transfer
|
75
72
|
#
|
76
|
-
# @
|
73
|
+
# @example Initiate the transfer for example.com using the contact 1234 as registrant:
|
74
|
+
# client.registrar.transfer(1010, "example.com", registrant_id: 1234, auth_info: "x1y2z3")
|
75
|
+
#
|
76
|
+
# @param [Fixnum] account_id the account ID
|
77
|
+
# @param [#to_s] domain_name the domain name to transfer
|
78
|
+
# @param [Hash] attributes
|
77
79
|
# @param [Hash] options
|
78
80
|
# @return [Struct::Domain]
|
79
81
|
#
|
80
82
|
# @raise [RequestError] When the request fails.
|
81
|
-
def
|
82
|
-
|
83
|
-
|
83
|
+
def transfer_domain(account_id, domain_name, attributes, options = {})
|
84
|
+
Extra.validate_mandatory_attributes(attributes, [:registrant_id])
|
85
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/transfer" % [account_id, domain_name])
|
86
|
+
response = client.post(endpoint, attributes, options)
|
84
87
|
|
85
|
-
Struct::Domain.new(response["
|
88
|
+
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
86
89
|
end
|
87
90
|
|
88
|
-
|
89
|
-
# List the extended attributes for a TLD.
|
90
|
-
#
|
91
|
-
# @see http://developer.dnsimple.com/v1/registrar/extended-attributes/#list
|
91
|
+
# Requests the transfer of a domain out of DNSimple.
|
92
92
|
#
|
93
|
-
# @
|
94
|
-
# @return [Array<Struct::ExtendedAttribute>]
|
95
|
-
#
|
96
|
-
# @raise [RequestError] When the request fails.
|
97
|
-
def extended_attributes(tld, options = {})
|
98
|
-
response = client.get(Client.versioned("/extended_attributes/#{tld}"), options)
|
99
|
-
|
100
|
-
response.map { |r| Struct::ExtendedAttribute.new(r) }
|
101
|
-
end
|
102
|
-
alias :list_extended_attributes :extended_attributes
|
103
|
-
|
104
|
-
# List all the TLD prices.
|
93
|
+
# @see https://developer.dnsimple.com/v2/registrar/#transfer_out
|
105
94
|
#
|
106
|
-
# @
|
95
|
+
# @example Request to transfer of example.com out of DNSimple:
|
96
|
+
# client.registrar.transfer_out(1010, "example.com")
|
107
97
|
#
|
108
|
-
# @
|
98
|
+
# @param [Fixnum] account_id the account ID
|
99
|
+
# @param [#to_s] domain_name the domain name to transfer out
|
100
|
+
# @param [Hash] options
|
101
|
+
# @return [Dnsimple::Response<nil>]
|
109
102
|
#
|
110
103
|
# @raise [RequestError] When the request fails.
|
111
|
-
def
|
112
|
-
|
104
|
+
def transfer_domain_out(account_id, domain_name, options = {})
|
105
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/transfer_out" % [account_id, domain_name])
|
106
|
+
response = client.post(endpoint, nil, options)
|
113
107
|
|
114
|
-
|
108
|
+
Dnsimple::Response.new(response, nil)
|
115
109
|
end
|
116
|
-
alias :list_prices :prices
|
117
|
-
|
118
110
|
end
|
119
111
|
end
|
120
112
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module RegistrarAutoRenewal
|
4
|
+
|
5
|
+
# Enable auto renewal for the domain in the account.
|
6
|
+
#
|
7
|
+
# @see https://developer.dnsimple.com/v2/registrar/auto-renewal/
|
8
|
+
#
|
9
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
10
|
+
# @param [#to_s] domain_name the domain name
|
11
|
+
# @param [Hash] options
|
12
|
+
# @return [Dnsimple::Response<nil>]
|
13
|
+
#
|
14
|
+
# @raise [Dnsimple::NotFoundError]
|
15
|
+
# @raise [Dnsimple::RequestError]
|
16
|
+
def enable_auto_renewal(account_id, domain_name, options={})
|
17
|
+
response = client.put(Client.versioned("/%s/registrar/domains/%s/auto_renewal" % [account_id, domain_name]), nil, options)
|
18
|
+
|
19
|
+
Dnsimple::Response.new(response, nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Disable auto renewal for the domain in the account.
|
23
|
+
#
|
24
|
+
# @see https://developer.dnsimple.com/v2/registrar/auto-renewal/
|
25
|
+
#
|
26
|
+
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
|
27
|
+
# @param [#to_s] domain_name the domain name
|
28
|
+
# @param [Hash] options
|
29
|
+
# @return [Dnsimple::Response<nil>]
|
30
|
+
#
|
31
|
+
# @raise [Dnsimple::NotFoundError]
|
32
|
+
# @raise [Dnsimple::RequestError]
|
33
|
+
def disable_auto_renewal(account_id, domain_name, options={})
|
34
|
+
response = client.delete(Client.versioned("/%s/registrar/domains/%s/auto_renewal" % [account_id, domain_name]), nil, options)
|
35
|
+
|
36
|
+
Dnsimple::Response.new(response, nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module RegistrarWhoisPrivacy
|
4
|
+
|
5
|
+
# Gets the whois privacy for the domain.
|
6
|
+
#
|
7
|
+
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#get
|
8
|
+
#
|
9
|
+
# @example Get the whois privacy for "example.com":
|
10
|
+
# client.registrar.get_whois_privacy(1010, "example.com")
|
11
|
+
#
|
12
|
+
# @param [Fixnum] account_id the account ID
|
13
|
+
# @param [#to_s] domain_name the domain name
|
14
|
+
# @param [Hash] options
|
15
|
+
# @return [Struct::WhoisPrivacy]
|
16
|
+
#
|
17
|
+
# @raise [RequestError] When the request fails.
|
18
|
+
def whois_privacy(account_id, domain_name, options = {})
|
19
|
+
endpoint = whois_privacy_endpoint(account_id, domain_name)
|
20
|
+
response = client.get(endpoint, options)
|
21
|
+
|
22
|
+
Dnsimple::Response.new(response, Struct::WhoisPrivacy.new(response["data"]))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Enables whois privacy for the domain.
|
26
|
+
#
|
27
|
+
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#enable
|
28
|
+
#
|
29
|
+
# @example Enable whois privacy for "example.com":
|
30
|
+
# client.registrar.enable_whois_privacy(1010, "example.com")
|
31
|
+
#
|
32
|
+
# @param [Fixnum] account_id the account ID
|
33
|
+
# @param [#to_s] domain_name the domain name
|
34
|
+
# @param [Hash] options
|
35
|
+
# @return [Struct::WhoisPrivacy]
|
36
|
+
#
|
37
|
+
# @raise [RequestError] When the request fails.
|
38
|
+
def enable_whois_privacy(account_id, domain_name, options = {})
|
39
|
+
endpoint = whois_privacy_endpoint(account_id, domain_name)
|
40
|
+
response = client.put(endpoint, nil, options)
|
41
|
+
|
42
|
+
Dnsimple::Response.new(response, Struct::WhoisPrivacy.new(response["data"]))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Disables whois privacy for the domain.
|
46
|
+
#
|
47
|
+
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#disable
|
48
|
+
#
|
49
|
+
# @example Disable whois privacy for "example.com":
|
50
|
+
# client.registrar.disable_whois_privacy(1010, "example.com")
|
51
|
+
#
|
52
|
+
# @param [Fixnum] account_id the account ID
|
53
|
+
# @param [#to_s] domain_name The domain name to check.
|
54
|
+
# @param [Hash] options
|
55
|
+
# @return [Struct::WhoisPrivacy]
|
56
|
+
#
|
57
|
+
# @raise [RequestError] When the request fails.
|
58
|
+
def disable_whois_privacy(account_id, domain_name, options = {})
|
59
|
+
endpoint = whois_privacy_endpoint(account_id, domain_name)
|
60
|
+
response = client.delete(endpoint, nil, options)
|
61
|
+
|
62
|
+
Dnsimple::Response.new(response, Struct::WhoisPrivacy.new(response["data"]))
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def whois_privacy_endpoint(account_id, domain_name)
|
69
|
+
Client.versioned("/%s/registrar/domains/%s/whois_privacy" % [account_id, domain_name])
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|