dnsimple 10.0.0 → 11.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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +5 -7
  3. data/.github/workflows/ci.yml +3 -3
  4. data/.github/workflows/release.yml +2 -2
  5. data/.github/workflows/sync-test-fixtures.yml +55 -0
  6. data/.markdownlint.yaml +15 -1
  7. data/.rubocop.yml +1 -1
  8. data/.rubocop_dnsimple.yml +15 -31
  9. data/CHANGELOG.md +9 -0
  10. data/Gemfile +7 -7
  11. data/lib/dnsimple/client/clients.rb +29 -31
  12. data/lib/dnsimple/client/domains_email_forwards.rb +1 -1
  13. data/lib/dnsimple/client/zones_records.rb +33 -0
  14. data/lib/dnsimple/client.rb +5 -5
  15. data/lib/dnsimple/default.rb +7 -7
  16. data/lib/dnsimple/response.rb +3 -3
  17. data/lib/dnsimple/struct/charge.rb +1 -1
  18. data/lib/dnsimple/struct/email_forward.rb +0 -8
  19. data/lib/dnsimple/struct/zone_record_id.rb +12 -0
  20. data/lib/dnsimple/struct/zone_records_batch_change.rb +18 -0
  21. data/lib/dnsimple/struct.rb +42 -40
  22. data/lib/dnsimple/version.rb +1 -1
  23. data/lib/dnsimple.rb +5 -5
  24. data/spec/dnsimple/client/accounts_spec.rb +2 -2
  25. data/spec/dnsimple/client/billing_spec.rb +3 -3
  26. data/spec/dnsimple/client/certificates_spec.rb +11 -11
  27. data/spec/dnsimple/client/client_service_spec.rb +1 -1
  28. data/spec/dnsimple/client/contacts_spec.rb +6 -6
  29. data/spec/dnsimple/client/dns_analytics_spec.rb +9 -9
  30. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +7 -7
  31. data/spec/dnsimple/client/domains_dnssec_spec.rb +4 -4
  32. data/spec/dnsimple/client/domains_email_forwards_spec.rb +8 -15
  33. data/spec/dnsimple/client/domains_pushes_spec.rb +5 -5
  34. data/spec/dnsimple/client/domains_spec.rb +6 -6
  35. data/spec/dnsimple/client/identity_spec.rb +2 -2
  36. data/spec/dnsimple/client/oauth_spec.rb +3 -3
  37. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +3 -3
  38. data/spec/dnsimple/client/registrar_delegation_spec.rb +1 -1
  39. data/spec/dnsimple/client/registrar_spec.rb +1 -1
  40. data/spec/dnsimple/client/registrar_transfer_lock_spec.rb +4 -4
  41. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +1 -1
  42. data/spec/dnsimple/client/services_domains_spec.rb +4 -4
  43. data/spec/dnsimple/client/services_spec.rb +1 -1
  44. data/spec/dnsimple/client/templates_domains_spec.rb +2 -2
  45. data/spec/dnsimple/client/templates_records_spec.rb +4 -4
  46. data/spec/dnsimple/client/templates_spec.rb +2 -2
  47. data/spec/dnsimple/client/tlds_spec.rb +5 -5
  48. data/spec/dnsimple/client/vanity_name_servers_spec.rb +1 -1
  49. data/spec/dnsimple/client/webhooks_spec.rb +5 -5
  50. data/spec/dnsimple/client/zones_distributions_spec.rb +3 -3
  51. data/spec/dnsimple/client/zones_records_spec.rb +102 -7
  52. data/spec/dnsimple/client/zones_spec.rb +6 -6
  53. data/spec/dnsimple/client_spec.rb +10 -10
  54. data/spec/dnsimple/extra_spec.rb +1 -1
  55. data/spec/dnsimple/options/base_spec.rb +5 -5
  56. data/spec/dnsimple/options/list_options_spec.rb +21 -21
  57. data/spec/fixtures.http/accounts/success-user.http +2 -1
  58. data/spec/fixtures.http/batchChangeZoneRecords/error_400_create_validation_failed.http +16 -0
  59. data/spec/fixtures.http/batchChangeZoneRecords/error_400_delete_validation_failed.http +15 -0
  60. data/spec/fixtures.http/batchChangeZoneRecords/error_400_update_validation_failed.http +15 -0
  61. data/spec/fixtures.http/batchChangeZoneRecords/success.http +16 -0
  62. data/spec/fixtures.http/checkRegistrantChange/error-contactnotfound.http +4 -4
  63. data/spec/fixtures.http/checkRegistrantChange/error-domainnotfound.http +4 -4
  64. data/spec/fixtures.http/checkRegistrantChange/success.http +5 -5
  65. data/spec/fixtures.http/createContact/error-validation-errors.http +18 -0
  66. data/spec/fixtures.http/createEmailForward/created.http +1 -2
  67. data/spec/fixtures.http/createRegistrantChange/success.http +5 -5
  68. data/spec/fixtures.http/createWebhook/created.http +16 -16
  69. data/spec/fixtures.http/deleteRegistrantChange/success.http +4 -4
  70. data/spec/fixtures.http/deleteRegistrantChange/success_async.http +14 -0
  71. data/spec/fixtures.http/dnsAnalytics/success.http +1 -1
  72. data/spec/fixtures.http/getDomainPrices/failure.http +18 -18
  73. data/spec/fixtures.http/getDomainPrices/success.http +21 -21
  74. data/spec/fixtures.http/getDomainRestore/success.http +15 -13
  75. data/spec/fixtures.http/getEmailForward/success.http +1 -2
  76. data/spec/fixtures.http/getRegistrantChange/success.http +5 -5
  77. data/spec/fixtures.http/getTld/success.http +1 -1
  78. data/spec/fixtures.http/getWebhook/success.http +16 -16
  79. data/spec/fixtures.http/listAccounts/success-user.http +1 -1
  80. data/spec/fixtures.http/listCharges/fail-400-bad-filter.http +0 -2
  81. data/spec/fixtures.http/listCharges/fail-403.http +0 -2
  82. data/spec/fixtures.http/listCharges/success.http +0 -2
  83. data/spec/fixtures.http/listEmailForwards/success.http +1 -1
  84. data/spec/fixtures.http/listRegistrantChanges/success.http +5 -5
  85. data/spec/fixtures.http/listTlds/success.http +1 -1
  86. data/spec/fixtures.http/listWebhooks/success.http +16 -16
  87. data/spec/fixtures.http/registerDomain/error-extended-attributes.http +18 -0
  88. data/spec/fixtures.http/restoreDomain/success.http +14 -12
  89. data/spec/fixtures.http/updateZoneNsRecords/success.http +16 -0
  90. data/spec/fixtures.http/whoami/success-account.http +1 -1
  91. data/spec/fixtures.http/whoami/success.http +1 -1
  92. data/spec/spec_helper.rb +4 -4
  93. data/spec/support/webmock.rb +1 -1
  94. metadata +14 -12
  95. data/.github/CODEOWNERS +0 -1
  96. data/.github/workflows/auto-merge.yml +0 -32
  97. data/lib/dnsimple/client/domains_collaborators.rb +0 -87
  98. data/spec/dnsimple/client/domains_collaborators_spec.rb +0 -164
  99. data/spec/fixtures.http/addCollaborator/invite-success.http +0 -20
  100. data/spec/fixtures.http/addCollaborator/success.http +0 -20
  101. data/spec/fixtures.http/listCollaborators/success.http +0 -20
  102. data/spec/fixtures.http/notfound-collaborator.http +0 -15
  103. data/spec/fixtures.http/removeCollaborator/success.http +0 -17
  104. /data/spec/fixtures.http/{notfound-delegationsignerrecord.http → notfound-delegationSignerRecord.http} +0 -0
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".identity" do
6
6
 
@@ -17,7 +17,7 @@ describe Dnsimple::Client, ".identity" do
17
17
  subject.whoami
18
18
 
19
19
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/whoami")
20
- .with(headers: { 'Accept' => 'application/json' })
20
+ .with(headers: { "Accept" => "application/json" })
21
21
  end
22
22
 
23
23
  it "returns the whoami" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".oauth" do
6
6
 
@@ -23,7 +23,7 @@ describe Dnsimple::Client, ".oauth" do
23
23
 
24
24
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/oauth/access_token")
25
25
  .with(body: { client_id: client_id, client_secret: client_secret, code: code, state: state, grant_type: "authorization_code" })
26
- .with(headers: { 'Accept' => 'application/json' })
26
+ .with(headers: { "Accept" => "application/json" })
27
27
  end
28
28
 
29
29
  it "returns oauth token" do
@@ -43,7 +43,7 @@ describe Dnsimple::Client, ".oauth" do
43
43
 
44
44
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/oauth/access_token")
45
45
  .with(body: { client_id: client_id, client_secret: client_secret, code: code, state: state, redirect_uri: redirect_uri, grant_type: "authorization_code" })
46
- .with(headers: { 'Accept' => 'application/json' })
46
+ .with(headers: { "Accept" => "application/json" })
47
47
  end
48
48
  end
49
49
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
6
 
@@ -20,7 +20,7 @@ describe Dnsimple::Client, ".registrar" do
20
20
  subject.enable_auto_renewal(account_id, domain_id)
21
21
 
22
22
  expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_id}/auto_renewal")
23
- .with(headers: { 'Accept' => 'application/json' })
23
+ .with(headers: { "Accept" => "application/json" })
24
24
  end
25
25
 
26
26
  it "returns nothing" do
@@ -57,7 +57,7 @@ describe Dnsimple::Client, ".registrar" do
57
57
  subject.disable_auto_renewal(account_id, domain_id)
58
58
 
59
59
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_id}/auto_renewal")
60
- .with(headers: { 'Accept' => 'application/json' })
60
+ .with(headers: { "Accept" => "application/json" })
61
61
  end
62
62
 
63
63
  it "returns nothing" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").registrar }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").registrar }
@@ -18,7 +18,7 @@ describe Dnsimple::Client, ".registrar" do
18
18
  subject.get_domain_transfer_lock(account_id, domain_id)
19
19
 
20
20
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_id}/transfer_lock")
21
- .with(headers: { 'Accept' => 'application/json' })
21
+ .with(headers: { "Accept" => "application/json" })
22
22
  end
23
23
 
24
24
  it "returns the transfer lock state" do
@@ -55,7 +55,7 @@ describe Dnsimple::Client, ".registrar" do
55
55
  subject.enable_domain_transfer_lock(account_id, domain_id)
56
56
 
57
57
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_id}/transfer_lock")
58
- .with(headers: { 'Accept' => 'application/json' })
58
+ .with(headers: { "Accept" => "application/json" })
59
59
  end
60
60
 
61
61
  it "returns the transfer lock state" do
@@ -92,7 +92,7 @@ describe Dnsimple::Client, ".registrar" do
92
92
  subject.disable_domain_transfer_lock(account_id, domain_id)
93
93
 
94
94
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_id}/transfer_lock")
95
- .with(headers: { 'Accept' => 'application/json' })
95
+ .with(headers: { "Accept" => "application/json" })
96
96
  end
97
97
 
98
98
  it "returns the transfer lock state" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".services" do
6
6
 
@@ -9,7 +9,7 @@ describe Dnsimple::Client, ".services" do
9
9
 
10
10
  describe "#applied_services" do
11
11
  let(:account_id) { 1010 }
12
- let(:domain_id) { 'example.com' }
12
+ let(:domain_id) { "example.com" }
13
13
 
14
14
  before do
15
15
  stub_request(:get, %r{/v2/#{account_id}/domains/#{domain_id}/services})
@@ -74,7 +74,7 @@ describe Dnsimple::Client, ".services" do
74
74
 
75
75
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}")
76
76
  .with(body: settings)
77
- .with(headers: { 'Accept' => 'application/json' })
77
+ .with(headers: { "Accept" => "application/json" })
78
78
  end
79
79
 
80
80
  it "returns empty response" do
@@ -100,7 +100,7 @@ describe Dnsimple::Client, ".services" do
100
100
  subject.unapply_service(account_id, service_id, domain_id)
101
101
 
102
102
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}")
103
- .with(headers: { 'Accept' => 'application/json' })
103
+ .with(headers: { "Accept" => "application/json" })
104
104
  end
105
105
 
106
106
  it "returns empty response" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".services" do
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".templates" do
6
6
 
@@ -10,7 +10,7 @@ describe Dnsimple::Client, ".templates" do
10
10
  describe "#apply_template" do
11
11
  let(:account_id) { 1010 }
12
12
  let(:template_id) { 5410 }
13
- let(:domain_id) { 'example.com' }
13
+ let(:domain_id) { "example.com" }
14
14
 
15
15
  before do
16
16
  stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}$})
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".templates" do
6
6
 
@@ -92,7 +92,7 @@ describe Dnsimple::Client, ".templates" do
92
92
 
93
93
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}/records")
94
94
  .with(body: attributes)
95
- .with(headers: { 'Accept' => 'application/json' })
95
+ .with(headers: { "Accept" => "application/json" })
96
96
  end
97
97
 
98
98
  it "returns the record" do
@@ -157,7 +157,7 @@ describe Dnsimple::Client, ".templates" do
157
157
  subject.record(account_id, template_id, record_id = 301)
158
158
 
159
159
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}/records/#{record_id}")
160
- .with(headers: { 'Accept' => 'application/json' })
160
+ .with(headers: { "Accept" => "application/json" })
161
161
  end
162
162
 
163
163
  it "returns the record" do
@@ -191,7 +191,7 @@ describe Dnsimple::Client, ".templates" do
191
191
  subject.delete_record(account_id, template_id, record_id = 301)
192
192
 
193
193
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}/records/#{record_id}")
194
- .with(headers: { 'Accept' => 'application/json' })
194
+ .with(headers: { "Accept" => "application/json" })
195
195
  end
196
196
 
197
197
  it "returns nothing" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".templates" do
6
6
 
@@ -194,7 +194,7 @@ describe Dnsimple::Client, ".templates" do
194
194
  describe "#apply_template" do
195
195
  let(:account_id) { 1010 }
196
196
  let(:template_id) { 5410 }
197
- let(:domain_id) { 'example.com' }
197
+ let(:domain_id) { "example.com" }
198
198
 
199
199
  before do
200
200
  stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}$})
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".tlds" do
6
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").tlds }
@@ -15,7 +15,7 @@ describe Dnsimple::Client, ".tlds" do
15
15
  subject.list_tlds
16
16
 
17
17
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds")
18
- .with(headers: { 'Accept' => 'application/json' })
18
+ .with(headers: { "Accept" => "application/json" })
19
19
  end
20
20
 
21
21
  it "supports pagination" do
@@ -89,7 +89,7 @@ describe Dnsimple::Client, ".tlds" do
89
89
  subject.tld(tld = "com")
90
90
 
91
91
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}")
92
- .with(headers: { 'Accept' => 'application/json' })
92
+ .with(headers: { "Accept" => "application/json" })
93
93
  end
94
94
 
95
95
  it "returns the tld" do
@@ -98,7 +98,7 @@ describe Dnsimple::Client, ".tlds" do
98
98
 
99
99
  result = response.data
100
100
  expect(result).to be_a(Dnsimple::Struct::Tld)
101
- expect(result.tld).to eq('com')
101
+ expect(result.tld).to eq("com")
102
102
  expect(result.tld_type).to eq(1)
103
103
  expect(result.whois_privacy).to be(true)
104
104
  expect(result.auto_renew_only).to be(false)
@@ -121,7 +121,7 @@ describe Dnsimple::Client, ".tlds" do
121
121
  subject.tld_extended_attributes(tld = "uk")
122
122
 
123
123
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}/extended_attributes")
124
- .with(headers: { 'Accept' => 'application/json' })
124
+ .with(headers: { "Accept" => "application/json" })
125
125
  end
126
126
 
127
127
  it "returns the extended attributes" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".vanity_name_servers" do
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".webhooks" do
6
6
 
@@ -18,7 +18,7 @@ describe Dnsimple::Client, ".webhooks" do
18
18
  subject.webhooks(account_id)
19
19
 
20
20
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks")
21
- .with(headers: { 'Accept' => 'application/json' })
21
+ .with(headers: { "Accept" => "application/json" })
22
22
  end
23
23
 
24
24
  it "supports extra request options" do
@@ -62,7 +62,7 @@ describe Dnsimple::Client, ".webhooks" do
62
62
 
63
63
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/webhooks")
64
64
  .with(body: attributes)
65
- .with(headers: { 'Accept' => 'application/json' })
65
+ .with(headers: { "Accept" => "application/json" })
66
66
  end
67
67
 
68
68
  it "returns the webhook" do
@@ -87,7 +87,7 @@ describe Dnsimple::Client, ".webhooks" do
87
87
  subject.webhook(account_id, webhook_id = "1")
88
88
 
89
89
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}")
90
- .with(headers: { 'Accept' => 'application/json' })
90
+ .with(headers: { "Accept" => "application/json" })
91
91
  end
92
92
 
93
93
  it "returns the webhook" do
@@ -124,7 +124,7 @@ describe Dnsimple::Client, ".webhooks" do
124
124
  subject.delete_webhook(account_id, webhook_id = "1")
125
125
 
126
126
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}")
127
- .with(headers: { 'Accept' => 'application/json' })
127
+ .with(headers: { "Accept" => "application/json" })
128
128
  end
129
129
 
130
130
  it "returns nothing" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".zones" do
6
6
 
@@ -18,7 +18,7 @@ describe Dnsimple::Client, ".zones" do
18
18
  subject.zone_distribution(account_id, zone = "example.com")
19
19
 
20
20
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/distribution")
21
- .with(headers: { 'Accept' => 'application/json' })
21
+ .with(headers: { "Accept" => "application/json" })
22
22
  end
23
23
 
24
24
  it "returns the zone distribution check with true when the zone is fully distributed" do
@@ -78,7 +78,7 @@ describe Dnsimple::Client, ".zones" do
78
78
  subject.zone_record_distribution(account_id, zone_id, record_id)
79
79
 
80
80
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution")
81
- .with(headers: { 'Accept' => 'application/json' })
81
+ .with(headers: { "Accept" => "application/json" })
82
82
  end
83
83
 
84
84
  it "returns the zone record distribution check with true when the zone is fully distributed" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".zones" do
6
6
 
@@ -20,7 +20,7 @@ describe Dnsimple::Client, ".zones" do
20
20
  subject.list_zone_records(account_id, zone_id)
21
21
 
22
22
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records")
23
- .with(headers: { 'Accept' => 'application/json' })
23
+ .with(headers: { "Accept" => "application/json" })
24
24
  end
25
25
 
26
26
  it "supports pagination" do
@@ -126,7 +126,7 @@ describe Dnsimple::Client, ".zones" do
126
126
 
127
127
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records")
128
128
  .with(body: attributes)
129
- .with(headers: { 'Accept' => 'application/json' })
129
+ .with(headers: { "Accept" => "application/json" })
130
130
  end
131
131
 
132
132
  it "returns the record" do
@@ -168,7 +168,7 @@ describe Dnsimple::Client, ".zones" do
168
168
  subject.zone_record(account_id, zone_id, record_id)
169
169
 
170
170
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
171
- .with(headers: { 'Accept' => 'application/json' })
171
+ .with(headers: { "Accept" => "application/json" })
172
172
  end
173
173
 
174
174
  it "returns the record" do
@@ -216,7 +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
+ let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ["global"] } }
220
220
  let(:zone_id) { "example.com" }
221
221
  let(:record_id) { 5 }
222
222
 
@@ -231,7 +231,7 @@ describe Dnsimple::Client, ".zones" do
231
231
 
232
232
  expect(WebMock).to have_requested(:patch, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
233
233
  .with(body: attributes)
234
- .with(headers: { 'Accept' => 'application/json' })
234
+ .with(headers: { "Accept" => "application/json" })
235
235
  end
236
236
 
237
237
  it "returns the record" do
@@ -282,7 +282,7 @@ describe Dnsimple::Client, ".zones" do
282
282
  subject.delete_zone_record(account_id, zone_id, record_id = 2)
283
283
 
284
284
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
285
- .with(headers: { 'Accept' => 'application/json' })
285
+ .with(headers: { "Accept" => "application/json" })
286
286
  end
287
287
 
288
288
  it "returns nothing" do
@@ -316,4 +316,99 @@ describe Dnsimple::Client, ".zones" do
316
316
  end
317
317
  end
318
318
 
319
+ describe "#batch_change_zone_records" do
320
+ let(:account_id) { 1010 }
321
+ let(:attributes) { { creates: [{ type: "A", content: "3.2.3.4", name: "ab" }, { type: "A", content: "4.2.3.4", name: "ab" }], updates: [{ id: 67622534, content: "3.2.3.40", name: "update1-1757049890" }, { id: 67622537, content: "5.2.3.40", name: "update2-1757049890" }], deletes: [{ id: 67622509 }, { id: 67622527 }] } }
322
+ let(:zone_id) { "example.com" }
323
+
324
+ before do
325
+ stub_request(:post, %r{/v2/#{account_id}/zones/#{zone_id}/batch$})
326
+ .to_return(read_http_fixture("batchChangeZoneRecords/success.http"))
327
+ end
328
+
329
+
330
+ it "builds the correct request" do
331
+ subject.batch_change_zone_records(account_id, zone_id, attributes)
332
+
333
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/batch")
334
+ .with(body: attributes)
335
+ .with(headers: { "Accept" => "application/json" })
336
+ end
337
+
338
+ it "returns the result" do
339
+ response = subject.batch_change_zone_records(account_id, zone_id, attributes)
340
+ expect(response).to be_a(Dnsimple::Response)
341
+
342
+ result = response.data
343
+ expect(result).to be_a(Dnsimple::Struct::ZoneRecordsBatchChange)
344
+ expect(result.creates[0].id).to eq(67623409)
345
+ expect(result.creates[0].type).to eq(attributes.fetch(:creates)[0].fetch(:type))
346
+ expect(result.creates[0].name).to eq(attributes.fetch(:creates)[0].fetch(:name))
347
+ expect(result.creates[0].content).to eq(attributes.fetch(:creates)[0].fetch(:content))
348
+ expect(result.creates[0].regions).to eq(["global"])
349
+ expect(result.creates[1].id).to eq(67623410)
350
+ expect(result.updates[0].id).to eq(67622534)
351
+ expect(result.updates[0].type).to eq("A")
352
+ expect(result.updates[0].name).to eq(attributes.fetch(:updates)[0].fetch(:name))
353
+ expect(result.updates[0].content).to eq(attributes.fetch(:updates)[0].fetch(:content))
354
+ expect(result.updates[1].id).to eq(67622537)
355
+ expect(result.deletes[0].id).to eq(67622509)
356
+ expect(result.deletes[1].id).to eq(67622527)
357
+ end
358
+
359
+ context "when there are errors with creation" do
360
+ it "raises RequestError" do
361
+ stub_request(:post, %r{/v2/#{account_id}/zones/#{zone_id}/batch$})
362
+ .to_return(read_http_fixture("batchChangeZoneRecords/error_400_create_validation_failed.http"))
363
+
364
+ expect {
365
+ subject.batch_change_zone_records(account_id, zone_id, attributes)
366
+ }.to raise_error(Dnsimple::RequestError, "Validation failed") do |exception|
367
+ expect(exception.attribute_errors["creates"][0]["message"]).to eq("Validation failed")
368
+ expect(exception.attribute_errors["creates"][0]["index"]).to eq(0)
369
+ expect(exception.attribute_errors["creates"][0]["errors"]).to eq({ "record_type" => ["unsupported"] })
370
+ end
371
+ end
372
+ end
373
+
374
+ context "when there are errors with updates" do
375
+ it "raises RequestError" do
376
+ stub_request(:post, %r{/v2/#{account_id}/zones/#{zone_id}/batch$})
377
+ .to_return(read_http_fixture("batchChangeZoneRecords/error_400_update_validation_failed.http"))
378
+
379
+ expect {
380
+ subject.batch_change_zone_records(account_id, zone_id, attributes)
381
+ }.to raise_error(Dnsimple::RequestError, "Validation failed") do |exception|
382
+ expect(exception.attribute_errors["updates"][0]["message"]).to eq("Record not found ID=99999999")
383
+ expect(exception.attribute_errors["updates"][0]["index"]).to eq(0)
384
+ end
385
+ end
386
+ end
387
+
388
+ context "when there are errors with deletes" do
389
+ it "raises RequestError" do
390
+ stub_request(:post, %r{/v2/#{account_id}/zones/#{zone_id}/batch$})
391
+ .to_return(read_http_fixture("batchChangeZoneRecords/error_400_delete_validation_failed.http"))
392
+
393
+ expect {
394
+ subject.batch_change_zone_records(account_id, zone_id, attributes)
395
+ }.to raise_error(Dnsimple::RequestError, "Validation failed") do |exception|
396
+ expect(exception.attribute_errors["deletes"][0]["message"]).to eq("Record not found ID=67622509")
397
+ expect(exception.attribute_errors["deletes"][0]["index"]).to eq(0)
398
+ end
399
+ end
400
+ end
401
+
402
+ context "when the zone does not exist" do
403
+ it "raises NotFoundError" do
404
+ stub_request(:post, %r{/v2})
405
+ .to_return(read_http_fixture("notfound-zone.http"))
406
+
407
+ expect {
408
+ subject.batch_change_zone_records(account_id, zone_id, attributes)
409
+ }.to raise_error(Dnsimple::NotFoundError)
410
+ end
411
+ end
412
+ end
413
+
319
414
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Dnsimple::Client, ".zones" do
6
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").zones }
@@ -18,7 +18,7 @@ describe Dnsimple::Client, ".zones" do
18
18
  subject.zones(account_id)
19
19
 
20
20
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones")
21
- .with(headers: { 'Accept' => 'application/json' })
21
+ .with(headers: { "Accept" => "application/json" })
22
22
  end
23
23
 
24
24
  it "supports pagination" do
@@ -107,7 +107,7 @@ describe Dnsimple::Client, ".zones" do
107
107
  subject.zone(account_id, zone = "example.com")
108
108
 
109
109
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}")
110
- .with(headers: { 'Accept' => 'application/json' })
110
+ .with(headers: { "Accept" => "application/json" })
111
111
  end
112
112
 
113
113
  it "returns the zone" do
@@ -151,7 +151,7 @@ describe Dnsimple::Client, ".zones" do
151
151
  subject.zone_file(account_id, zone = "example.com")
152
152
 
153
153
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/file")
154
- .with(headers: { 'Accept' => 'application/json' })
154
+ .with(headers: { "Accept" => "application/json" })
155
155
  end
156
156
 
157
157
  it "returns the zone id" do
@@ -187,7 +187,7 @@ describe Dnsimple::Client, ".zones" do
187
187
  subject.activate_dns(account_id, zone = "example.com")
188
188
 
189
189
  expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/activation")
190
- .with(headers: { 'Accept' => 'application/json' })
190
+ .with(headers: { "Accept" => "application/json" })
191
191
  end
192
192
 
193
193
  it "returns the zone" do
@@ -229,7 +229,7 @@ describe Dnsimple::Client, ".zones" do
229
229
  subject.deactivate_dns(account_id, zone = "example.com")
230
230
 
231
231
  expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/activation")
232
- .with(headers: { 'Accept' => 'application/json' })
232
+ .with(headers: { "Accept" => "application/json" })
233
233
  end
234
234
 
235
235
  it "returns the zone" do