dnsimple 4.3.0 → 5.1.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 (143) hide show
  1. checksums.yaml +5 -5
  2. data/.dependabot/config.yml +9 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_dnsimple.yml +136 -45
  5. data/.travis.yml +13 -9
  6. data/CHANGELOG.md +57 -23
  7. data/CONTRIBUTING.md +55 -7
  8. data/Gemfile +4 -1
  9. data/LICENSE.txt +1 -1
  10. data/README.md +8 -6
  11. data/dnsimple.gemspec +3 -3
  12. data/lib/dnsimple.rb +2 -0
  13. data/lib/dnsimple/client.rb +12 -10
  14. data/lib/dnsimple/client/accounts.rb +2 -1
  15. data/lib/dnsimple/client/certificates.rb +188 -28
  16. data/lib/dnsimple/client/clients.rb +6 -2
  17. data/lib/dnsimple/client/contacts.rb +2 -5
  18. data/lib/dnsimple/client/domains.rb +3 -5
  19. data/lib/dnsimple/client/{collaborators.rb → domains_collaborators.rb} +3 -1
  20. data/lib/dnsimple/client/domains_delegation_signer_records.rb +2 -0
  21. data/lib/dnsimple/client/domains_dnssec.rb +2 -0
  22. data/lib/dnsimple/client/domains_email_forwards.rb +2 -0
  23. data/lib/dnsimple/client/domains_pushes.rb +2 -0
  24. data/lib/dnsimple/client/identity.rb +2 -0
  25. data/lib/dnsimple/client/oauth.rb +2 -0
  26. data/lib/dnsimple/client/registrar.rb +51 -5
  27. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
  28. data/lib/dnsimple/client/registrar_delegation.rb +6 -4
  29. data/lib/dnsimple/client/registrar_whois_privacy.rb +23 -1
  30. data/lib/dnsimple/client/services.rb +2 -2
  31. data/lib/dnsimple/client/services_domains.rb +2 -0
  32. data/lib/dnsimple/client/templates.rb +2 -0
  33. data/lib/dnsimple/client/templates_domains.rb +2 -0
  34. data/lib/dnsimple/client/templates_records.rb +2 -0
  35. data/lib/dnsimple/client/tlds.rb +16 -17
  36. data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
  37. data/lib/dnsimple/client/webhooks.rb +2 -3
  38. data/lib/dnsimple/client/zones.rb +2 -1
  39. data/lib/dnsimple/client/zones_distributions.rb +49 -0
  40. data/lib/dnsimple/client/zones_records.rb +25 -28
  41. data/lib/dnsimple/default.rb +11 -9
  42. data/lib/dnsimple/error.rb +2 -0
  43. data/lib/dnsimple/extra.rb +2 -0
  44. data/lib/dnsimple/options.rb +2 -0
  45. data/lib/dnsimple/response.rb +6 -4
  46. data/lib/dnsimple/struct.rb +7 -0
  47. data/lib/dnsimple/struct/account.rb +2 -0
  48. data/lib/dnsimple/struct/certificate.rb +11 -0
  49. data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
  50. data/lib/dnsimple/struct/certificate_purchase.rb +27 -0
  51. data/lib/dnsimple/struct/certificate_renewal.rb +30 -0
  52. data/lib/dnsimple/struct/collaborator.rb +2 -0
  53. data/lib/dnsimple/struct/contact.rb +2 -0
  54. data/lib/dnsimple/struct/delegation_signer_record.rb +2 -0
  55. data/lib/dnsimple/struct/dnssec.rb +2 -0
  56. data/lib/dnsimple/struct/domain.rb +24 -3
  57. data/lib/dnsimple/struct/domain_check.rb +2 -0
  58. data/lib/dnsimple/struct/domain_premium_price.rb +2 -0
  59. data/lib/dnsimple/struct/domain_push.rb +2 -0
  60. data/lib/dnsimple/struct/domain_registration.rb +2 -3
  61. data/lib/dnsimple/struct/domain_renewal.rb +2 -3
  62. data/lib/dnsimple/struct/domain_transfer.rb +4 -2
  63. data/lib/dnsimple/struct/email_forward.rb +2 -0
  64. data/lib/dnsimple/struct/extended_attribute.rb +3 -1
  65. data/lib/dnsimple/struct/oauth_token.rb +2 -0
  66. data/lib/dnsimple/struct/service.rb +3 -1
  67. data/lib/dnsimple/struct/template.rb +2 -0
  68. data/lib/dnsimple/struct/template_record.rb +2 -0
  69. data/lib/dnsimple/struct/tld.rb +2 -0
  70. data/lib/dnsimple/struct/user.rb +2 -0
  71. data/lib/dnsimple/struct/vanity_name_server.rb +27 -0
  72. data/lib/dnsimple/struct/webhook.rb +2 -0
  73. data/lib/dnsimple/struct/whoami.rb +4 -2
  74. data/lib/dnsimple/struct/whois_privacy.rb +2 -0
  75. data/lib/dnsimple/struct/whois_privacy_renewal.rb +30 -0
  76. data/lib/dnsimple/struct/zone.rb +2 -0
  77. data/lib/dnsimple/struct/zone_distribution.rb +13 -0
  78. data/lib/dnsimple/struct/zone_file.rb +2 -0
  79. data/lib/dnsimple/struct/zone_record.rb +2 -0
  80. data/lib/dnsimple/version.rb +3 -1
  81. data/spec/dnsimple/client/accounts_spec.rb +2 -0
  82. data/spec/dnsimple/client/certificates_spec.rb +227 -1
  83. data/spec/dnsimple/client/client_service_spec.rb +2 -0
  84. data/spec/dnsimple/client/contacts_spec.rb +3 -1
  85. data/spec/dnsimple/client/{collaborators_spec.rb → domains_collaborators_spec.rb} +3 -1
  86. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
  87. data/spec/dnsimple/client/domains_dnssec_spec.rb +4 -2
  88. data/spec/dnsimple/client/domains_email_forwards_spec.rb +3 -1
  89. data/spec/dnsimple/client/domains_pushes_spec.rb +3 -1
  90. data/spec/dnsimple/client/domains_spec.rb +19 -16
  91. data/spec/dnsimple/client/identity_spec.rb +2 -0
  92. data/spec/dnsimple/client/oauth_spec.rb +2 -0
  93. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +2 -0
  94. data/spec/dnsimple/client/registrar_delegation_spec.rb +5 -2
  95. data/spec/dnsimple/client/registrar_spec.rb +73 -4
  96. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +60 -3
  97. data/spec/dnsimple/client/services_domains_spec.rb +2 -0
  98. data/spec/dnsimple/client/services_spec.rb +3 -1
  99. data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
  100. data/spec/dnsimple/client/templates_records_spec.rb +2 -0
  101. data/spec/dnsimple/client/templates_spec.rb +2 -0
  102. data/spec/dnsimple/client/tlds_spec.rb +22 -19
  103. data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
  104. data/spec/dnsimple/client/webhooks_spec.rb +2 -0
  105. data/spec/dnsimple/client/zones_distributions_spec.rb +137 -0
  106. data/spec/dnsimple/client/zones_records_spec.rb +37 -35
  107. data/spec/dnsimple/client/zones_spec.rb +4 -2
  108. data/spec/dnsimple/client_spec.rb +8 -6
  109. data/spec/dnsimple/extra_spec.rb +2 -0
  110. data/spec/dnsimple/options/base_spec.rb +2 -0
  111. data/spec/dnsimple/options/list_options_spec.rb +2 -0
  112. data/spec/fixtures.http/{transferDomainOut → authorizeDomainTransferOut}/success.http +0 -0
  113. data/spec/fixtures.http/cancelDomainTransfer/success.http +19 -0
  114. data/spec/fixtures.http/checkZoneDistribution/error.http +21 -0
  115. data/spec/fixtures.http/checkZoneDistribution/failure.http +21 -0
  116. data/spec/fixtures.http/checkZoneDistribution/success.http +21 -0
  117. data/spec/fixtures.http/checkZoneRecordDistribution/error.http +21 -0
  118. data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +21 -0
  119. data/spec/fixtures.http/checkZoneRecordDistribution/success.http +21 -0
  120. data/spec/fixtures.http/createDomain/created.http +21 -16
  121. data/spec/fixtures.http/getCertificate/success.http +1 -1
  122. data/spec/fixtures.http/getDomain/success.http +14 -9
  123. data/spec/fixtures.http/getDomainTransfer/success.http +21 -0
  124. data/spec/fixtures.http/issueLetsencryptCertificate/success.http +21 -0
  125. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +21 -0
  126. data/spec/fixtures.http/listCertificates/success.http +1 -1
  127. data/spec/fixtures.http/listDomains/success.http +21 -16
  128. data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +21 -0
  129. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +21 -0
  130. data/spec/fixtures.http/registerDomain/success.http +2 -2
  131. data/spec/fixtures.http/renewDomain/success.http +2 -2
  132. data/spec/fixtures.http/renewWhoisPrivacy/success.http +21 -0
  133. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +19 -0
  134. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +19 -0
  135. data/spec/fixtures.http/transferDomain/success.http +2 -2
  136. data/spec/fixtures.http/whoami/success-account.http +1 -1
  137. data/spec/fixtures.http/whoami/success-user.http +1 -1
  138. data/spec/fixtures.http/whoami/success.http +1 -1
  139. data/spec/spec_helper.rb +4 -2
  140. data/spec/support/helpers.rb +2 -0
  141. data/spec/support/webmock.rb +2 -0
  142. metadata +50 -19
  143. data/.ruby-gemset +0 -1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client::ClientService do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".contacts" do
@@ -54,7 +56,7 @@ describe Dnsimple::Client, ".contacts" do
54
56
  it "exposes the pagination information" do
55
57
  response = subject.contacts(account_id)
56
58
 
57
- expect(response.respond_to?(:page)).to be_truthy
59
+ expect(response.respond_to?(:page)).to be(true)
58
60
  expect(response.page).to eq(1)
59
61
  expect(response.per_page).to be_a(Integer)
60
62
  expect(response.total_entries).to be_a(Integer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -49,7 +51,7 @@ describe Dnsimple::Client, ".domains" do
49
51
  it "exposes the pagination information" do
50
52
  response = subject.collaborators(account_id, domain_id)
51
53
 
52
- expect(response.respond_to?(:page)).to be_truthy
54
+ expect(response.respond_to?(:page)).to be(true)
53
55
  expect(response.page).to eq(1)
54
56
  expect(response.per_page).to be_a(Integer)
55
57
  expect(response.total_entries).to be_a(Integer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -55,7 +57,7 @@ describe Dnsimple::Client, ".domains" do
55
57
  it "exposes the pagination information" do
56
58
  response = subject.delegation_signer_records(account_id, domain_id)
57
59
 
58
- expect(response.respond_to?(:page)).to be_truthy
60
+ expect(response.respond_to?(:page)).to be(true)
59
61
  expect(response.page).to eq(1)
60
62
  expect(response.per_page).to be_a(Integer)
61
63
  expect(response.total_entries).to be_a(Integer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -27,7 +29,7 @@ describe Dnsimple::Client, ".domains" do
27
29
 
28
30
  result = response.data
29
31
  expect(result).to be_a(Dnsimple::Struct::Dnssec)
30
- expect(result.enabled).to be_truthy
32
+ expect(result.enabled).to be(true)
31
33
  end
32
34
 
33
35
  context "when the domain does not exist" do
@@ -103,7 +105,7 @@ describe Dnsimple::Client, ".domains" do
103
105
 
104
106
  result = response.data
105
107
  expect(result).to be_a(Dnsimple::Struct::Dnssec)
106
- expect(result.enabled).to be_truthy
108
+ expect(result.enabled).to be(true)
107
109
  end
108
110
 
109
111
  context "when the domain does not exist" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -55,7 +57,7 @@ describe Dnsimple::Client, ".domains" do
55
57
  it "exposes the pagination information" do
56
58
  response = subject.email_forwards(account_id, domain_id)
57
59
 
58
- expect(response.respond_to?(:page)).to be_truthy
60
+ expect(response.respond_to?(:page)).to be(true)
59
61
  expect(response.page).to eq(1)
60
62
  expect(response.per_page).to be_a(Integer)
61
63
  expect(response.total_entries).to be_a(Integer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -76,7 +78,7 @@ describe Dnsimple::Client, ".domains" do
76
78
  it "exposes the pagination information" do
77
79
  response = subject.pushes(account_id)
78
80
 
79
- expect(response.respond_to?(:page)).to be_truthy
81
+ expect(response.respond_to?(:page)).to be(true)
80
82
  expect(response.page).to eq(1)
81
83
  expect(response.per_page).to be_a(Integer)
82
84
  expect(response.total_entries).to be_a(Integer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -33,9 +35,9 @@ describe Dnsimple::Client, ".domains" do
33
35
  end
34
36
 
35
37
  it "supports sorting" do
36
- subject.domains(account_id, sort: "expires_on:asc")
38
+ subject.domains(account_id, sort: "expiration:asc")
37
39
 
38
- 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")
39
41
  end
40
42
 
41
43
  it "supports filtering" do
@@ -60,7 +62,7 @@ describe Dnsimple::Client, ".domains" do
60
62
  it "exposes the pagination information" do
61
63
  response = subject.domains(account_id)
62
64
 
63
- expect(response.respond_to?(:page)).to be_truthy
65
+ expect(response.respond_to?(:page)).to be(true)
64
66
  expect(response.page).to eq(1)
65
67
  expect(response.per_page).to be_a(Integer)
66
68
  expect(response.total_entries).to be_a(Integer)
@@ -82,9 +84,9 @@ describe Dnsimple::Client, ".domains" do
82
84
  end
83
85
 
84
86
  it "supports sorting" do
85
- subject.all_domains(account_id, sort: "expires_on:asc")
87
+ subject.all_domains(account_id, sort: "expiration:asc")
86
88
 
87
- 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")
88
90
  end
89
91
 
90
92
  it "supports filtering" do
@@ -131,28 +133,29 @@ describe Dnsimple::Client, ".domains" do
131
133
  end
132
134
 
133
135
  it "builds the correct request" do
134
- subject.domain(account_id, domain = "example.com")
136
+ subject.domain(account_id, domain = "example-alpha.com")
135
137
 
136
138
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain}")
137
139
  .with(headers: { 'Accept' => 'application/json' })
138
140
  end
139
141
 
140
142
  it "returns the domain" do
141
- response = subject.domain(account_id, "example.com")
143
+ response = subject.domain(account_id, "example-alpha.com")
142
144
  expect(response).to be_a(Dnsimple::Response)
143
145
 
144
146
  result = response.data
145
147
  expect(result).to be_a(Dnsimple::Struct::Domain)
146
- expect(result.id).to eq(1)
147
- expect(result.account_id).to eq(1010)
148
- 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)
149
151
  expect(result.name).to eq("example-alpha.com")
150
- expect(result.state).to eq("hosted")
151
- expect(result.auto_renew).to eq(false)
152
- expect(result.private_whois).to eq(false)
153
- expect(result.expires_on).to eq(nil)
154
- expect(result.created_at).to eq("2014-12-06T15:56:55Z")
155
- expect(result.updated_at).to eq("2015-12-09T00:20:56Z")
152
+ expect(result.state).to eq("registered")
153
+ expect(result.auto_renew).to be(false)
154
+ expect(result.private_whois).to be(false)
155
+ expect(result.expires_at).to eq("2021-06-05T02:15:00Z")
156
+ expect(result.expires_on).to eq("2021-06-05")
157
+ expect(result.created_at).to eq("2020-06-04T19:15:14Z")
158
+ expect(result.updated_at).to eq("2020-06-04T19:15:21Z")
156
159
  end
157
160
 
158
161
  context "when the domain does not exist" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".identity" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".oauth" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -75,8 +77,9 @@ describe Dnsimple::Client, ".registrar" do
75
77
  response = subject.change_domain_delegation_to_vanity(account_id, "example.com", attributes)
76
78
  expect(response).to be_a(Dnsimple::Response)
77
79
 
78
- vanity_name_servers = response.data.map { |ns| ns["name"] }
79
- expect(vanity_name_servers).to match_array(%w(ns1.example.com ns2.example.com))
80
+ vanity_name_server = response.data.first
81
+ expect(vanity_name_server).to be_a(Dnsimple::Struct::VanityNameServer)
82
+ expect(vanity_name_server.name).to eq("ns1.example.com")
80
83
  end
81
84
  end
82
85
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -27,8 +29,8 @@ describe Dnsimple::Client, ".registrar" do
27
29
  result = response.data
28
30
  expect(result).to be_a(Dnsimple::Struct::DomainCheck)
29
31
  expect(result.domain).to eq("ruby.codes")
30
- expect(result.available).to be_truthy
31
- expect(result.premium).to be_truthy
32
+ expect(result.available).to be(true)
33
+ expect(result.premium).to be(true)
32
34
  end
33
35
  end
34
36
 
@@ -37,7 +39,7 @@ describe Dnsimple::Client, ".registrar" do
37
39
 
38
40
  context "when premium price" do
39
41
  before do
40
- 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]*})
41
43
  .to_return(read_http_fixture("getDomainPremiumPrice/success.http"))
42
44
  end
43
45
 
@@ -212,12 +214,79 @@ describe Dnsimple::Client, ".registrar" do
212
214
  end
213
215
  end
214
216
 
217
+ describe "#get_transfer_domain" do
218
+ let(:account_id) { 1010 }
219
+
220
+ before do
221
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/transfers/.+$})
222
+ .to_return(read_http_fixture("getDomainTransfer/success.http"))
223
+ end
224
+
225
+ it "builds the correct request" do
226
+ subject.get_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
227
+
228
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
229
+ .with(headers: { "Accept" => "application/json" })
230
+ end
231
+
232
+ it "returns the domain transfer" do
233
+ response = subject.get_domain_transfer(account_id, "example.com", 361)
234
+ expect(response).to be_a(Dnsimple::Response)
235
+
236
+ result = response.data
237
+ expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
238
+ expect(result.id).to eq(361)
239
+ expect(result.domain_id).to eq(182245)
240
+ expect(result.registrant_id).to eq(2715)
241
+ expect(result.state).to eq("cancelled")
242
+ expect(result.auto_renew).to be(false)
243
+ expect(result.whois_privacy).to be(false)
244
+ expect(result.status_description).to eq("Canceled by customer")
245
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
246
+ expect(result.updated_at).to eq("2020-06-05T18:10:01Z")
247
+ end
248
+ end
249
+
250
+ describe "#cancel_domain_transfer" do
251
+ let(:account_id) { 1010 }
252
+
253
+ before do
254
+ stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/.+/transfers/.+$})
255
+ .to_return(read_http_fixture("cancelDomainTransfer/success.http"))
256
+ end
257
+
258
+ it "builds the correct request" do
259
+ subject.cancel_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
260
+
261
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
262
+ .with(headers: { "Accept" => "application/json" })
263
+ end
264
+
265
+ it "returns the domain transfer" do
266
+ response = subject.cancel_domain_transfer(account_id, "example.com", 361)
267
+ expect(response).to be_a(Dnsimple::Response)
268
+
269
+ result = response.data
270
+ expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
271
+ expect(result.id).to eq(361)
272
+ expect(result.domain_id).to eq(182245)
273
+ expect(result.registrant_id).to eq(2715)
274
+ expect(result.state).to eq("transferring")
275
+ expect(result.auto_renew).to be(false)
276
+ expect(result.whois_privacy).to be(false)
277
+ expect(result.status_description).to eq(nil)
278
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
279
+ expect(result.updated_at).to eq("2020-06-05T18:08:04Z")
280
+ end
281
+ end
282
+
283
+
215
284
  describe "#transfer_domain_out" do
216
285
  let(:account_id) { 1010 }
217
286
 
218
287
  before do
219
288
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/authorize_transfer_out$})
220
- .to_return(read_http_fixture("transferDomainOut/success.http"))
289
+ .to_return(read_http_fixture("authorizeDomainTransferOut/success.http"))
221
290
  end
222
291
 
223
292
  it "builds the correct request" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -27,7 +29,7 @@ describe Dnsimple::Client, ".registrar" do
27
29
  result = response.data
28
30
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
29
31
  expect(result.domain_id).to be_kind_of(Integer)
30
- expect(result.enabled).to be_truthy
32
+ expect(result.enabled).to be(true)
31
33
  expect(result.expires_on).to be_kind_of(String)
32
34
  end
33
35
  end
@@ -56,7 +58,7 @@ describe Dnsimple::Client, ".registrar" do
56
58
  result = response.data
57
59
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
58
60
  expect(result.domain_id).to be_kind_of(Integer)
59
- expect(result.enabled).to be_truthy
61
+ expect(result.enabled).to be(true)
60
62
  expect(result.expires_on).to be_kind_of(String)
61
63
  end
62
64
  end
@@ -111,9 +113,64 @@ describe Dnsimple::Client, ".registrar" do
111
113
  result = response.data
112
114
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
113
115
  expect(result.domain_id).to be_kind_of(Integer)
114
- expect(result.enabled).to be_falsey
116
+ expect(result.enabled).to be(false)
117
+ expect(result.expires_on).to be_kind_of(String)
118
+ end
119
+ end
120
+
121
+
122
+ describe "#renew_whois_privacy" do
123
+ let(:account_id) { 1010 }
124
+
125
+ before do
126
+ stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
127
+ .to_return(read_http_fixture("renewWhoisPrivacy/success.http"))
128
+ end
129
+
130
+ it "builds the correct request" do
131
+ subject.renew_whois_privacy(account_id, domain_name = "example.com")
132
+
133
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy/renewals")
134
+ .with(headers: { "Accept" => "application/json" })
135
+ end
136
+
137
+ it "returns the whois privacy order" do
138
+ response = subject.renew_whois_privacy(account_id, "example.com")
139
+ expect(response).to be_a(Dnsimple::Response)
140
+
141
+ result = response.data
142
+ expect(result).to be_a(Dnsimple::Struct::WhoisPrivacyRenewal)
143
+ expect(result.domain_id).to be_kind_of(Integer)
144
+ expect(result.whois_privacy_id).to be_kind_of(Integer)
145
+ expect(result.enabled).to be(true)
115
146
  expect(result.expires_on).to be_kind_of(String)
116
147
  end
148
+
149
+ context "when whois privacy was't previously purchased" do
150
+ before do
151
+ stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
152
+ .to_return(read_http_fixture("renewWhoisPrivacy/whois-privacy-not-found.http"))
153
+ end
154
+
155
+ it "raises error" do
156
+ expect do
157
+ subject.renew_whois_privacy(account_id, "example.com")
158
+ end.to raise_error(Dnsimple::RequestError, "WHOIS privacy not found for example.com")
159
+ end
160
+ end
161
+
162
+ context "when there is already a whois privacy renewal order in progress" do
163
+ before do
164
+ stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
165
+ .to_return(read_http_fixture("renewWhoisPrivacy/whois-privacy-duplicated-order.http"))
166
+ end
167
+
168
+ it "raises error" do
169
+ expect do
170
+ subject.renew_whois_privacy(account_id, "example.com")
171
+ end.to raise_error(Dnsimple::RequestError, "The whois privacy for example.com has just been renewed, a new renewal cannot be started at this time")
172
+ end
173
+ end
117
174
  end
118
175
 
119
176
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".services" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".services" do
@@ -98,7 +100,7 @@ describe Dnsimple::Client, ".services" do
98
100
  expect(service.sid).to eq("service1")
99
101
  expect(service.description).to eq("First service example.")
100
102
  expect(service.setup_description).to be_nil
101
- expect(service.requires_setup).to eq(true)
103
+ expect(service.requires_setup).to be(true)
102
104
  expect(service.default_subdomain).to be_nil
103
105
 
104
106
  settings = service.settings
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".templates" do