dnsimple 5.2.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/ci.yml +63 -0
- data/.github/workflows/release.yml +19 -0
- data/.gitignore +3 -0
- data/.markdownlint.yaml +3 -0
- data/.rubocop.yml +7 -16
- data/.rubocop_dnsimple.yml +28 -55
- data/.rubocop_todo.yml +44 -5
- data/CHANGELOG.md +24 -10
- data/CONTRIBUTING.md +8 -23
- data/Gemfile +3 -1
- data/LICENSE.txt +1 -1
- data/README.md +7 -11
- data/UPGRADING.md +4 -5
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client/clients.rb +3 -2
- data/lib/dnsimple/client/domains.rb +0 -18
- data/lib/dnsimple/client/domains_delegation_signer_records.rb +5 -4
- data/lib/dnsimple/client/registrar.rb +23 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
- data/lib/dnsimple/client.rb +11 -3
- data/lib/dnsimple/default.rb +2 -2
- data/lib/dnsimple/error.rb +1 -1
- data/lib/dnsimple/extra.rb +3 -3
- data/lib/dnsimple/response.rb +1 -3
- data/lib/dnsimple/struct/certificate.rb +0 -19
- data/lib/dnsimple/struct/delegation_signer_record.rb +3 -0
- data/lib/dnsimple/struct/domain.rb +0 -20
- data/lib/dnsimple/struct/domain_price.rb +24 -0
- data/lib/dnsimple/struct/tld.rb +3 -0
- data/lib/dnsimple/struct.rb +1 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +0 -1
- data/spec/dnsimple/client/client_service_spec.rb +1 -1
- data/spec/dnsimple/client/contacts_spec.rb +2 -2
- data/spec/dnsimple/client/domains_collaborators_spec.rb +2 -2
- data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +2 -1
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +8 -8
- data/spec/dnsimple/client/domains_pushes_spec.rb +2 -2
- data/spec/dnsimple/client/domains_spec.rb +1 -29
- data/spec/dnsimple/client/registrar_delegation_spec.rb +2 -2
- data/spec/dnsimple/client/registrar_spec.rb +46 -3
- data/spec/dnsimple/client/services_domains_spec.rb +2 -4
- data/spec/dnsimple/client/services_spec.rb +1 -3
- data/spec/dnsimple/client/templates_records_spec.rb +1 -1
- data/spec/dnsimple/client/templates_spec.rb +2 -2
- data/spec/dnsimple/client/tlds_spec.rb +1 -0
- data/spec/dnsimple/client/webhooks_spec.rb +1 -1
- data/spec/dnsimple/client/zones_records_spec.rb +2 -2
- data/spec/dnsimple/client/zones_spec.rb +1 -1
- data/spec/dnsimple/client_spec.rb +15 -15
- data/spec/dnsimple/extra_spec.rb +1 -1
- data/spec/dnsimple/options/list_options_spec.rb +4 -4
- data/spec/fixtures.http/accounts/success-account.http +0 -1
- data/spec/fixtures.http/accounts/success-user.http +0 -1
- data/spec/fixtures.http/addCollaborator/invite-success.http +0 -1
- data/spec/fixtures.http/addCollaborator/success.http +0 -1
- data/spec/fixtures.http/appliedServices/success.http +0 -1
- data/spec/fixtures.http/cancelDomainTransfer/success.http +0 -1
- data/spec/fixtures.http/changeDomainDelegation/success.http +0 -1
- data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +0 -1
- data/spec/fixtures.http/checkDomain/success.http +0 -1
- data/spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http +18 -0
- data/spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http +18 -0
- data/spec/fixtures.http/checkDomainPremiumPrice/success.http +20 -0
- data/spec/fixtures.http/checkZoneDistribution/error.http +0 -1
- data/spec/fixtures.http/checkZoneDistribution/failure.http +0 -1
- data/spec/fixtures.http/checkZoneDistribution/success.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/error.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/success.http +0 -1
- data/spec/fixtures.http/createContact/created.http +0 -1
- data/spec/fixtures.http/createDelegationSignerRecord/created.http +1 -2
- data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
- data/spec/fixtures.http/createDomain/created.http +0 -1
- data/spec/fixtures.http/createEmailForward/created.http +21 -17
- data/spec/fixtures.http/createPrimaryServer/created.http +21 -0
- data/spec/fixtures.http/createSecondaryZone/created.http +21 -0
- data/spec/fixtures.http/createTemplate/created.http +0 -1
- data/spec/fixtures.http/createTemplateRecord/created.http +0 -1
- data/spec/fixtures.http/createWebhook/created.http +0 -1
- data/spec/fixtures.http/createZoneRecord/created-apex.http +0 -1
- data/spec/fixtures.http/createZoneRecord/created.http +0 -1
- data/spec/fixtures.http/deleteContact/error-contact-in-use.http +18 -0
- data/spec/fixtures.http/deleteEmailForward/success.http +12 -7
- data/spec/fixtures.http/disableDnssec/not-enabled.http +0 -1
- data/spec/fixtures.http/disableWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/downloadCertificate/success.http +0 -1
- data/spec/fixtures.http/enableDnssec/success.http +0 -1
- data/spec/fixtures.http/enableVanityNameServers/success.http +0 -1
- data/spec/fixtures.http/enableWhoisPrivacy/created.http +0 -1
- data/spec/fixtures.http/enableWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/getCertificate/success.http +0 -1
- data/spec/fixtures.http/getCertificatePrivateKey/success.http +0 -1
- data/spec/fixtures.http/getContact/success.http +0 -1
- data/spec/fixtures.http/getDelegationSignerRecord/success.http +1 -2
- data/spec/fixtures.http/getDnssec/success.http +0 -1
- data/spec/fixtures.http/getDomain/success.http +0 -1
- data/spec/fixtures.http/getDomainDelegation/success-empty.http +0 -1
- data/spec/fixtures.http/getDomainDelegation/success.http +0 -1
- data/spec/fixtures.http/getDomainPremiumPrice/failure.http +0 -1
- data/spec/fixtures.http/getDomainPremiumPrice/success.http +0 -1
- data/spec/fixtures.http/getDomainPrices/failure.http +19 -0
- data/spec/fixtures.http/getDomainPrices/success.http +21 -0
- data/spec/fixtures.http/getDomainTransfer/success.http +0 -1
- data/spec/fixtures.http/getEmailForward/success.http +14 -10
- data/spec/fixtures.http/getPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/getService/success.http +0 -1
- data/spec/fixtures.http/getTemplate/success.http +0 -1
- data/spec/fixtures.http/getTemplateRecord/success.http +0 -1
- data/spec/fixtures.http/getTld/success.http +1 -2
- data/spec/fixtures.http/getTldExtendedAttributes/success-attributes.http +0 -1
- data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +0 -1
- data/spec/fixtures.http/getTldExtendedAttributes/success.http +0 -1
- data/spec/fixtures.http/getWebhook/success.http +0 -1
- data/spec/fixtures.http/getWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/getZone/success.http +0 -1
- data/spec/fixtures.http/getZoneFile/success.http +0 -1
- data/spec/fixtures.http/getZoneRecord/success.http +0 -1
- data/spec/fixtures.http/initiatePush/success.http +0 -1
- data/spec/fixtures.http/issueLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/linkPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/listAccounts/success-account.http +0 -1
- data/spec/fixtures.http/listAccounts/success-user.http +0 -1
- data/spec/fixtures.http/listCertificates/success.http +0 -1
- data/spec/fixtures.http/listCollaborators/success.http +0 -1
- data/spec/fixtures.http/listContacts/success.http +0 -1
- data/spec/fixtures.http/listDelegationSignerRecords/success.http +1 -2
- data/spec/fixtures.http/listDomains/success.http +0 -1
- data/spec/fixtures.http/listEmailForwards/success.http +0 -1
- data/spec/fixtures.http/listPrimaryServers/success.http +21 -0
- data/spec/fixtures.http/listPushes/success.http +0 -1
- data/spec/fixtures.http/listServices/success.http +0 -1
- data/spec/fixtures.http/listTemplateRecords/success.http +0 -1
- data/spec/fixtures.http/listTemplates/success.http +0 -1
- data/spec/fixtures.http/listTlds/success.http +1 -2
- data/spec/fixtures.http/listWebhooks/success.http +0 -1
- data/spec/fixtures.http/listZoneRecords/success.http +0 -1
- data/spec/fixtures.http/listZones/success.http +0 -1
- data/spec/fixtures.http/method-not-allowed.http +0 -1
- data/spec/fixtures.http/notfound-certificate.http +0 -1
- data/spec/fixtures.http/notfound-collaborator.http +0 -1
- data/spec/fixtures.http/notfound-contact.http +0 -1
- data/spec/fixtures.http/notfound-delegationsignerrecord.http +0 -1
- data/spec/fixtures.http/notfound-domain.http +0 -1
- data/spec/fixtures.http/notfound-domainpush.http +0 -1
- data/spec/fixtures.http/notfound-emailforward.http +0 -1
- data/spec/fixtures.http/notfound-record.http +0 -1
- data/spec/fixtures.http/notfound-template.http +0 -1
- data/spec/fixtures.http/notfound-webhook.http +0 -1
- data/spec/fixtures.http/notfound-whoisprivacy.http +0 -1
- data/spec/fixtures.http/notfound-zone.http +0 -1
- data/spec/fixtures.http/oauthAccessToken/error-invalid-request.http +0 -1
- data/spec/fixtures.http/oauthAccessToken/success.http +0 -1
- data/spec/fixtures.http/pages-1of3.http +0 -1
- data/spec/fixtures.http/pages-2of3.http +0 -1
- data/spec/fixtures.http/pages-3of3.http +0 -1
- data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/registerDomain/success.http +0 -1
- data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
- data/spec/fixtures.http/renewDomain/success.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +0 -1
- data/spec/fixtures.http/response.http +0 -1
- data/spec/fixtures.http/transferDomain/error-indnsimple.http +0 -1
- data/spec/fixtures.http/transferDomain/error-missing-authcode.http +0 -1
- data/spec/fixtures.http/transferDomain/success.http +0 -1
- data/spec/fixtures.http/unlinkPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/updateContact/success.http +0 -1
- data/spec/fixtures.http/updateTemplate/success.http +0 -1
- data/spec/fixtures.http/updateZoneRecord/success.http +0 -1
- data/spec/fixtures.http/validation-error.http +0 -1
- data/spec/fixtures.http/whoami/success-account.http +0 -1
- data/spec/fixtures.http/whoami/success-user.http +0 -1
- data/spec/fixtures.http/whoami/success.http +0 -1
- data/spec/spec_helper.rb +2 -2
- metadata +23 -177
- data/.dependabot/config.yml +0 -9
- data/.travis.yml +0 -17
- data/spec/fixtures.http/resetDomainToken/success.http +0 -17
data/dnsimple.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = 'The DNSimple API client for Ruby'
|
12
12
|
s.description = 'The DNSimple API client for Ruby.'
|
13
13
|
|
14
|
-
s.required_ruby_version = ">= 2.
|
14
|
+
s.required_ruby_version = ">= 2.6"
|
15
15
|
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
s.files = `git ls-files`.split("\n")
|
@@ -98,14 +98,15 @@ module Dnsimple
|
|
98
98
|
options = args.pop
|
99
99
|
response = nil
|
100
100
|
|
101
|
-
|
101
|
+
loop do
|
102
102
|
current_page += 1
|
103
103
|
query = Extra.deep_merge(options, query: { page: current_page, per_page: 100 })
|
104
104
|
|
105
105
|
response = send(method, *(args + [query]))
|
106
106
|
total_pages ||= response.total_pages
|
107
107
|
collection.concat(response.data)
|
108
|
-
|
108
|
+
break unless current_page < total_pages
|
109
|
+
end
|
109
110
|
|
110
111
|
CollectionResponse.new(response.http_response, collection)
|
111
112
|
end
|
@@ -114,24 +114,6 @@ module Dnsimple
|
|
114
114
|
|
115
115
|
Dnsimple::Response.new(response, nil)
|
116
116
|
end
|
117
|
-
|
118
|
-
# Resets the domain token.
|
119
|
-
#
|
120
|
-
# @see https://developer.dnsimple.com/v2/domains/#reset-token
|
121
|
-
#
|
122
|
-
# @param [Integer] account_id the account ID
|
123
|
-
# @param [#to_s] domain_id The domain ID or domain name
|
124
|
-
# @param [Hash] options
|
125
|
-
# @return [Dnsimple::Response<nil>]
|
126
|
-
#
|
127
|
-
# @raise [Dnsimple::NotFoundError]
|
128
|
-
# @raise [Dnsimple::RequestError]
|
129
|
-
def reset_domain_token(account_id, domain_id, options = {})
|
130
|
-
response = client.post(Client.versioned("/%s/domains/%s/token" % [account_id, domain_id]), nil, options)
|
131
|
-
|
132
|
-
Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
|
133
|
-
end
|
134
|
-
|
135
117
|
end
|
136
118
|
end
|
137
119
|
end
|
@@ -67,15 +67,16 @@ module Dnsimple
|
|
67
67
|
# @param [#to_s] domain_id The domain ID or domain name
|
68
68
|
# @param [Hash] attributes
|
69
69
|
# @option attributes [Integer] :algorithm DNSSEC algorithm as number (required)
|
70
|
-
# @option attributes [String] :digest The hexidecimal representation of the digest of the corresponding DNSKEY record (required)
|
71
|
-
# @option attributes [Integer] :digest_type DNSSEC digest type (required)
|
72
|
-
# @option attributes [String] :keytag A keytag that references the corresponding DNSKEY record (required)
|
70
|
+
# @option attributes [String] :digest The hexidecimal representation of the digest of the corresponding DNSKEY record (required if TLD requires DS data)
|
71
|
+
# @option attributes [Integer] :digest_type DNSSEC digest type (required if TLD requires DS data)
|
72
|
+
# @option attributes [String] :keytag A keytag that references the corresponding DNSKEY record (required if TLD requires DS data)
|
73
|
+
# @option attributes [String] :public_key A public key that references the corresponding DNSKEY record (required if TLD requires KEY data)
|
73
74
|
# @param [Hash] options
|
74
75
|
# @return [Dnsimple::Response<Dnsimple::Struct::DelegationSignerRecord>]
|
75
76
|
#
|
76
77
|
# @raise [Dnsimple::RequestError]
|
77
78
|
def create_delegation_signer_record(account_id, domain_id, attributes, options = {})
|
78
|
-
Extra.validate_mandatory_attributes(attributes, [:algorithm
|
79
|
+
Extra.validate_mandatory_attributes(attributes, [:algorithm])
|
79
80
|
response = client.post(Client.versioned("/%s/domains/%s/ds_records" % [account_id, domain_id]), attributes, options)
|
80
81
|
|
81
82
|
Dnsimple::Response.new(response, Struct::DelegationSignerRecord.new(response["data"]))
|
@@ -42,7 +42,10 @@ module Dnsimple
|
|
42
42
|
# @return [Struct::DomainPremiumPrice]
|
43
43
|
#
|
44
44
|
# @raise [RequestError] When the request fails.
|
45
|
+
#
|
46
|
+
# @deprecated Use {#get_domain_prices} instead of this one as it will soon be removed from the API.
|
45
47
|
def domain_premium_price(account_id, domain_name, options = {})
|
48
|
+
Dnsimple.deprecate("Use {#get_domain_prices} instead of this one as it will soon be removed from the API.")
|
46
49
|
endpoint = Client.versioned("/%s/registrar/domains/%s/premium_price" % [account_id, domain_name])
|
47
50
|
options[:query] = { action: options.delete(:action) } if options.key?(:action)
|
48
51
|
response = client.get(endpoint, options)
|
@@ -50,6 +53,26 @@ module Dnsimple
|
|
50
53
|
Dnsimple::Response.new(response, Struct::DomainPremiumPrice.new(response["data"]))
|
51
54
|
end
|
52
55
|
|
56
|
+
# Get prices for a domain.
|
57
|
+
# @see https://developer.dnsimple.com/v2/registrar/#getDomainPrices
|
58
|
+
#
|
59
|
+
# @example Check prices for example.com:
|
60
|
+
# client.registrar.get_domain_prices(1010, "example.com")
|
61
|
+
#
|
62
|
+
# @param [Integer] account_id the Account id
|
63
|
+
# @param [String] domain_name the domain name to find the prices
|
64
|
+
# @param [Hash] options
|
65
|
+
#
|
66
|
+
# @return [Struct::DomainPrice]
|
67
|
+
#
|
68
|
+
# @raise [RequestError] When the request fails.
|
69
|
+
def get_domain_prices(account_id, domain_name, options = {})
|
70
|
+
endpoint = Client.versioned("/%s/registrar/domains/%s/prices" % [account_id, domain_name])
|
71
|
+
response = client.get(endpoint, options)
|
72
|
+
|
73
|
+
Dnsimple::Response.new(response, Struct::DomainPrice.new(response["data"]))
|
74
|
+
end
|
75
|
+
|
53
76
|
# Registers a domain.
|
54
77
|
#
|
55
78
|
# @see https://developer.dnsimple.com/v2/registrar/#register
|
@@ -78,7 +78,7 @@ module Dnsimple
|
|
78
78
|
#
|
79
79
|
# @raise [RequestError] When the request fails.
|
80
80
|
def renew_whois_privacy(account_id, domain_name, options = {})
|
81
|
-
endpoint = whois_privacy_endpoint(account_id, domain_name)
|
81
|
+
endpoint = "#{whois_privacy_endpoint(account_id, domain_name)}/renewals"
|
82
82
|
response = client.post(endpoint, nil, options)
|
83
83
|
|
84
84
|
Dnsimple::Response.new(response, Struct::WhoisPrivacyRenewal.new(response["data"]))
|
data/lib/dnsimple/client.rb
CHANGED
@@ -42,22 +42,30 @@ module Dnsimple
|
|
42
42
|
# @!attribute username
|
43
43
|
# @see https://developer.dnsimple.com/v2/#authentication
|
44
44
|
# @return [String] DNSimple username for Basic Authentication
|
45
|
+
attr_accessor :username
|
46
|
+
|
45
47
|
# @!attribute password
|
46
48
|
# @see https://developer.dnsimple.com/v2/#authentication
|
47
49
|
# @return [String] DNSimple password for Basic Authentication
|
50
|
+
attr_accessor :password
|
51
|
+
|
48
52
|
# @!attribute domain_api_token
|
49
53
|
# @see https://developer.dnsimple.com/v2/#authentication
|
50
54
|
# @return [String] Domain API access token for authentication
|
55
|
+
attr_accessor :domain_api_token
|
56
|
+
|
51
57
|
# @!attribute access_token
|
52
58
|
# @see https://developer.dnsimple.com/v2/#authentication
|
53
59
|
# @return [String] Domain API access token for authentication
|
60
|
+
attr_accessor :access_token
|
61
|
+
|
54
62
|
# @!attribute user_agent
|
55
63
|
# @return [String] Configure User-Agent header for requests.
|
64
|
+
attr_accessor :user_agent
|
65
|
+
|
56
66
|
# @!attribute proxy
|
57
67
|
# @return [String,nil] Configure address:port values for proxy server
|
58
|
-
|
59
|
-
attr_accessor :username, :password, :domain_api_token, :access_token,
|
60
|
-
:user_agent, :proxy
|
68
|
+
attr_accessor :proxy
|
61
69
|
|
62
70
|
|
63
71
|
def initialize(options = {})
|
data/lib/dnsimple/default.rb
CHANGED
@@ -9,7 +9,7 @@ module Dnsimple
|
|
9
9
|
BASE_URL = "https://api.dnsimple.com/"
|
10
10
|
|
11
11
|
# Default User Agent header
|
12
|
-
USER_AGENT = "dnsimple-ruby/#{VERSION}"
|
12
|
+
USER_AGENT = "dnsimple-ruby/#{VERSION}".freeze
|
13
13
|
|
14
14
|
class << self
|
15
15
|
|
@@ -30,7 +30,7 @@ module Dnsimple
|
|
30
30
|
# Configuration options
|
31
31
|
# @return [Hash]
|
32
32
|
def options
|
33
|
-
|
33
|
+
keys.to_h { |key| [key, send(key)] }
|
34
34
|
end
|
35
35
|
|
36
36
|
# Default API endpoint from ENV or {BASE_URL}
|
data/lib/dnsimple/error.rb
CHANGED
@@ -18,7 +18,7 @@ module Dnsimple
|
|
18
18
|
|
19
19
|
def message_from(http_response)
|
20
20
|
content_type = http_response.headers["Content-Type"]
|
21
|
-
if content_type
|
21
|
+
if content_type&.start_with?("application/json")
|
22
22
|
http_response.parsed_response["message"]
|
23
23
|
else
|
24
24
|
net_http_response = http_response.response
|
data/lib/dnsimple/extra.rb
CHANGED
@@ -36,8 +36,8 @@ module Dnsimple
|
|
36
36
|
this[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
|
37
37
|
deep_merge(this_value, other_value, &block)
|
38
38
|
else
|
39
|
-
if
|
40
|
-
|
39
|
+
if block && key?(current_key)
|
40
|
+
yield(current_key, this_value, other_value)
|
41
41
|
else
|
42
42
|
other_value
|
43
43
|
end
|
@@ -55,7 +55,7 @@ module Dnsimple
|
|
55
55
|
# @raise [ArgumentError]
|
56
56
|
def self.validate_mandatory_attributes(attributes, required)
|
57
57
|
required.each do |name|
|
58
|
-
attributes
|
58
|
+
attributes&.key?(name) or raise(ArgumentError, ":#{name} is required")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
data/lib/dnsimple/response.rb
CHANGED
@@ -41,9 +41,7 @@ module Dnsimple
|
|
41
41
|
|
42
42
|
# The CollectionResponse is a specific type of Response where the data is a collection of enumerable objects.
|
43
43
|
class CollectionResponse < Response
|
44
|
-
|
45
|
-
super
|
46
|
-
end
|
44
|
+
|
47
45
|
end
|
48
46
|
|
49
47
|
# The PaginatedResponse is a specific type of Response that also exposes pagination metadata.
|
@@ -4,13 +4,6 @@ module Dnsimple
|
|
4
4
|
module Struct
|
5
5
|
|
6
6
|
class Certificate < Base
|
7
|
-
|
8
|
-
def initialize(attributes = {})
|
9
|
-
attributes.delete("expires_on")
|
10
|
-
super
|
11
|
-
@expires_on = Date.parse(expires_at).to_s if expires_at
|
12
|
-
end
|
13
|
-
|
14
7
|
# @return [Integer] The certificate ID in DNSimple.
|
15
8
|
attr_accessor :id
|
16
9
|
|
@@ -49,18 +42,6 @@ module Dnsimple
|
|
49
42
|
|
50
43
|
# @return [String] The timestamp when the certificate will expire.
|
51
44
|
attr_accessor :expires_at
|
52
|
-
|
53
|
-
# @deprecated Please use #expires_at instead.
|
54
|
-
# @return [String] The date when the certificate will expire.
|
55
|
-
def expires_on
|
56
|
-
warn "[DEPRECATION] Certificate#expires_on is deprecated. Please use `expires_at` instead."
|
57
|
-
@expires_on
|
58
|
-
end
|
59
|
-
|
60
|
-
def expires_on=(expiration_date)
|
61
|
-
warn "[DEPRECATION] Certificate#expires_on= is deprecated. Please use `expires_at=` instead."
|
62
|
-
@expires_on = expiration_date
|
63
|
-
end
|
64
45
|
end
|
65
46
|
|
66
47
|
end
|
@@ -22,6 +22,9 @@ module Dnsimple
|
|
22
22
|
# @return [String] The keytag for the associated DNSKEY.
|
23
23
|
attr_accessor :keytag
|
24
24
|
|
25
|
+
# @return [String] The public key that references the corresponding DNSKEY record.
|
26
|
+
attr_accessor :public_key
|
27
|
+
|
25
28
|
# @return [String] When the delegation signing record was created in DNSimple.
|
26
29
|
attr_accessor :created_at
|
27
30
|
|
@@ -4,13 +4,6 @@ module Dnsimple
|
|
4
4
|
module Struct
|
5
5
|
|
6
6
|
class Domain < Base
|
7
|
-
|
8
|
-
def initialize(attributes = {})
|
9
|
-
attributes.delete("expires_on")
|
10
|
-
super
|
11
|
-
@expires_on = Date.parse(expires_at).to_s if expires_at
|
12
|
-
end
|
13
|
-
|
14
7
|
# @return [Integer] The domain ID in DNSimple.
|
15
8
|
attr_accessor :id
|
16
9
|
|
@@ -43,19 +36,6 @@ module Dnsimple
|
|
43
36
|
|
44
37
|
# @return [String] When the domain was last updated in DNSimple.
|
45
38
|
attr_accessor :updated_at
|
46
|
-
|
47
|
-
# @deprecated Please use #expires_at instead.
|
48
|
-
# @return [String] The date the domain will expire.
|
49
|
-
def expires_on
|
50
|
-
warn "[DEPRECATION] Domain#expires_on is deprecated. Please use `expires_at` instead."
|
51
|
-
@expires_on
|
52
|
-
end
|
53
|
-
|
54
|
-
def expires_on=(expiration_date)
|
55
|
-
warn "[DEPRECATION] Domain#expires_on= is deprecated. Please use `expires_at=` instead."
|
56
|
-
@expires_on = expiration_date
|
57
|
-
end
|
58
|
-
|
59
39
|
end
|
60
40
|
end
|
61
41
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dnsimple
|
4
|
+
module Struct
|
5
|
+
|
6
|
+
class DomainPrice < Base
|
7
|
+
# @return [String] The domain name
|
8
|
+
attr_accessor :domain
|
9
|
+
|
10
|
+
# @return [Boolean] Whether the domain is premium.
|
11
|
+
attr_accessor :premium
|
12
|
+
|
13
|
+
# @return [Float] The price for registration
|
14
|
+
attr_accessor :registration_price
|
15
|
+
|
16
|
+
# @return [Float] The price for renewal
|
17
|
+
attr_accessor :renewal_price
|
18
|
+
|
19
|
+
# @return [Float] The price for transfer
|
20
|
+
attr_accessor :transfer_price
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/dnsimple/struct/tld.rb
CHANGED
@@ -30,6 +30,9 @@ module Dnsimple
|
|
30
30
|
|
31
31
|
# @return [Boolean] True if DNSimple supports inbound transfers for this TLD.
|
32
32
|
attr_accessor :transfer_enabled
|
33
|
+
|
34
|
+
# @return [String, nil] Type of data interface required for DNSSEC for this TLD.
|
35
|
+
attr_accessor :dnssec_interface_type
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
data/lib/dnsimple/struct.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative 'struct/dnssec'
|
|
27
27
|
require_relative 'struct/domain'
|
28
28
|
require_relative 'struct/domain_check'
|
29
29
|
require_relative 'struct/domain_premium_price'
|
30
|
+
require_relative 'struct/domain_price'
|
30
31
|
require_relative 'struct/domain_push'
|
31
32
|
require_relative 'struct/domain_registration'
|
32
33
|
require_relative 'struct/domain_transfer'
|
data/lib/dnsimple/version.rb
CHANGED
@@ -120,7 +120,6 @@ describe Dnsimple::Client, ".certificates" do
|
|
120
120
|
expect(result.auto_renew).to be(false)
|
121
121
|
expect(result.created_at).to eq("2020-06-18T18:54:17Z")
|
122
122
|
expect(result.updated_at).to eq("2020-06-18T19:10:14Z")
|
123
|
-
expect(result.expires_on).to eq("2020-09-16")
|
124
123
|
expect(result.expires_at).to eq("2020-09-16T18:10:13Z")
|
125
124
|
end
|
126
125
|
|
@@ -6,7 +6,7 @@ describe Dnsimple::Client::ClientService do
|
|
6
6
|
|
7
7
|
describe "#paginate" do
|
8
8
|
service_class = Class.new(Dnsimple::Client::ClientService) do
|
9
|
-
Item = Class.new(Dnsimple::Struct::Base) do
|
9
|
+
Item = Class.new(Dnsimple::Struct::Base) do # rubocop:disable Lint/ConstantDefinitionInBlock
|
10
10
|
attr_accessor :id
|
11
11
|
end
|
12
12
|
|
@@ -86,13 +86,13 @@ describe Dnsimple::Client, ".contacts" do
|
|
86
86
|
|
87
87
|
describe "#create_contact" do
|
88
88
|
let(:account_id) { 1010 }
|
89
|
+
let(:attributes) { { first_name: "Simone", last_name: "Carletti", address1: "Italian Street", city: "Rome", state_province: "RM", postal_code: "00171", country: "IT", email: "example@example.com", phone: "+393391234567" } }
|
89
90
|
|
90
91
|
before do
|
91
92
|
stub_request(:post, %r{/v2/#{account_id}/contacts$})
|
92
93
|
.to_return(read_http_fixture("createContact/created.http"))
|
93
94
|
end
|
94
95
|
|
95
|
-
let(:attributes) { { first_name: "Simone", last_name: "Carletti", address1: "Italian Street", city: "Rome", state_province: "RM", postal_code: "00171", country: "IT", email: "example@example.com", phone: "+393391234567" } }
|
96
96
|
|
97
97
|
it "builds the correct request" do
|
98
98
|
subject.create_contact(account_id, attributes)
|
@@ -153,13 +153,13 @@ describe Dnsimple::Client, ".contacts" do
|
|
153
153
|
|
154
154
|
describe "#update_contact" do
|
155
155
|
let(:account_id) { 1010 }
|
156
|
+
let(:attributes) { { first_name: "Updated" } }
|
156
157
|
|
157
158
|
before do
|
158
159
|
stub_request(:patch, %r{/v2/#{account_id}/contacts/.+$})
|
159
160
|
.to_return(read_http_fixture("updateContact/success.http"))
|
160
161
|
end
|
161
162
|
|
162
|
-
let(:attributes) { { first_name: "Updated" } }
|
163
163
|
|
164
164
|
it "builds the correct request" do
|
165
165
|
subject.update_contact(account_id, contact_id = 1, attributes)
|
@@ -63,7 +63,7 @@ describe Dnsimple::Client, ".domains" do
|
|
63
63
|
let(:account_id) { 1010 }
|
64
64
|
let(:domain_id) { "example.com" }
|
65
65
|
|
66
|
-
context "
|
66
|
+
context "when inviting a user already registered on DNSimple" do
|
67
67
|
before do
|
68
68
|
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/collaborators$})
|
69
69
|
.to_return(read_http_fixture("addCollaborator/success.http"))
|
@@ -93,7 +93,7 @@ describe Dnsimple::Client, ".domains" do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
context "
|
96
|
+
context "when inviting a user not registered on DNSimple" do
|
97
97
|
before do
|
98
98
|
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/collaborators$})
|
99
99
|
.to_return(read_http_fixture("addCollaborator/invite-success.http"))
|
@@ -99,6 +99,7 @@ describe Dnsimple::Client, ".domains" do
|
|
99
99
|
|
100
100
|
describe "#create_delegation_signer_record" do
|
101
101
|
let(:account_id) { 1010 }
|
102
|
+
let(:attributes) { { algorithm: "13", digest: "ABC123", digest_type: "2", keytag: "1111" } }
|
102
103
|
let(:domain_id) { "example.com" }
|
103
104
|
|
104
105
|
before do
|
@@ -106,7 +107,6 @@ describe Dnsimple::Client, ".domains" do
|
|
106
107
|
.to_return(read_http_fixture("createDelegationSignerRecord/created.http"))
|
107
108
|
end
|
108
109
|
|
109
|
-
let(:attributes) { { algorithm: "13", digest: "ABC123", digest_type: "2", keytag: "1111" } }
|
110
110
|
|
111
111
|
it "builds the correct request" do
|
112
112
|
subject.create_delegation_signer_record(account_id, domain_id, attributes)
|
@@ -155,6 +155,7 @@ describe Dnsimple::Client, ".domains" do
|
|
155
155
|
expect(result.digest).to eq("C1F6E04A5A61FBF65BF9DC8294C363CF11C89E802D926BDAB79C55D27BEFA94F")
|
156
156
|
expect(result.digest_type).to eq("2")
|
157
157
|
expect(result.keytag).to eq("44620")
|
158
|
+
expect(result.public_key).to be_nil
|
158
159
|
expect(result.created_at).to eq("2017-03-03T13:49:58Z")
|
159
160
|
expect(result.updated_at).to eq("2017-03-03T13:49:58Z")
|
160
161
|
end
|
@@ -99,6 +99,7 @@ describe Dnsimple::Client, ".domains" do
|
|
99
99
|
|
100
100
|
describe "#create_email_forward" do
|
101
101
|
let(:account_id) { 1010 }
|
102
|
+
let(:attributes) { { from: "jim", to: "jim@another.com" } }
|
102
103
|
let(:domain_id) { "example.com" }
|
103
104
|
|
104
105
|
before do
|
@@ -106,7 +107,6 @@ describe Dnsimple::Client, ".domains" do
|
|
106
107
|
.to_return(read_http_fixture("createEmailForward/created.http"))
|
107
108
|
end
|
108
109
|
|
109
|
-
let(:attributes) { { from: "jim", to: "jim@another.com" } }
|
110
110
|
|
111
111
|
it "builds the correct request" do
|
112
112
|
subject.create_email_forward(account_id, domain_id, attributes)
|
@@ -129,7 +129,7 @@ describe Dnsimple::Client, ".domains" do
|
|
129
129
|
describe "#email_forward" do
|
130
130
|
let(:account_id) { 1010 }
|
131
131
|
let(:domain_id) { "example.com" }
|
132
|
-
let(:email_forward_id) {
|
132
|
+
let(:email_forward_id) { 41872 }
|
133
133
|
|
134
134
|
before do
|
135
135
|
stub_request(:get, %r{/v2/#{account_id}/domains/#{domain_id}/email_forwards.+$})
|
@@ -149,12 +149,12 @@ describe Dnsimple::Client, ".domains" do
|
|
149
149
|
|
150
150
|
result = response.data
|
151
151
|
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
152
|
-
expect(result.id).to eq(
|
153
|
-
expect(result.domain_id).to eq(
|
154
|
-
expect(result.from).to eq("
|
155
|
-
expect(result.to).to eq("
|
156
|
-
expect(result.created_at).to eq("
|
157
|
-
expect(result.updated_at).to eq("
|
152
|
+
expect(result.id).to eq(41872)
|
153
|
+
expect(result.domain_id).to eq(235146)
|
154
|
+
expect(result.from).to eq("example@dnsimple.xyz")
|
155
|
+
expect(result.to).to eq("example@example.com")
|
156
|
+
expect(result.created_at).to eq("2021-01-25T13:54:40Z")
|
157
|
+
expect(result.updated_at).to eq("2021-01-25T13:54:40Z")
|
158
158
|
end
|
159
159
|
|
160
160
|
context "when the email forward does not exist" do
|
@@ -8,6 +8,7 @@ describe Dnsimple::Client, ".domains" do
|
|
8
8
|
|
9
9
|
describe "#initiate_push" do
|
10
10
|
let(:account_id) { 1010 }
|
11
|
+
let(:attributes) { { new_account_email: "admin@target-account.test" } }
|
11
12
|
let(:domain_id) { "example.com" }
|
12
13
|
|
13
14
|
before do
|
@@ -15,7 +16,6 @@ describe Dnsimple::Client, ".domains" do
|
|
15
16
|
.to_return(read_http_fixture("initiatePush/success.http"))
|
16
17
|
end
|
17
18
|
|
18
|
-
let(:attributes) { { new_account_email: "admin@target-account.test" } }
|
19
19
|
|
20
20
|
it "builds the correct request" do
|
21
21
|
subject.initiate_push(account_id, domain_id, attributes)
|
@@ -88,6 +88,7 @@ describe Dnsimple::Client, ".domains" do
|
|
88
88
|
|
89
89
|
describe "#accept_push" do
|
90
90
|
let(:account_id) { 2020 }
|
91
|
+
let(:attributes) { { contact_id: 2 } }
|
91
92
|
let(:push_id) { 1 }
|
92
93
|
|
93
94
|
before do
|
@@ -95,7 +96,6 @@ describe Dnsimple::Client, ".domains" do
|
|
95
96
|
.to_return(read_http_fixture("acceptPush/success.http"))
|
96
97
|
end
|
97
98
|
|
98
|
-
let(:attributes) { { contact_id: 2 } }
|
99
99
|
|
100
100
|
it "builds the correct request" do
|
101
101
|
subject.accept_push(account_id, push_id, attributes)
|
@@ -98,13 +98,13 @@ describe Dnsimple::Client, ".domains" do
|
|
98
98
|
|
99
99
|
describe "#create_domain" do
|
100
100
|
let(:account_id) { 1010 }
|
101
|
+
let(:attributes) { { name: "example.com" } }
|
101
102
|
|
102
103
|
before do
|
103
104
|
stub_request(:post, %r{/v2/#{account_id}/domains$})
|
104
105
|
.to_return(read_http_fixture("createDomain/created.http"))
|
105
106
|
end
|
106
107
|
|
107
|
-
let(:attributes) { { name: "example.com" } }
|
108
108
|
|
109
109
|
it "builds the correct request" do
|
110
110
|
subject.create_domain(account_id, attributes)
|
@@ -153,7 +153,6 @@ describe Dnsimple::Client, ".domains" do
|
|
153
153
|
expect(result.auto_renew).to be(false)
|
154
154
|
expect(result.private_whois).to be(false)
|
155
155
|
expect(result.expires_at).to eq("2021-06-05T02:15:00Z")
|
156
|
-
expect(result.expires_on).to eq("2021-06-05")
|
157
156
|
expect(result.created_at).to eq("2020-06-04T19:15:14Z")
|
158
157
|
expect(result.updated_at).to eq("2020-06-04T19:15:21Z")
|
159
158
|
end
|
@@ -204,31 +203,4 @@ describe Dnsimple::Client, ".domains" do
|
|
204
203
|
end
|
205
204
|
end
|
206
205
|
end
|
207
|
-
|
208
|
-
describe "#reset_domain_token" do
|
209
|
-
let(:account_id) { 1010 }
|
210
|
-
let(:domain_id) { "example.com" }
|
211
|
-
|
212
|
-
before do
|
213
|
-
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/token})
|
214
|
-
.to_return(read_http_fixture("resetDomainToken/success.http"))
|
215
|
-
end
|
216
|
-
|
217
|
-
it "builds the correct request" do
|
218
|
-
subject.reset_domain_token(account_id, domain_id)
|
219
|
-
|
220
|
-
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/token")
|
221
|
-
.with(headers: { 'Accept' => 'application/json' })
|
222
|
-
end
|
223
|
-
|
224
|
-
it "returns the domain" do
|
225
|
-
response = subject.reset_domain_token(account_id, domain_id)
|
226
|
-
expect(response).to be_a(Dnsimple::Response)
|
227
|
-
|
228
|
-
result = response.data
|
229
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
230
|
-
expect(result.id).to be_a(Integer)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
206
|
end
|
@@ -31,13 +31,13 @@ describe Dnsimple::Client, ".registrar" do
|
|
31
31
|
|
32
32
|
describe "#change_domain_delegation" do
|
33
33
|
let(:account_id) { 1010 }
|
34
|
+
let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }
|
34
35
|
|
35
36
|
before do
|
36
37
|
stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation$})
|
37
38
|
.to_return(read_http_fixture("changeDomainDelegation/success.http"))
|
38
39
|
end
|
39
40
|
|
40
|
-
let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }
|
41
41
|
|
42
42
|
it "builds the correct request" do
|
43
43
|
subject.change_domain_delegation(account_id, domain_name = "example.com", attributes)
|
@@ -57,13 +57,13 @@ describe Dnsimple::Client, ".registrar" do
|
|
57
57
|
|
58
58
|
describe "#change_domain_delegation_to_vanity" do
|
59
59
|
let(:account_id) { 1010 }
|
60
|
+
let(:attributes) { %w(ns1.example.com ns2.example.com) }
|
60
61
|
|
61
62
|
before do
|
62
63
|
stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$})
|
63
64
|
.to_return(read_http_fixture("changeDomainDelegationToVanity/success.http"))
|
64
65
|
end
|
65
66
|
|
66
|
-
let(:attributes) { %w(ns1.example.com ns2.example.com) }
|
67
67
|
|
68
68
|
it "builds the correct request" do
|
69
69
|
subject.change_domain_delegation_to_vanity(account_id, domain_name = "example.com", attributes)
|