dnsimple 5.2.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +4 -1
  4. data/.rubocop_dnsimple.yml +1 -38
  5. data/.rubocop_todo.yml +63 -5
  6. data/.travis.yml +7 -3
  7. data/CHANGELOG.md +10 -0
  8. data/CONTRIBUTING.md +2 -2
  9. data/Gemfile +3 -1
  10. data/LICENSE.txt +1 -1
  11. data/README.md +4 -4
  12. data/lib/dnsimple/client.rb +11 -3
  13. data/lib/dnsimple/client/domains.rb +0 -18
  14. data/lib/dnsimple/client/registrar.rb +20 -0
  15. data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
  16. data/lib/dnsimple/default.rb +1 -1
  17. data/lib/dnsimple/extra.rb +1 -1
  18. data/lib/dnsimple/response.rb +1 -3
  19. data/lib/dnsimple/struct.rb +1 -0
  20. data/lib/dnsimple/struct/certificate.rb +0 -19
  21. data/lib/dnsimple/struct/domain.rb +0 -20
  22. data/lib/dnsimple/struct/domain_price.rb +24 -0
  23. data/lib/dnsimple/version.rb +1 -1
  24. data/spec/dnsimple/client/certificates_spec.rb +0 -1
  25. data/spec/dnsimple/client/client_service_spec.rb +1 -1
  26. data/spec/dnsimple/client/contacts_spec.rb +2 -2
  27. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +1 -1
  28. data/spec/dnsimple/client/domains_email_forwards_spec.rb +8 -8
  29. data/spec/dnsimple/client/domains_pushes_spec.rb +2 -2
  30. data/spec/dnsimple/client/domains_spec.rb +1 -29
  31. data/spec/dnsimple/client/registrar_delegation_spec.rb +2 -2
  32. data/spec/dnsimple/client/registrar_spec.rb +46 -3
  33. data/spec/dnsimple/client/services_domains_spec.rb +2 -4
  34. data/spec/dnsimple/client/services_spec.rb +1 -3
  35. data/spec/dnsimple/client/templates_records_spec.rb +1 -1
  36. data/spec/dnsimple/client/templates_spec.rb +2 -2
  37. data/spec/dnsimple/client/webhooks_spec.rb +1 -1
  38. data/spec/dnsimple/client/zones_records_spec.rb +2 -2
  39. data/spec/dnsimple/client/zones_spec.rb +1 -1
  40. data/spec/fixtures.http/accounts/success-account.http +0 -1
  41. data/spec/fixtures.http/accounts/success-user.http +0 -1
  42. data/spec/fixtures.http/addCollaborator/invite-success.http +0 -1
  43. data/spec/fixtures.http/addCollaborator/success.http +0 -1
  44. data/spec/fixtures.http/appliedServices/success.http +0 -1
  45. data/spec/fixtures.http/cancelDomainTransfer/success.http +0 -1
  46. data/spec/fixtures.http/changeDomainDelegation/success.http +0 -1
  47. data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +0 -1
  48. data/spec/fixtures.http/checkDomain/success.http +0 -1
  49. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http +18 -0
  50. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http +18 -0
  51. data/spec/fixtures.http/checkDomainPremiumPrice/success.http +20 -0
  52. data/spec/fixtures.http/checkZoneDistribution/error.http +0 -1
  53. data/spec/fixtures.http/checkZoneDistribution/failure.http +0 -1
  54. data/spec/fixtures.http/checkZoneDistribution/success.http +0 -1
  55. data/spec/fixtures.http/checkZoneRecordDistribution/error.http +0 -1
  56. data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +0 -1
  57. data/spec/fixtures.http/checkZoneRecordDistribution/success.http +0 -1
  58. data/spec/fixtures.http/createContact/created.http +0 -1
  59. data/spec/fixtures.http/createDelegationSignerRecord/created.http +0 -1
  60. data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
  61. data/spec/fixtures.http/createDomain/created.http +0 -1
  62. data/spec/fixtures.http/createEmailForward/created.http +21 -17
  63. data/spec/fixtures.http/createPrimaryServer/created.http +21 -0
  64. data/spec/fixtures.http/createSecondaryZone/created.http +21 -0
  65. data/spec/fixtures.http/createTemplate/created.http +0 -1
  66. data/spec/fixtures.http/createTemplateRecord/created.http +0 -1
  67. data/spec/fixtures.http/createWebhook/created.http +0 -1
  68. data/spec/fixtures.http/createZoneRecord/created-apex.http +0 -1
  69. data/spec/fixtures.http/createZoneRecord/created.http +0 -1
  70. data/spec/fixtures.http/deleteContact/error-contact-in-use.http +18 -0
  71. data/spec/fixtures.http/deleteEmailForward/success.http +12 -7
  72. data/spec/fixtures.http/disableDnssec/not-enabled.http +0 -1
  73. data/spec/fixtures.http/disableWhoisPrivacy/success.http +0 -1
  74. data/spec/fixtures.http/downloadCertificate/success.http +0 -1
  75. data/spec/fixtures.http/enableDnssec/success.http +0 -1
  76. data/spec/fixtures.http/enableVanityNameServers/success.http +0 -1
  77. data/spec/fixtures.http/enableWhoisPrivacy/created.http +0 -1
  78. data/spec/fixtures.http/enableWhoisPrivacy/success.http +0 -1
  79. data/spec/fixtures.http/getCertificate/success.http +0 -1
  80. data/spec/fixtures.http/getCertificatePrivateKey/success.http +0 -1
  81. data/spec/fixtures.http/getContact/success.http +0 -1
  82. data/spec/fixtures.http/getDelegationSignerRecord/success.http +0 -1
  83. data/spec/fixtures.http/getDnssec/success.http +0 -1
  84. data/spec/fixtures.http/getDomain/success.http +0 -1
  85. data/spec/fixtures.http/getDomainDelegation/success-empty.http +0 -1
  86. data/spec/fixtures.http/getDomainDelegation/success.http +0 -1
  87. data/spec/fixtures.http/getDomainPremiumPrice/failure.http +0 -1
  88. data/spec/fixtures.http/getDomainPremiumPrice/success.http +0 -1
  89. data/spec/fixtures.http/getDomainPrices/failure.http +19 -0
  90. data/spec/fixtures.http/getDomainPrices/success.http +21 -0
  91. data/spec/fixtures.http/getDomainTransfer/success.http +0 -1
  92. data/spec/fixtures.http/getEmailForward/success.http +14 -10
  93. data/spec/fixtures.http/getPrimaryServer/success.http +21 -0
  94. data/spec/fixtures.http/getService/success.http +0 -1
  95. data/spec/fixtures.http/getTemplate/success.http +0 -1
  96. data/spec/fixtures.http/getTemplateRecord/success.http +0 -1
  97. data/spec/fixtures.http/getTld/success.http +0 -1
  98. data/spec/fixtures.http/getTldExtendedAttributes/success-attributes.http +0 -1
  99. data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +0 -1
  100. data/spec/fixtures.http/getTldExtendedAttributes/success.http +0 -1
  101. data/spec/fixtures.http/getWebhook/success.http +0 -1
  102. data/spec/fixtures.http/getWhoisPrivacy/success.http +0 -1
  103. data/spec/fixtures.http/getZone/success.http +0 -1
  104. data/spec/fixtures.http/getZoneFile/success.http +0 -1
  105. data/spec/fixtures.http/getZoneRecord/success.http +0 -1
  106. data/spec/fixtures.http/initiatePush/success.http +0 -1
  107. data/spec/fixtures.http/issueLetsencryptCertificate/success.http +0 -1
  108. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +0 -1
  109. data/spec/fixtures.http/linkPrimaryServer/success.http +21 -0
  110. data/spec/fixtures.http/listAccounts/success-account.http +0 -1
  111. data/spec/fixtures.http/listAccounts/success-user.http +0 -1
  112. data/spec/fixtures.http/listCertificates/success.http +0 -1
  113. data/spec/fixtures.http/listCollaborators/success.http +0 -1
  114. data/spec/fixtures.http/listContacts/success.http +0 -1
  115. data/spec/fixtures.http/listDelegationSignerRecords/success.http +0 -1
  116. data/spec/fixtures.http/listDomains/success.http +0 -1
  117. data/spec/fixtures.http/listEmailForwards/success.http +0 -1
  118. data/spec/fixtures.http/listPrimaryServers/success.http +21 -0
  119. data/spec/fixtures.http/listPushes/success.http +0 -1
  120. data/spec/fixtures.http/listServices/success.http +0 -1
  121. data/spec/fixtures.http/listTemplateRecords/success.http +0 -1
  122. data/spec/fixtures.http/listTemplates/success.http +0 -1
  123. data/spec/fixtures.http/listTlds/success.http +0 -1
  124. data/spec/fixtures.http/listWebhooks/success.http +0 -1
  125. data/spec/fixtures.http/listZoneRecords/success.http +0 -1
  126. data/spec/fixtures.http/listZones/success.http +0 -1
  127. data/spec/fixtures.http/method-not-allowed.http +0 -1
  128. data/spec/fixtures.http/notfound-certificate.http +0 -1
  129. data/spec/fixtures.http/notfound-collaborator.http +0 -1
  130. data/spec/fixtures.http/notfound-contact.http +0 -1
  131. data/spec/fixtures.http/notfound-delegationsignerrecord.http +0 -1
  132. data/spec/fixtures.http/notfound-domain.http +0 -1
  133. data/spec/fixtures.http/notfound-domainpush.http +0 -1
  134. data/spec/fixtures.http/notfound-emailforward.http +0 -1
  135. data/spec/fixtures.http/notfound-record.http +0 -1
  136. data/spec/fixtures.http/notfound-template.http +0 -1
  137. data/spec/fixtures.http/notfound-webhook.http +0 -1
  138. data/spec/fixtures.http/notfound-whoisprivacy.http +0 -1
  139. data/spec/fixtures.http/notfound-zone.http +0 -1
  140. data/spec/fixtures.http/oauthAccessToken/error-invalid-request.http +0 -1
  141. data/spec/fixtures.http/oauthAccessToken/success.http +0 -1
  142. data/spec/fixtures.http/pages-1of3.http +0 -1
  143. data/spec/fixtures.http/pages-2of3.http +0 -1
  144. data/spec/fixtures.http/pages-3of3.http +0 -1
  145. data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +0 -1
  146. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +0 -1
  147. data/spec/fixtures.http/registerDomain/success.http +0 -1
  148. data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
  149. data/spec/fixtures.http/renewDomain/success.http +0 -1
  150. data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
  151. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +0 -1
  152. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +0 -1
  153. data/spec/fixtures.http/response.http +0 -1
  154. data/spec/fixtures.http/transferDomain/error-indnsimple.http +0 -1
  155. data/spec/fixtures.http/transferDomain/error-missing-authcode.http +0 -1
  156. data/spec/fixtures.http/transferDomain/success.http +0 -1
  157. data/spec/fixtures.http/unlinkPrimaryServer/success.http +21 -0
  158. data/spec/fixtures.http/updateContact/success.http +0 -1
  159. data/spec/fixtures.http/updateTemplate/success.http +0 -1
  160. data/spec/fixtures.http/updateZoneRecord/success.http +0 -1
  161. data/spec/fixtures.http/validation-error.http +0 -1
  162. data/spec/fixtures.http/whoami/success-account.http +0 -1
  163. data/spec/fixtures.http/whoami/success-user.http +0 -1
  164. data/spec/fixtures.http/whoami/success.http +0 -1
  165. data/spec/spec_helper.rb +1 -1
  166. metadata +31 -8
  167. data/spec/fixtures.http/resetDomainToken/success.http +0 -17
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dnsimple
4
- VERSION = "5.2.0"
4
+ VERSION = "6.0.0"
5
5
  end
@@ -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)
@@ -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)
@@ -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) { 17706 }
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(17706)
153
- expect(result.domain_id).to eq(228963)
154
- expect(result.from).to eq("jim@a-domain.com")
155
- expect(result.to).to eq("jim@another.com")
156
- expect(result.created_at).to eq("2016-02-04T14:26:50Z")
157
- expect(result.updated_at).to eq("2016-02-04T14:26:50Z")
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)
@@ -82,15 +82,58 @@ describe Dnsimple::Client, ".registrar" do
82
82
  end
83
83
  end
84
84
 
85
+ describe "#get_domain_prices" do
86
+ let(:account_id) { 1010 }
87
+
88
+ before do
89
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pizza/prices$})
90
+ .to_return(read_http_fixture("getDomainPrices/success.http"))
91
+ end
92
+
93
+ it "builds the correct request" do
94
+ subject.get_domain_prices(account_id, "bingo.pizza")
95
+
96
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/bingo.pizza/prices")
97
+ .with(headers: { "Accept" => "application/json" })
98
+ end
99
+
100
+ it "returns the prices" do
101
+ response = subject.get_domain_prices(account_id, "bingo.pizza")
102
+ expect(response).to be_a(Dnsimple::Response)
103
+
104
+ result = response.data
105
+
106
+ expect(result).to be_a(Dnsimple::Struct::DomainPrice)
107
+ expect(result.domain).to eq("bingo.pizza")
108
+ expect(result.premium).to be(true)
109
+ expect(result.registration_price).to eq(20.0)
110
+ expect(result.renewal_price).to eq(20.0)
111
+ expect(result.transfer_price).to eq(20.0)
112
+ end
113
+
114
+ context "when the TLD is not supported" do
115
+ before do
116
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pineapple/prices$})
117
+ .to_return(read_http_fixture("getDomainPrices/failure.http"))
118
+ end
119
+
120
+ it "raises error" do
121
+ expect {
122
+ subject.get_domain_prices(account_id, "bingo.pineapple")
123
+ }.to raise_error(Dnsimple::RequestError, "TLD .PINEAPPLE is not supported")
124
+ end
125
+ end
126
+ end
127
+
85
128
  describe "#register_domain" do
86
129
  let(:account_id) { 1010 }
130
+ let(:attributes) { { registrant_id: "10" } }
87
131
 
88
132
  before do
89
133
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/registrations$})
90
134
  .to_return(read_http_fixture("registerDomain/success.http"))
91
135
  end
92
136
 
93
- let(:attributes) { { registrant_id: "10" } }
94
137
 
95
138
  it "builds the correct request" do
96
139
  subject.register_domain(account_id, domain_name = "example.com", attributes)
@@ -119,13 +162,13 @@ describe Dnsimple::Client, ".registrar" do
119
162
 
120
163
  describe "#renew_domain" do
121
164
  let(:account_id) { 1010 }
165
+ let(:attributes) { { period: "3" } }
122
166
 
123
167
  before do
124
168
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/renewals$})
125
169
  .to_return(read_http_fixture("renewDomain/success.http"))
126
170
  end
127
171
 
128
- let(:attributes) { { period: "3" } }
129
172
 
130
173
  it "builds the correct request" do
131
174
  subject.renew_domain(account_id, domain_name = "example.com", attributes)
@@ -159,13 +202,13 @@ describe Dnsimple::Client, ".registrar" do
159
202
 
160
203
  describe "#transfer_domain" do
161
204
  let(:account_id) { 1010 }
205
+ let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
162
206
 
163
207
  before do
164
208
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/transfers$})
165
209
  .to_return(read_http_fixture("transferDomain/success.http"))
166
210
  end
167
211
 
168
- let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
169
212
 
170
213
  it "builds the correct request" do
171
214
  subject.transfer_domain(account_id, domain_name = "example.com", attributes)
@@ -52,15 +52,14 @@ describe Dnsimple::Client, ".services" do
52
52
  expect(service.sid).to be_a(String)
53
53
  expect(service.description).to be_a(String)
54
54
 
55
- service.settings.each do |service_setting|
56
- expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
57
- end
55
+ expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
58
56
  end
59
57
  end
60
58
  end
61
59
 
62
60
  describe "#apply_service" do
63
61
  let(:account_id) { 1010 }
62
+ let(:settings) { { app: "foo" } }
64
63
  let(:domain_id) { "example.com" }
65
64
  let(:service_id) { "service1" }
66
65
 
@@ -69,7 +68,6 @@ describe Dnsimple::Client, ".services" do
69
68
  .to_return(read_http_fixture("applyService/success.http"))
70
69
  end
71
70
 
72
- let(:settings) { { app: "foo" } }
73
71
 
74
72
  it "builds the correct request" do
75
73
  subject.apply_service(account_id, service_id, domain_id, settings)
@@ -49,9 +49,7 @@ describe Dnsimple::Client, ".services" do
49
49
  expect(service.sid).to be_a(String)
50
50
  expect(service.description).to be_a(String)
51
51
 
52
- service.settings.each do |service_setting|
53
- expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
54
- end
52
+ expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
55
53
  end
56
54
  end
57
55
  end
@@ -78,6 +78,7 @@ describe Dnsimple::Client, ".templates" do
78
78
 
79
79
  describe "#create_record" do
80
80
  let(:account_id) { 1010 }
81
+ let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
81
82
  let(:template_id) { "alpha" }
82
83
 
83
84
  before do
@@ -85,7 +86,6 @@ describe Dnsimple::Client, ".templates" do
85
86
  .to_return(read_http_fixture("createTemplateRecord/created.http"))
86
87
  end
87
88
 
88
- let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
89
89
 
90
90
  it "builds the correct request" do
91
91
  subject.create_record(account_id, template_id, attributes)
@@ -77,13 +77,13 @@ describe Dnsimple::Client, ".templates" do
77
77
 
78
78
  describe "#create_template" do
79
79
  let(:account_id) { 1010 }
80
+ let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
80
81
 
81
82
  before do
82
83
  stub_request(:post, %r{/v2/#{account_id}/templates$})
83
84
  .to_return(read_http_fixture("createTemplate/created.http"))
84
85
  end
85
86
 
86
- let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
87
87
 
88
88
  it "builds the correct request" do
89
89
  subject.create_template(account_id, attributes)
@@ -138,6 +138,7 @@ describe Dnsimple::Client, ".templates" do
138
138
 
139
139
  describe "#update_template" do
140
140
  let(:account_id) { 1010 }
141
+ let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
141
142
  let(:template_id) { 1 }
142
143
 
143
144
  before do
@@ -145,7 +146,6 @@ describe Dnsimple::Client, ".templates" do
145
146
  .to_return(read_http_fixture("updateTemplate/success.http"))
146
147
  end
147
148
 
148
- let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
149
149
 
150
150
  it "builds the correct request" do
151
151
  subject.update_template(account_id, template_id, attributes)
@@ -49,13 +49,13 @@ describe Dnsimple::Client, ".webhooks" do
49
49
 
50
50
  describe "#create_webhook" do
51
51
  let(:account_id) { 1010 }
52
+ let(:attributes) { { url: "https://webhook.test" } }
52
53
 
53
54
  before do
54
55
  stub_request(:post, %r{/v2/#{account_id}/webhooks$})
55
56
  .to_return(read_http_fixture("createWebhook/created.http"))
56
57
  end
57
58
 
58
- let(:attributes) { { url: "https://webhook.test" } }
59
59
 
60
60
  it "builds the correct request" do
61
61
  subject.create_webhook(account_id, attributes)