dnsimple 8.4.0 → 8.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34867970ac25f062a88e64df5c8ffc1a4cebb69612aea702cf6075ca79a9f9e7
4
- data.tar.gz: 79ffa15c0875466c11c175feeda98df3467ddeb0b2229c16aa6c92aecf1e0a39
3
+ metadata.gz: 644e524e7010bc680c34ba6abf09315fbe41e2a5ec63ee6c82e443df4f21326a
4
+ data.tar.gz: aa84484bdf2a0b8b48ca45ad448dcea01c8c879acdf4b1c018f2cb8fb73ad7cf
5
5
  SHA512:
6
- metadata.gz: d7d71422305173c73b5dc948ffaf006d76b651697afc072b90e494dd9051c90424409ad7f16366bbec4ea5992fadcad6463c133c7b0ef522bbabe03c6b78f766
7
- data.tar.gz: 980c1e8c59db95933ab3d6e95eea871fcaaf9234b4866efbfc105c7da2fb841097a8e9aec2deb467d3ca1a6a7e9db79bcaed9b3851c6da4429c5799e3ded2a92
6
+ metadata.gz: fa53931624fc7c23d8f91332c9d86379560fc3609fe0f351d6346b6e38fb5b9337bb04e0aa6120c639431b9931cbc100405bc7bca544e04ee805b1ef07e2d4cb
7
+ data.tar.gz: 0032b9d9c4b3df0581e9037a5196bc8376c9f01dbb87ced552eb0372f6d30263a1121bdd86ba16e1a5a992974b64639cbdb81b9ba50e8442603bd0c6ab39f0b2
data/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).
4
4
 
5
5
  ## main
6
6
 
7
+ ## 8.6.0
8
+
9
+ FEATURES:
10
+
11
+ - NEW: Added `Dnsimple::Client::Registrar#get_domain_transfer_lock` to retrieves the transfer lock status of a registered domain. (dnsimple/dnsimple-ruby#356)
12
+ - NEW: Added `Dnsimple::Client::Registrar#enable_domain_transfer_lock` to enable the transfer lock for a registered domain. (dnsimple/dnsimple-ruby#356)
13
+ - NEW: Added `Dnsimple::Client::Registrar#disable_domain_transfer_lock` to disable the transfer lock for a registered domain. (dnsimple/dnsimple-ruby#356)
14
+
15
+ ## 8.5.0
16
+
17
+ FEATURES:
18
+
19
+ - NEW: Added `Dnsimple::Client::Registrar#check_registrant_change` to retrieves the requirements of a registrant change. (dnsimple/dnsimple-ruby#355)
20
+ - NEW: Added `Dnsimple::Client::Registrar#get_registrant_change` to retrieves the details of an existing registrant change. (dnsimple/dnsimple-ruby#355)
21
+ - NEW: Added `Dnsimple::Client::Registrar#create_registrant_change` to start registrant change. (dnsimple/dnsimple-ruby#355)
22
+ - NEW: Added `Dnsimple::Client::Registrar#list_registrant_changes` to lists the registrant changes for a domain. (dnsimple/dnsimple-ruby#355)
23
+ - NEW: Added `Dnsimple::Client::Registrar#delete_registrant_change` to cancel an ongoing registrant change from the account. (dnsimple/dnsimple-ruby#355)
24
+
7
25
  ## 8.4.0
8
26
 
9
27
  FEATURES:
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  gem 'coveralls', require: false
8
- gem 'rubocop', '1.55.1', require: false
9
- gem 'rubocop-performance', '1.18.0', require: false
8
+ gem 'rubocop', '1.56.2', require: false
9
+ gem 'rubocop-performance', '1.19.0', require: false
10
10
  gem 'rubocop-rake', '0.6.0', require: false
11
- gem 'rubocop-rspec', '2.23.0', require: false
11
+ gem 'rubocop-rspec', '2.23.2', require: false
@@ -160,17 +160,20 @@ module Dnsimple
160
160
  include Client::Oauth
161
161
  end
162
162
 
163
-
164
163
  require_relative 'registrar'
165
164
  require_relative 'registrar_auto_renewal'
166
165
  require_relative 'registrar_whois_privacy'
166
+ require_relative 'registrar_registrant_changes'
167
+ require_relative 'registrar_transfer_lock'
167
168
  require_relative 'registrar_delegation'
168
169
 
169
170
  class RegistrarService < ClientService
170
171
  include Client::Registrar
171
172
  include Client::RegistrarAutoRenewal
172
- include Client::RegistrarWhoisPrivacy
173
173
  include Client::RegistrarDelegation
174
+ include Client::RegistrarRegistrantChanges
175
+ include Client::RegistrarTransferLock
176
+ include Client::RegistrarWhoisPrivacy
174
177
  end
175
178
 
176
179
 
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ class Client
5
+ module RegistrarRegistrantChanges
6
+
7
+ # Retrieves the requirements of a registrant change
8
+ #
9
+ # @example Check the requirements to change the contact for example.com to contact 1234:
10
+ # client.registrar.check_registrant_change(1010, { domain_id: "example.com", contact_id: 1234 })
11
+ #
12
+ # @param [Integer] account_id the account ID
13
+ # @param [Hash] attributes the attributes to check the registrant change
14
+ # @option attributes [String, Integer] :domain_id the domain ID to check
15
+ # @option attributes [Integer] :contact_id the contact ID to check against
16
+ # @param [Hash] options
17
+ # @return [Struct::RegistrantChangeCheck]
18
+ #
19
+ # @raise [RequestError] When the request fails.
20
+ def check_registrant_change(account_id, attributes, options = {})
21
+ Extra.validate_mandatory_attributes(attributes, [:domain_id, :contact_id])
22
+ endpoint = Client.versioned("/%s/registrar/registrant_changes/check" % [account_id])
23
+ response = client.post(endpoint, attributes, options)
24
+
25
+ Dnsimple::Response.new(response, Struct::RegistrantChangeCheck.new(response["data"]))
26
+ end
27
+
28
+ # Retrieves the details of an existing registrant change.
29
+ #
30
+ # @example Retrieve the registrant change 42:
31
+ # client.registrar.get_registrant_change(1010, 42)
32
+ #
33
+ # @param [Integer] account_id the Account id
34
+ # @param [#to_s] registrant_change_id the registrant change id
35
+ # @param [Hash] options
36
+ #
37
+ # @return [Struct::RegistrantChange]
38
+ #
39
+ # @raise [NotFoundError] When record is not found.
40
+ # @raise [RequestError] When the request fails.
41
+ def get_registrant_change(account_id, registrant_change_id, options = {})
42
+ endpoint = Client.versioned("/%s/registrar/registrant_changes/%s" % [account_id, registrant_change_id])
43
+ response = client.get(endpoint, options)
44
+
45
+ Dnsimple::Response.new(response, Struct::RegistrantChange.new(response["data"]))
46
+ end
47
+
48
+ # Start registrant change.
49
+ #
50
+ # @example Start a registrant change for example.com to contact 1234:
51
+ # including WHOIS privacy for the domain and enabling auto renewal:
52
+ # client.registrar.create_registrant_change(1010, { domain_id: "example.com", contact_id: 1234, extended_attributes: { "x-fi-registrant-idnumber" => "1234" } })
53
+ #
54
+ # @param [Integer] account_id the account ID
55
+ # @param [Hash] attributes the attributes to start a registrant change
56
+ # @option attributes [String, Integer] :domain_id the domain ID
57
+ # @option attributes [Integer] :contact_id the contact ID to change to
58
+ # @option attributes [Array<Hash>, nil] :extended_attributes the extended attributes to pass to the registry
59
+ # @param [Hash] options
60
+ # @return [Struct::RegistrantChange]
61
+ #
62
+ # @raise [RequestError] When the request fails.
63
+ def create_registrant_change(account_id, attributes, options = {})
64
+ Extra.validate_mandatory_attributes(attributes, [:domain_id, :contact_id])
65
+ endpoint = Client.versioned("/%s/registrar/registrant_changes" % [account_id])
66
+ response = client.post(endpoint, attributes, options)
67
+
68
+ Dnsimple::Response.new(response, Struct::RegistrantChange.new(response["data"]))
69
+ end
70
+
71
+ # List registrant changes in the account.
72
+ #
73
+ # @example List registrant changes for the account:
74
+ # client.registrar.list_registrant_changes(1010)
75
+ #
76
+ # @param [Integer] account_id the account ID
77
+ # @param [Hash] options
78
+ # @return [Dnsimple::PaginatedResponse<Struct::DomainRegistration>]
79
+ #
80
+ # @raise [NotFoundError] When record is not found.
81
+ # @raise [RequestError] When the request fails.
82
+ def list_registrant_changes(account_id, options = {})
83
+ endpoint = Client.versioned("/%s/registrar/registrant_changes" % [account_id])
84
+ response = client.get(endpoint, options)
85
+
86
+ Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::RegistrantChange.new(r) })
87
+ end
88
+
89
+ # Cancel an ongoing registrant change from the account.
90
+ #
91
+ # @example Cancel a registrant change 42:
92
+ # client.registrar.delete_registrant_change(1010, 42)
93
+ #
94
+ # @param [Integer] account_id the account ID
95
+ # @param [#to_s] registrant_change_id the registrant change ID
96
+ # @param [Hash] options
97
+ # @return [Dnsimple::Response<nil>]
98
+ #
99
+ # @raise [NotFoundError] When record is not found.
100
+ # @raise [RequestError] When the request fails.
101
+ def delete_registrant_change(account_id, registrant_change_id, options = {})
102
+ endpoint = Client.versioned("/%s/registrar/registrant_changes/%s" % [account_id, registrant_change_id])
103
+ response = client.delete(endpoint, nil, options)
104
+
105
+ Dnsimple::Response.new(response, nil)
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ class Client
5
+ module RegistrarTransferLock
6
+
7
+ # Gets the transfer lock for the domain.
8
+ #
9
+ # @example Get the transfer lock for "example.com":
10
+ # client.registrar.get_domain_transfer_lock(1010, "example.com")
11
+ #
12
+ # @param [#to_s] account_id the account ID
13
+ # @param [#to_s] domain_name the domain name
14
+ # @param [Hash] options
15
+ # @return [Struct::TransferLock]
16
+ #
17
+ # @raise [Dnsimple::NotFoundError]
18
+ # @raise [RequestError] When the request fails.
19
+ def get_domain_transfer_lock(account_id, domain_name, options = {})
20
+ response = client.get(Client.versioned("/%s/registrar/domains/%s/transfer_lock" % [account_id, domain_name]), options)
21
+
22
+ Dnsimple::Response.new(response, Struct::TransferLock.new(response["data"]))
23
+ end
24
+
25
+ # Enable transfer lock for the domain in the account.
26
+ #
27
+ # @see https://developer.dnsimple.com/v2/registrar/#enableDomainTransferLock
28
+ #
29
+ # @param [Integer] account_id the account ID
30
+ # @param [#to_s] domain_name the domain name
31
+ # @param [Hash] options
32
+ # @return [Struct::TransferLock]
33
+ #
34
+ # @raise [Dnsimple::NotFoundError]
35
+ # @raise [Dnsimple::RequestError]
36
+ def enable_domain_transfer_lock(account_id, domain_name, options = {})
37
+ response = client.post(Client.versioned("/%s/registrar/domains/%s/transfer_lock" % [account_id, domain_name]), nil, options)
38
+
39
+ Dnsimple::Response.new(response, Struct::TransferLock.new(response["data"]))
40
+ end
41
+
42
+ # Disable trasnfer lock for the domain in the account.
43
+ #
44
+ # @see https://developer.dnsimple.com/v2/registrar/#disableDomainTransferLock
45
+ #
46
+ # @param [Integer] account_id the account ID
47
+ # @param [#to_s] domain_name the domain name
48
+ # @param [Hash] options
49
+ # @return [Struct::TransferLock]
50
+ #
51
+ # @raise [Dnsimple::NotFoundError]
52
+ # @raise [Dnsimple::RequestError]
53
+ def disable_domain_transfer_lock(account_id, domain_name, options = {})
54
+ response = client.delete(Client.versioned("/%s/registrar/domains/%s/transfer_lock" % [account_id, domain_name]), nil, options)
55
+
56
+ Dnsimple::Response.new(response, Struct::TransferLock.new(response["data"]))
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class RegistrantChange < Base
7
+ # @return [Integer] The registrant change ID in DNSimple.
8
+ attr_accessor :id
9
+
10
+ # @return [Integer] The associated account ID.
11
+ attr_accessor :account_id
12
+
13
+ # @return [Integer] The associated contact ID.
14
+ attr_accessor :contact_id
15
+
16
+ # @return [Integer] The associated domain ID.
17
+ attr_accessor :domain_id
18
+
19
+ # @return [String] The registrant change state.
20
+ attr_accessor :state
21
+
22
+ # @return [Hash] The extended attributes.
23
+ attr_accessor :extended_attributes
24
+
25
+ # @return [Boolean] True if the registrant change is a registry owner change.
26
+ attr_accessor :registry_owner_change
27
+
28
+ # @return [String] When the Inter-Registrar Transfer lock (60 days) is going to be lifted.
29
+ attr_accessor :irt_lock_lifted_by
30
+
31
+ # @return [String] When the registrant change was created in DNSimple.
32
+ attr_accessor :created_at
33
+
34
+ # @return [String] When the registrant change was last updated in DNSimple.
35
+ attr_accessor :updated_at
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class RegistrantChangeCheck < Base
7
+ # @return [Integer] The associated contact ID.
8
+ attr_accessor :contact_id
9
+
10
+ # @return [Integer] The associated domain ID.
11
+ attr_accessor :domain_id
12
+
13
+ # @return [Array<Hash>] The extended attributes.
14
+ attr_accessor :extended_attributes
15
+
16
+ # # @return [Boolean] True if the registrant change is a registry owner change.
17
+ attr_accessor :registry_owner_change
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class TransferLock < Base
7
+ # @return [Boolean] True if Transfer Lock is enabled on the domain, otherwise false
8
+ attr_accessor :enabled
9
+ end
10
+
11
+ end
12
+ end
@@ -35,6 +35,9 @@ require_relative 'struct/domain_renewal'
35
35
  require_relative 'struct/email_forward'
36
36
  require_relative 'struct/extended_attribute'
37
37
  require_relative 'struct/oauth_token'
38
+ require_relative 'struct/registrant_change_check'
39
+ require_relative 'struct/registrant_change'
40
+ require_relative 'struct/transfer_lock'
38
41
  require_relative 'struct/zone_record'
39
42
  require_relative 'struct/service'
40
43
  require_relative 'struct/template'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dnsimple
4
- VERSION = "8.4.0"
4
+ VERSION = "8.6.0"
5
5
  end
@@ -3,7 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Dnsimple::Client, ".registrar" do
6
-
7
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").registrar }
8
7
 
9
8
 
@@ -283,7 +282,7 @@ describe Dnsimple::Client, ".registrar" do
283
282
  result = response.data
284
283
  expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
285
284
  expect(result.id).to eq(361)
286
- expect(result.domain_id).to eq(182245)
285
+ expect(result.domain_id).to eq(182_245)
287
286
  expect(result.registrant_id).to eq(2715)
288
287
  expect(result.state).to eq("cancelled")
289
288
  expect(result.auto_renew).to be(false)
@@ -316,7 +315,7 @@ describe Dnsimple::Client, ".registrar" do
316
315
  result = response.data
317
316
  expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
318
317
  expect(result.id).to eq(361)
319
- expect(result.domain_id).to eq(182245)
318
+ expect(result.domain_id).to eq(182_245)
320
319
  expect(result.registrant_id).to eq(2715)
321
320
  expect(result.state).to eq("transferring")
322
321
  expect(result.auto_renew).to be(false)
@@ -352,4 +351,224 @@ describe Dnsimple::Client, ".registrar" do
352
351
  end
353
352
  end
354
353
 
354
+ describe "#check_registrant_change" do
355
+ let(:account_id) { 1010 }
356
+ let(:attributes) { { domain_id: "example.com", contact_id: 1234 } }
357
+
358
+ before do
359
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes/check$})
360
+ .to_return(read_http_fixture("checkRegistrantChange/success.http"))
361
+ end
362
+
363
+ it "builds the correct request" do
364
+ subject.check_registrant_change(account_id, attributes)
365
+
366
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/registrar/registrant_changes/check")
367
+ .with(headers: { "Accept" => "application/json" })
368
+ .with(body: attributes)
369
+ end
370
+
371
+ it "returns the registrant change check" do
372
+ response = subject.check_registrant_change(account_id, attributes)
373
+ expect(response).to be_a(Dnsimple::Response)
374
+
375
+ result = response.data
376
+ expect(result).to be_a(Dnsimple::Struct::RegistrantChangeCheck)
377
+ expect(result.contact_id).to eq(101)
378
+ expect(result.domain_id).to eq(101)
379
+ expect(result.extended_attributes).to be_a(Array)
380
+ expect(result.extended_attributes).to be_empty
381
+ expect(result.registry_owner_change).to be(true)
382
+ end
383
+
384
+ context "when the attributes are incomplete" do
385
+ it "raises ArgumentError" do
386
+ expect { subject.check_registrant_change(account_id, domain_id: "example.com") }.to raise_error(ArgumentError)
387
+ end
388
+ end
389
+
390
+ context "when the domain is not found" do
391
+ it "raises a NotFoundError" do
392
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes/check$})
393
+ .to_return(read_http_fixture("checkRegistrantChange/error-domainnotfound.http"))
394
+
395
+ expect {
396
+ subject.check_registrant_change(account_id, attributes)
397
+ }.to raise_error(Dnsimple::NotFoundError)
398
+ end
399
+ end
400
+
401
+ context "when the contact is not found" do
402
+ it "raises a NotFoundError" do
403
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes/check$})
404
+ .to_return(read_http_fixture("checkRegistrantChange/error-contactnotfound.http"))
405
+
406
+ expect {
407
+ subject.check_registrant_change(account_id, attributes)
408
+ }.to raise_error(Dnsimple::NotFoundError)
409
+ end
410
+ end
411
+ end
412
+
413
+ describe "#get_registrant_change" do
414
+ let(:account_id) { 1010 }
415
+
416
+ before do
417
+ stub_request(:get, %r{/v2/#{account_id}/registrar/registrant_changes/.+$})
418
+ .to_return(read_http_fixture("getRegistrantChange/success.http"))
419
+ end
420
+
421
+ it "builds the correct request" do
422
+ subject.get_registrant_change(account_id, registrant_change_id = 42)
423
+
424
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/registrant_changes/#{registrant_change_id}")
425
+ .with(headers: { "Accept" => "application/json" })
426
+ end
427
+
428
+ it "returns the registrant change" do
429
+ response = subject.get_registrant_change(account_id, 42)
430
+ expect(response).to be_a(Dnsimple::Response)
431
+
432
+ result = response.data
433
+ expect(result).to be_a(Dnsimple::Struct::RegistrantChange)
434
+ expect(result.id).to eq(101)
435
+ expect(result.account_id).to eq(101)
436
+ expect(result.contact_id).to eq(101)
437
+ expect(result.domain_id).to eq(101)
438
+ expect(result.state).to eq("new")
439
+ expect(result.extended_attributes).to be_a(Hash)
440
+ expect(result.extended_attributes).to be_empty
441
+ expect(result.registry_owner_change).to be(true)
442
+ expect(result.irt_lock_lifted_by).to be_nil
443
+ expect(result.created_at).to eq("2017-02-03T17:43:22Z")
444
+ expect(result.updated_at).to eq("2017-02-03T17:43:22Z")
445
+ end
446
+ end
447
+
448
+ describe "#create_registrant_change" do
449
+ let(:account_id) { 1010 }
450
+ let(:attributes) { { domain_id: "example.com", contact_id: 1234, extended_attributes: { "x-fi-registrant-idnumber" => "1234" } } }
451
+
452
+ before do
453
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes$})
454
+ .to_return(read_http_fixture("createRegistrantChange/success.http"))
455
+ end
456
+
457
+ it "builds the correct request" do
458
+ subject.create_registrant_change(account_id, attributes)
459
+
460
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/registrar/registrant_changes")
461
+ .with(headers: { "Accept" => "application/json" })
462
+ .with(body: attributes)
463
+ end
464
+
465
+ it "returns the registrant change" do
466
+ response = subject.create_registrant_change(account_id, attributes)
467
+ expect(response).to be_a(Dnsimple::Response)
468
+
469
+ result = response.data
470
+ expect(result).to be_a(Dnsimple::Struct::RegistrantChange)
471
+ expect(result.id).to eq(101)
472
+ expect(result.account_id).to eq(101)
473
+ expect(result.contact_id).to eq(101)
474
+ expect(result.domain_id).to eq(101)
475
+ expect(result.state).to eq("new")
476
+ expect(result.extended_attributes).to be_a(Hash)
477
+ expect(result.extended_attributes).to be_empty
478
+ expect(result.registry_owner_change).to be(true)
479
+ expect(result.irt_lock_lifted_by).to be_nil
480
+ expect(result.created_at).to eq("2017-02-03T17:43:22Z")
481
+ expect(result.updated_at).to eq("2017-02-03T17:43:22Z")
482
+ end
483
+
484
+ context "when the attributes are incomplete" do
485
+ it "raises ArgumentError" do
486
+ expect { subject.create_registrant_change(account_id, domain_id: "example.com") }.to raise_error(ArgumentError)
487
+ end
488
+ end
489
+
490
+ context "when the domain is not found" do
491
+ it "raises a NotFoundError" do
492
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes$})
493
+ .to_return(read_http_fixture("checkRegistrantChange/error-domainnotfound.http"))
494
+
495
+ expect {
496
+ subject.create_registrant_change(account_id, attributes)
497
+ }.to raise_error(Dnsimple::NotFoundError)
498
+ end
499
+ end
500
+
501
+ context "when the contact is not found" do
502
+ it "raises a NotFoundError" do
503
+ stub_request(:post, %r{/v2/#{account_id}/registrar/registrant_changes$})
504
+ .to_return(read_http_fixture("checkRegistrantChange/error-contactnotfound.http"))
505
+
506
+ expect {
507
+ subject.create_registrant_change(account_id, attributes)
508
+ }.to raise_error(Dnsimple::NotFoundError)
509
+ end
510
+ end
511
+ end
512
+
513
+ describe "#list_registrant_changes" do
514
+ let(:account_id) { 1010 }
515
+
516
+ before do
517
+ stub_request(:get, %r{/v2/#{account_id}/registrar/registrant_changes$})
518
+ .to_return(read_http_fixture("listRegistrantChanges/success.http"))
519
+ end
520
+
521
+ it "builds the correct request" do
522
+ subject.list_registrant_changes(account_id)
523
+
524
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/registrant_changes")
525
+ .with(headers: { "Accept" => "application/json" })
526
+ end
527
+
528
+ it "returns the registrant changes" do
529
+ response = subject.list_registrant_changes(account_id)
530
+ expect(response).to be_a(Dnsimple::PaginatedResponse)
531
+
532
+ results = response.data
533
+
534
+ results.each do |result|
535
+ expect(result).to be_a(Dnsimple::Struct::RegistrantChange)
536
+ expect(result.id).to be_a(Integer)
537
+ expect(result.account_id).to be_a(Integer)
538
+ expect(result.contact_id).to be_a(Integer)
539
+ expect(result.domain_id).to be_a(Integer)
540
+ expect(result.state).to be_a(String)
541
+ expect(result.extended_attributes).to be_a(Hash)
542
+ expect(result.extended_attributes).to be_empty
543
+ expect(result.registry_owner_change).to be(true).or be(false)
544
+ expect(result.irt_lock_lifted_by).to be_nil
545
+ expect(result.created_at).to be_a(String)
546
+ expect(result.updated_at).to be_a(String)
547
+ end
548
+ end
549
+ end
550
+
551
+ describe "#delete_registrant_change" do
552
+ let(:account_id) { 1010 }
553
+
554
+ before do
555
+ stub_request(:delete, %r{/v2/#{account_id}/registrar/registrant_changes/.+$})
556
+ .to_return(read_http_fixture("deleteRegistrantChange/success.http"))
557
+ end
558
+
559
+ it "builds the correct request" do
560
+ subject.delete_registrant_change(account_id, registrant_change_id = 42)
561
+
562
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/registrant_changes/#{registrant_change_id}")
563
+ .with(headers: { "Accept" => "application/json" })
564
+ end
565
+
566
+ it "returns nothing" do
567
+ response = subject.delete_registrant_change(account_id, 42)
568
+ expect(response).to be_a(Dnsimple::Response)
569
+
570
+ result = response.data
571
+ expect(result).to be_nil
572
+ end
573
+ end
355
574
  end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Dnsimple::Client, ".registrar" do
6
+ subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").registrar }
7
+
8
+ describe "#get_domain_transfer_lock" do
9
+ let(:account_id) { 1010 }
10
+ let(:domain_id) { "example.com" }
11
+
12
+ before do
13
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/#{domain_id}/transfer_lock})
14
+ .to_return(read_http_fixture("getDomainTransferLock/success.http"))
15
+ end
16
+
17
+ it "builds the correct request" do
18
+ subject.get_domain_transfer_lock(account_id, domain_id)
19
+
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' })
22
+ end
23
+
24
+ it "returns the transfer lock state" do
25
+ response = subject.get_domain_transfer_lock(account_id, domain_id)
26
+ expect(response).to be_a(Dnsimple::Response)
27
+
28
+ result = response.data
29
+ expect(result).to be_a(Dnsimple::Struct::TransferLock)
30
+ expect(result.enabled).to be(true)
31
+ end
32
+
33
+ context "when the domain does not exist" do
34
+ it "raises NotFoundError" do
35
+ stub_request(:get, %r{/v2})
36
+ .to_return(read_http_fixture("notfound-domain.http"))
37
+
38
+ expect {
39
+ subject.get_domain_transfer_lock(account_id, domain_id)
40
+ }.to raise_error(Dnsimple::NotFoundError)
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#enable_domain_transfer_lock" do
46
+ let(:account_id) { 1010 }
47
+ let(:domain_id) { "example.com" }
48
+
49
+ before do
50
+ stub_request(:post, %r{/v2/#{account_id}/registrar/domains/#{domain_id}/transfer_lock})
51
+ .to_return(read_http_fixture("enableDomainTransferLock/success.http"))
52
+ end
53
+
54
+ it "builds the correct request" do
55
+ subject.enable_domain_transfer_lock(account_id, domain_id)
56
+
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' })
59
+ end
60
+
61
+ it "returns the transfer lock state" do
62
+ response = subject.enable_domain_transfer_lock(account_id, domain_id)
63
+ expect(response).to be_a(Dnsimple::Response)
64
+
65
+ result = response.data
66
+ expect(result).to be_a(Dnsimple::Struct::TransferLock)
67
+ expect(result.enabled).to be(true)
68
+ end
69
+
70
+ context "when the domain does not exist" do
71
+ it "raises NotFoundError" do
72
+ stub_request(:post, %r{/v2})
73
+ .to_return(read_http_fixture("notfound-domain.http"))
74
+
75
+ expect {
76
+ subject.enable_domain_transfer_lock(account_id, domain_id)
77
+ }.to raise_error(Dnsimple::NotFoundError)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "#disable_domain_transfer_lock" do
83
+ let(:account_id) { 1010 }
84
+ let(:domain_id) { "example.com" }
85
+
86
+ before do
87
+ stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/#{domain_id}})
88
+ .to_return(read_http_fixture("disableDomainTransferLock/success.http"))
89
+ end
90
+
91
+ it "builds the correct request" do
92
+ subject.disable_domain_transfer_lock(account_id, domain_id)
93
+
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' })
96
+ end
97
+
98
+ it "returns the transfer lock state" do
99
+ response = subject.disable_domain_transfer_lock(account_id, domain_id)
100
+ expect(response).to be_a(Dnsimple::Response)
101
+
102
+ result = response.data
103
+ expect(result).to be_a(Dnsimple::Struct::TransferLock)
104
+ expect(result.enabled).to be(false)
105
+ end
106
+
107
+ context "when the domain does not exist" do
108
+ it "raises NotFoundError" do
109
+ stub_request(:delete, %r{/v2})
110
+ .to_return(read_http_fixture("notfound-domain.http"))
111
+
112
+ expect {
113
+ subject.disable_domain_transfer_lock(account_id, domain_id)
114
+ }.to raise_error(Dnsimple::NotFoundError)
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,14 @@
1
+ HTTP/1.1 404
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 13:59:02 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2398
7
+ x-ratelimit-reset: 1692716201
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ cache-control: no-cache
10
+ x-request-id: b1dd3f42-ebb9-42fd-a121-d595de96f667
11
+ x-runtime: 0.019122
12
+ strict-transport-security: max-age=63072000
13
+
14
+ {"message":"Contact `21` not found"}
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 404
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:09:40 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2395
7
+ x-ratelimit-reset: 1692705338
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ etag: W/"cef1e7d85d0b9bfd25e81b812891d34f"
10
+ cache-control: max-age=0, private, must-revalidate
11
+ x-request-id: 5b0d8bfb-7b6a-40b5-a079-b640fd817e34
12
+ x-runtime: 3.066249
13
+ strict-transport-security: max-age=63072000
14
+
15
+ {"message":"Domain `example.com` not found"}
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 200
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:09:40 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2395
7
+ x-ratelimit-reset: 1692705338
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ etag: W/"cef1e7d85d0b9bfd25e81b812891d34f"
10
+ cache-control: max-age=0, private, must-revalidate
11
+ x-request-id: 5b0d8bfb-7b6a-40b5-a079-b640fd817e34
12
+ x-runtime: 3.066249
13
+ strict-transport-security: max-age=63072000
14
+
15
+ {"data":{"domain_id":101,"contact_id":101,"extended_attributes":[],"registry_owner_change":true}}
@@ -0,0 +1,14 @@
1
+ HTTP/1.1 202
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:11:00 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2394
7
+ x-ratelimit-reset: 1692705339
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ cache-control: no-cache
10
+ x-request-id: 26bf7ff9-2075-42b0-9431-1778c825b6b0
11
+ x-runtime: 3.408950
12
+ strict-transport-security: max-age=63072000
13
+
14
+ {"data":{"id":101,"account_id":101,"domain_id":101,"contact_id":101,"state":"new","extended_attributes":{},"registry_owner_change":true,"irt_lock_lifted_by":null,"created_at":"2017-02-03T17:43:22Z","updated_at":"2017-02-03T17:43:22Z"}}
@@ -0,0 +1,13 @@
1
+ HTTP/1.1 201
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:14:44 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2391
7
+ x-ratelimit-reset: 1692705338
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ cache-control: no-cache
10
+ x-request-id: b123e1f0-aa70-4abb-95cf-34f377c83ef4
11
+ x-runtime: 0.114839
12
+ strict-transport-security: max-age=63072000
13
+
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 15 Aug 2023 09:58:37 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2398
8
+ X-RateLimit-Reset: 1488538623
9
+ ETag: W/"fc2368a31a1b6a3afcca33bb37ff6b9d"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: 8b0fe49a-c810-4552-84ab-a1cd9b4a7786
12
+ X-Runtime: 0.024780
13
+ X-Content-Type-Options: nosniff
14
+ X-Download-Options: noopen
15
+ X-Frame-Options: DENY
16
+ X-Permitted-Cross-Domain-Policies: none
17
+ X-XSS-Protection: 1; mode=block
18
+ Strict-Transport-Security: max-age=31536000
19
+
20
+ {"data":{"enabled":false}}
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 201 Created
2
+ Server: nginx
3
+ Date: Tue, 15 Aug 2023 09:58:37 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2398
8
+ X-RateLimit-Reset: 1488538623
9
+ ETag: W/"fc2368a31a1b6a3afcca33bb37ff6b9d"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: 8b0fe49a-c810-4552-84ab-a1cd9b4a7786
12
+ X-Runtime: 0.024780
13
+ X-Content-Type-Options: nosniff
14
+ X-Download-Options: noopen
15
+ X-Frame-Options: DENY
16
+ X-Permitted-Cross-Domain-Policies: none
17
+ X-XSS-Protection: 1; mode=block
18
+ Strict-Transport-Security: max-age=31536000
19
+
20
+ {"data":{"enabled":true}}
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 15 Aug 2023 09:58:37 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2398
8
+ X-RateLimit-Reset: 1488538623
9
+ ETag: W/"fc2368a31a1b6a3afcca33bb37ff6b9d"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: 8b0fe49a-c810-4552-84ab-a1cd9b4a7786
12
+ X-Runtime: 0.024780
13
+ X-Content-Type-Options: nosniff
14
+ X-Download-Options: noopen
15
+ X-Frame-Options: DENY
16
+ X-Permitted-Cross-Domain-Policies: none
17
+ X-XSS-Protection: 1; mode=block
18
+ Strict-Transport-Security: max-age=31536000
19
+
20
+ {"data":{"enabled":true}}
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 200
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:13:58 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2392
7
+ x-ratelimit-reset: 1692705338
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ etag: W/"76c5d4c7579b754b94a42ac7fa37a901"
10
+ cache-control: max-age=0, private, must-revalidate
11
+ x-request-id: e910cd08-3f9c-4da4-9986-50dbe9c3bc55
12
+ x-runtime: 0.022006
13
+ strict-transport-security: max-age=63072000
14
+
15
+ {"data":{"id":101,"account_id":101,"domain_id":101,"contact_id":101,"state":"new","extended_attributes":{},"registry_owner_change":true,"irt_lock_lifted_by":null,"created_at":"2017-02-03T17:43:22Z","updated_at":"2017-02-03T17:43:22Z"}}
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 200
2
+ server: nginx
3
+ date: Tue, 22 Aug 2023 11:12:49 GMT
4
+ content-type: application/json; charset=utf-8
5
+ x-ratelimit-limit: 2400
6
+ x-ratelimit-remaining: 2393
7
+ x-ratelimit-reset: 1692705338
8
+ x-work-with-us: Love automation? So do we! https://dnsimple.com/jobs
9
+ etag: W/"0049703ea058b06346df4c0e169eac29"
10
+ cache-control: max-age=0, private, must-revalidate
11
+ x-request-id: fd0334ce-414a-4872-8889-e548e0b1410c
12
+ x-runtime: 0.030759
13
+ strict-transport-security: max-age=63072000
14
+
15
+ {"data":[{"id":101,"account_id":101,"domain_id":101,"contact_id":101,"state":"new","extended_attributes":{},"registry_owner_change":true,"irt_lock_lifted_by":null,"created_at":"2017-02-03T17:43:22Z","updated_at":"2017-02-03T17:43:22Z"}],"pagination":{"current_page":1,"per_page":30,"total_entries":1,"total_pages":1}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.0
4
+ version: 8.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DNSimple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-10 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -124,6 +124,8 @@ files:
124
124
  - lib/dnsimple/client/registrar.rb
125
125
  - lib/dnsimple/client/registrar_auto_renewal.rb
126
126
  - lib/dnsimple/client/registrar_delegation.rb
127
+ - lib/dnsimple/client/registrar_registrant_changes.rb
128
+ - lib/dnsimple/client/registrar_transfer_lock.rb
127
129
  - lib/dnsimple/client/registrar_whois_privacy.rb
128
130
  - lib/dnsimple/client/services.rb
129
131
  - lib/dnsimple/client/services_domains.rb
@@ -162,10 +164,13 @@ files:
162
164
  - lib/dnsimple/struct/email_forward.rb
163
165
  - lib/dnsimple/struct/extended_attribute.rb
164
166
  - lib/dnsimple/struct/oauth_token.rb
167
+ - lib/dnsimple/struct/registrant_change.rb
168
+ - lib/dnsimple/struct/registrant_change_check.rb
165
169
  - lib/dnsimple/struct/service.rb
166
170
  - lib/dnsimple/struct/template.rb
167
171
  - lib/dnsimple/struct/template_record.rb
168
172
  - lib/dnsimple/struct/tld.rb
173
+ - lib/dnsimple/struct/transfer_lock.rb
169
174
  - lib/dnsimple/struct/user.rb
170
175
  - lib/dnsimple/struct/vanity_name_server.rb
171
176
  - lib/dnsimple/struct/webhook.rb
@@ -192,6 +197,7 @@ files:
192
197
  - spec/dnsimple/client/registrar_auto_renewal_spec.rb
193
198
  - spec/dnsimple/client/registrar_delegation_spec.rb
194
199
  - spec/dnsimple/client/registrar_spec.rb
200
+ - spec/dnsimple/client/registrar_transfer_lock_spec.rb
195
201
  - spec/dnsimple/client/registrar_whois_privacy_spec.rb
196
202
  - spec/dnsimple/client/services_domains_spec.rb
197
203
  - spec/dnsimple/client/services_spec.rb
@@ -227,6 +233,9 @@ files:
227
233
  - spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http
228
234
  - spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http
229
235
  - spec/fixtures.http/checkDomainPremiumPrice/success.http
236
+ - spec/fixtures.http/checkRegistrantChange/error-contactnotfound.http
237
+ - spec/fixtures.http/checkRegistrantChange/error-domainnotfound.http
238
+ - spec/fixtures.http/checkRegistrantChange/success.http
230
239
  - spec/fixtures.http/checkZoneDistribution/error.http
231
240
  - spec/fixtures.http/checkZoneDistribution/failure.http
232
241
  - spec/fixtures.http/checkZoneDistribution/success.http
@@ -239,6 +248,7 @@ files:
239
248
  - spec/fixtures.http/createDomain/created.http
240
249
  - spec/fixtures.http/createEmailForward/created.http
241
250
  - spec/fixtures.http/createPrimaryServer/created.http
251
+ - spec/fixtures.http/createRegistrantChange/success.http
242
252
  - spec/fixtures.http/createSecondaryZone/created.http
243
253
  - spec/fixtures.http/createTemplate/created.http
244
254
  - spec/fixtures.http/createTemplateRecord/created.http
@@ -251,6 +261,7 @@ files:
251
261
  - spec/fixtures.http/deleteDelegationSignerRecord/success.http
252
262
  - spec/fixtures.http/deleteDomain/success.http
253
263
  - spec/fixtures.http/deleteEmailForward/success.http
264
+ - spec/fixtures.http/deleteRegistrantChange/success.http
254
265
  - spec/fixtures.http/deleteTemplate/success.http
255
266
  - spec/fixtures.http/deleteTemplateRecord/success.http
256
267
  - spec/fixtures.http/deleteWebhook/success.http
@@ -258,11 +269,13 @@ files:
258
269
  - spec/fixtures.http/disableDnssec/not-enabled.http
259
270
  - spec/fixtures.http/disableDnssec/success.http
260
271
  - spec/fixtures.http/disableDomainAutoRenewal/success.http
272
+ - spec/fixtures.http/disableDomainTransferLock/success.http
261
273
  - spec/fixtures.http/disableVanityNameServers/success.http
262
274
  - spec/fixtures.http/disableWhoisPrivacy/success.http
263
275
  - spec/fixtures.http/downloadCertificate/success.http
264
276
  - spec/fixtures.http/enableDnssec/success.http
265
277
  - spec/fixtures.http/enableDomainAutoRenewal/success.http
278
+ - spec/fixtures.http/enableDomainTransferLock/success.http
266
279
  - spec/fixtures.http/enableVanityNameServers/success.http
267
280
  - spec/fixtures.http/enableWhoisPrivacy/created.http
268
281
  - spec/fixtures.http/enableWhoisPrivacy/success.http
@@ -281,8 +294,10 @@ files:
281
294
  - spec/fixtures.http/getDomainRegistration/success.http
282
295
  - spec/fixtures.http/getDomainRenewal/success.http
283
296
  - spec/fixtures.http/getDomainTransfer/success.http
297
+ - spec/fixtures.http/getDomainTransferLock/success.http
284
298
  - spec/fixtures.http/getEmailForward/success.http
285
299
  - spec/fixtures.http/getPrimaryServer/success.http
300
+ - spec/fixtures.http/getRegistrantChange/success.http
286
301
  - spec/fixtures.http/getService/success.http
287
302
  - spec/fixtures.http/getTemplate/success.http
288
303
  - spec/fixtures.http/getTemplateRecord/success.http
@@ -309,6 +324,7 @@ files:
309
324
  - spec/fixtures.http/listEmailForwards/success.http
310
325
  - spec/fixtures.http/listPrimaryServers/success.http
311
326
  - spec/fixtures.http/listPushes/success.http
327
+ - spec/fixtures.http/listRegistrantChanges/success.http
312
328
  - spec/fixtures.http/listServices/success.http
313
329
  - spec/fixtures.http/listTemplateRecords/success.http
314
330
  - spec/fixtures.http/listTemplates/success.http