Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).

## main

### Removed

- Removed `Dnsimple::Client::Registrar#whois_privacy` (dnsimple/dnsimple-developer#919)
- Removed `Dnsimple::Client::Registrar#renew_whois_privacy` (dnsimple/dnsimple-developer#919)

## 11.1.0 - 2025-09-25

### Added
Expand Down
40 changes: 0 additions & 40 deletions lib/dnsimple/client/registrar_whois_privacy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@
module Dnsimple
class Client
module RegistrarWhoisPrivacy
# Gets the whois privacy for the domain.
#
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#get
#
# @example Get the whois privacy for "example.com":
# client.registrar.whois_privacy(1010, "example.com")
#
# @param [Integer] account_id the account ID
# @param [#to_s] domain_name the domain name
# @param [Hash] options
# @return [Struct::WhoisPrivacy]
#
# @raise [RequestError] When the request fails.
def whois_privacy(account_id, domain_name, options = {})
endpoint = whois_privacy_endpoint(account_id, domain_name)
response = client.get(endpoint, options)

Dnsimple::Response.new(response, Struct::WhoisPrivacy.new(response["data"]))
end

# Enables whois privacy for the domain.
#
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#enable
Expand Down Expand Up @@ -63,26 +43,6 @@ def disable_whois_privacy(account_id, domain_name, options = {})
Dnsimple::Response.new(response, Struct::WhoisPrivacy.new(response["data"]))
end

# Renews whois privacy for the domain.
#
# @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#renew
#
# @example Renew whois privacy for "example.com":
# client.registrar.renew_whois_privacy(1010, "example.com")
#
# @param account_id [Integer] the account ID
# @param domain_name [#to_s] The domain name
# @param options [Hash]
# @return [Struct::WhoisPrivacy]
#
# @raise [RequestError] When the request fails.
def renew_whois_privacy(account_id, domain_name, options = {})
endpoint = "#{whois_privacy_endpoint(account_id, domain_name)}/renewals"
response = client.post(endpoint, nil, options)

Dnsimple::Response.new(response, Struct::WhoisPrivacyRenewal.new(response["data"]))
end


private

Expand Down
1 change: 0 additions & 1 deletion lib/dnsimple/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def initialize(attributes = {})
require_relative "struct/user"
require_relative "struct/vanity_name_server"
require_relative "struct/whois_privacy"
require_relative "struct/whois_privacy_renewal"
require_relative "struct/zone"
require_relative "struct/zone_records_batch_change"
require_relative "struct/zone_record_id"
Expand Down
28 changes: 0 additions & 28 deletions lib/dnsimple/struct/whois_privacy_renewal.rb

This file was deleted.

82 changes: 0 additions & 82 deletions spec/dnsimple/client/registrar_whois_privacy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,6 @@
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").registrar }


describe "#whois_privacy" do
let(:account_id) { 1010 }

before do
stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy$})
.to_return(read_http_fixture("getWhoisPrivacy/success.http"))
end

it "builds the correct request" do
subject.whois_privacy(account_id, domain_name = "example.com")

expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy")
.with(headers: { "Accept" => "application/json" })
end

it "returns the whois privacy" do
response = subject.whois_privacy(account_id, "example.com")
expect(response).to be_a(Dnsimple::Response)

result = response.data
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
expect(result.domain_id).to be_a(Integer)
expect(result.enabled).to be(true)
expect(result.expires_on).to be_a(String)
end
end

describe "#enable_whois_privacy" do
let(:account_id) { 1010 }

Expand Down Expand Up @@ -118,59 +91,4 @@
end
end


describe "#renew_whois_privacy" do
let(:account_id) { 1010 }

before do
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
.to_return(read_http_fixture("renewWhoisPrivacy/success.http"))
end

it "builds the correct request" do
subject.renew_whois_privacy(account_id, domain_name = "example.com")

expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy/renewals")
.with(headers: { "Accept" => "application/json" })
end

it "returns the whois privacy order" do
response = subject.renew_whois_privacy(account_id, "example.com")
expect(response).to be_a(Dnsimple::Response)

result = response.data
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacyRenewal)
expect(result.domain_id).to be_a(Integer)
expect(result.whois_privacy_id).to be_a(Integer)
expect(result.enabled).to be(true)
expect(result.expires_on).to be_a(String)
end

context "when whois privacy was't previously purchased" do
before do
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
.to_return(read_http_fixture("renewWhoisPrivacy/whois-privacy-not-found.http"))
end

it "raises error" do
expect do
subject.renew_whois_privacy(account_id, "example.com")
end.to raise_error(Dnsimple::RequestError, "WHOIS privacy not found for example.com")
end
end

context "when there is already a whois privacy renewal order in progress" do
before do
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy/renewals$})
.to_return(read_http_fixture("renewWhoisPrivacy/whois-privacy-duplicated-order.http"))
end

it "raises error" do
expect do
subject.renew_whois_privacy(account_id, "example.com")
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")
end
end
end

end
16 changes: 0 additions & 16 deletions spec/fixtures.http/getWhoisPrivacy/success.http

This file was deleted.

20 changes: 0 additions & 20 deletions spec/fixtures.http/renewWhoisPrivacy/success.http

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http

This file was deleted.