dnsimple 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -23
  5. data/.rubocop_todo.yml +63 -5
  6. data/.travis.yml +7 -3
  7. data/CHANGELOG.md +17 -0
  8. data/CONTRIBUTING.md +8 -2
  9. data/Gemfile +3 -1
  10. data/LICENSE.txt +1 -1
  11. data/README.md +4 -4
  12. data/lib/dnsimple/client/domains.rb +1 -19
  13. data/lib/dnsimple/client/registrar.rb +20 -0
  14. data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
  15. data/lib/dnsimple/client.rb +11 -3
  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/certificate.rb +2 -2
  20. data/lib/dnsimple/struct/domain.rb +2 -3
  21. data/lib/dnsimple/struct/domain_price.rb +24 -0
  22. data/lib/dnsimple/struct.rb +1 -0
  23. data/lib/dnsimple/version.rb +1 -1
  24. data/spec/dnsimple/client/certificates_spec.rb +33 -33
  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 +14 -41
  31. data/spec/dnsimple/client/registrar_delegation_spec.rb +2 -2
  32. data/spec/dnsimple/client/registrar_spec.rb +62 -19
  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 +18 -30
  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 +20 -16
  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 +10 -11
  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 +13 -9
  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 +20 -30
  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 +18 -21
  108. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +18 -21
  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 +10 -11
  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 +20 -16
  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 +20 -21
  146. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +20 -21
  147. data/spec/fixtures.http/registerDomain/success.http +1 -2
  148. data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
  149. data/spec/fixtures.http/renewDomain/success.http +1 -2
  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 +1 -2
  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
@@ -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)
@@ -35,9 +35,9 @@ describe Dnsimple::Client, ".domains" do
35
35
  end
36
36
 
37
37
  it "supports sorting" do
38
- subject.domains(account_id, sort: "expires_on:asc")
38
+ subject.domains(account_id, sort: "expiration:asc")
39
39
 
40
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?sort=expires_on:asc")
40
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?sort=expiration:asc")
41
41
  end
42
42
 
43
43
  it "supports filtering" do
@@ -84,9 +84,9 @@ describe Dnsimple::Client, ".domains" do
84
84
  end
85
85
 
86
86
  it "supports sorting" do
87
- subject.all_domains(account_id, sort: "expires_on:asc")
87
+ subject.all_domains(account_id, sort: "expiration:asc")
88
88
 
89
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100&sort=expires_on:asc")
89
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100&sort=expiration:asc")
90
90
  end
91
91
 
92
92
  it "supports filtering" do
@@ -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)
@@ -133,28 +133,28 @@ describe Dnsimple::Client, ".domains" do
133
133
  end
134
134
 
135
135
  it "builds the correct request" do
136
- subject.domain(account_id, domain = "example.com")
136
+ subject.domain(account_id, domain = "example-alpha.com")
137
137
 
138
138
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain}")
139
139
  .with(headers: { 'Accept' => 'application/json' })
140
140
  end
141
141
 
142
142
  it "returns the domain" do
143
- response = subject.domain(account_id, "example.com")
143
+ response = subject.domain(account_id, "example-alpha.com")
144
144
  expect(response).to be_a(Dnsimple::Response)
145
145
 
146
146
  result = response.data
147
147
  expect(result).to be_a(Dnsimple::Struct::Domain)
148
- expect(result.id).to eq(1)
149
- expect(result.account_id).to eq(1010)
150
- expect(result.registrant_id).to eq(nil)
148
+ expect(result.id).to eq(181984)
149
+ expect(result.account_id).to eq(1385)
150
+ expect(result.registrant_id).to eq(2715)
151
151
  expect(result.name).to eq("example-alpha.com")
152
- expect(result.state).to eq("hosted")
152
+ expect(result.state).to eq("registered")
153
153
  expect(result.auto_renew).to be(false)
154
154
  expect(result.private_whois).to be(false)
155
- expect(result.expires_on).to eq(nil)
156
- expect(result.created_at).to eq("2014-12-06T15:56:55Z")
157
- expect(result.updated_at).to eq("2015-12-09T00:20:56Z")
155
+ expect(result.expires_at).to eq("2021-06-05T02:15:00Z")
156
+ expect(result.created_at).to eq("2020-06-04T19:15:14Z")
157
+ expect(result.updated_at).to eq("2020-06-04T19:15:21Z")
158
158
  end
159
159
 
160
160
  context "when the domain does not exist" do
@@ -203,31 +203,4 @@ describe Dnsimple::Client, ".domains" do
203
203
  end
204
204
  end
205
205
  end
206
-
207
- describe "#reset_domain_token" do
208
- let(:account_id) { 1010 }
209
- let(:domain_id) { "example.com" }
210
-
211
- before do
212
- stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/token})
213
- .to_return(read_http_fixture("resetDomainToken/success.http"))
214
- end
215
-
216
- it "builds the correct request" do
217
- subject.reset_domain_token(account_id, domain_id)
218
-
219
- expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/token")
220
- .with(headers: { 'Accept' => 'application/json' })
221
- end
222
-
223
- it "returns the domain" do
224
- response = subject.reset_domain_token(account_id, domain_id)
225
- expect(response).to be_a(Dnsimple::Response)
226
-
227
- result = response.data
228
- expect(result).to be_a(Dnsimple::Struct::Domain)
229
- expect(result.id).to be_a(Integer)
230
- end
231
- end
232
-
233
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)
@@ -39,7 +39,7 @@ describe Dnsimple::Client, ".registrar" do
39
39
 
40
40
  context "when premium price" do
41
41
  before do
42
- stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[\?action]*})
42
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[?action]*})
43
43
  .to_return(read_http_fixture("getDomainPremiumPrice/success.http"))
44
44
  end
45
45
 
@@ -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)
@@ -223,27 +266,27 @@ describe Dnsimple::Client, ".registrar" do
223
266
  end
224
267
 
225
268
  it "builds the correct request" do
226
- subject.get_domain_transfer(account_id, domain_name = "example.com", transfer_id = 42)
269
+ subject.get_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
227
270
 
228
271
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
229
272
  .with(headers: { "Accept" => "application/json" })
230
273
  end
231
274
 
232
275
  it "returns the domain transfer" do
233
- response = subject.get_domain_transfer(account_id, "example.com", 42)
276
+ response = subject.get_domain_transfer(account_id, "example.com", 361)
234
277
  expect(response).to be_a(Dnsimple::Response)
235
278
 
236
279
  result = response.data
237
280
  expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
238
- expect(result.id).to eq(42)
239
- expect(result.domain_id).to eq(2)
240
- expect(result.registrant_id).to eq(3)
281
+ expect(result.id).to eq(361)
282
+ expect(result.domain_id).to eq(182245)
283
+ expect(result.registrant_id).to eq(2715)
241
284
  expect(result.state).to eq("cancelled")
242
285
  expect(result.auto_renew).to be(false)
243
286
  expect(result.whois_privacy).to be(false)
244
287
  expect(result.status_description).to eq("Canceled by customer")
245
- expect(result.created_at).to eq("2020-04-27T18:08:44Z")
246
- expect(result.updated_at).to eq("2020-04-27T18:20:01Z")
288
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
289
+ expect(result.updated_at).to eq("2020-06-05T18:10:01Z")
247
290
  end
248
291
  end
249
292
 
@@ -256,27 +299,27 @@ describe Dnsimple::Client, ".registrar" do
256
299
  end
257
300
 
258
301
  it "builds the correct request" do
259
- subject.cancel_domain_transfer(account_id, domain_name = "example.com", transfer_id = 42)
302
+ subject.cancel_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
260
303
 
261
304
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
262
305
  .with(headers: { "Accept" => "application/json" })
263
306
  end
264
307
 
265
308
  it "returns the domain transfer" do
266
- response = subject.cancel_domain_transfer(account_id, "example.com", 42)
309
+ response = subject.cancel_domain_transfer(account_id, "example.com", 361)
267
310
  expect(response).to be_a(Dnsimple::Response)
268
311
 
269
312
  result = response.data
270
313
  expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
271
- expect(result.id).to eq(42)
272
- expect(result.domain_id).to eq(6)
273
- expect(result.registrant_id).to eq(1)
314
+ expect(result.id).to eq(361)
315
+ expect(result.domain_id).to eq(182245)
316
+ expect(result.registrant_id).to eq(2715)
274
317
  expect(result.state).to eq("transferring")
275
- expect(result.auto_renew).to be(true)
318
+ expect(result.auto_renew).to be(false)
276
319
  expect(result.whois_privacy).to be(false)
277
320
  expect(result.status_description).to eq(nil)
278
- expect(result.created_at).to eq("2020-04-24T19:19:03Z")
279
- expect(result.updated_at).to eq("2020-04-24T19:19:15Z")
321
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
322
+ expect(result.updated_at).to eq("2020-06-05T18:08:04Z")
280
323
  end
281
324
  end
282
325
 
@@ -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)
@@ -112,6 +112,7 @@ describe Dnsimple::Client, ".zones" do
112
112
 
113
113
  describe "#create_zone_record" do
114
114
  let(:account_id) { 1010 }
115
+ let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
115
116
  let(:zone_id) { "example.com" }
116
117
 
117
118
  before do
@@ -119,7 +120,6 @@ describe Dnsimple::Client, ".zones" do
119
120
  .to_return(read_http_fixture("createZoneRecord/created.http"))
120
121
  end
121
122
 
122
- let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
123
123
 
124
124
  it "builds the correct request" do
125
125
  subject.create_zone_record(account_id, zone_id, attributes)
@@ -216,6 +216,7 @@ describe Dnsimple::Client, ".zones" do
216
216
 
217
217
  describe "#update_zone_record" do
218
218
  let(:account_id) { 1010 }
219
+ let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
219
220
  let(:zone_id) { "example.com" }
220
221
  let(:record_id) { 5 }
221
222
 
@@ -224,7 +225,6 @@ describe Dnsimple::Client, ".zones" do
224
225
  .to_return(read_http_fixture("updateZoneRecord/success.http"))
225
226
  end
226
227
 
227
- let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
228
228
 
229
229
  it "builds the correct request" do
230
230
  subject.update_zone_record(account_id, zone_id, record_id, attributes)
@@ -89,7 +89,7 @@ describe Dnsimple::Client, ".zones" do
89
89
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&sort=name:desc")
90
90
  end
91
91
 
92
- it "supports sorting" do
92
+ it "supports filtering" do
93
93
  subject.all_zones(account_id, filter: { name_like: "zone.test" })
94
94
 
95
95
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&name_like=zone.test")
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Tue, 14 Jun 2016 12:02:58 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2391
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Tue, 14 Jun 2016 12:05:38 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2390
@@ -2,7 +2,6 @@ HTTP/1.1 201 Created
2
2
  Server: nginx
3
3
  Date: Fri, 07 Oct 2016 08:51:12 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2398
@@ -2,7 +2,6 @@ HTTP/1.1 201 Created
2
2
  Server: nginx
3
3
  Date: Fri, 07 Oct 2016 08:53:41 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2397
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Wed, 15 Jun 2016 11:09:44 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2398