Skip to content

Commit

Permalink
Added support for changeDomainDelegationFromVanity
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jul 11, 2016
1 parent c3a3e29 commit 36c48c4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/dnsimple/client/registrar_delegation.rb
Expand Up @@ -66,6 +66,26 @@ def change_domain_delegation_to_vanity(account_id, domain_name, attributes, opti
Dnsimple::Response.new(response, response["data"])
end

# Disable vanity name servers for the domain.
#
# @see https://developer.dnsimple.com/v2/registrar/delegation/#delegateFromVanity
#
# @example Disable vanity name servers for example.com:
# client.registrar.change_domain_delegation_from_vanity(1010, "example.com")
#
# @param [Fixnum] account_id the account ID
# @param [#to_s] domain_name the domain name to check
# @param [Hash] options
# @return [Dnsimple::Response<Array>]
#
# @raise [RequestError] When the request fails.
def change_domain_delegation_from_vanity(account_id, domain_name, options = {})
endpoint = Client.versioned("/%s/registrar/domains/%s/delegation/vanity" % [account_id, domain_name])
response = client.delete(endpoint, options)

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

end
end
end
24 changes: 24 additions & 0 deletions spec/dnsimple/client/registrar_delegation_spec.rb
Expand Up @@ -79,4 +79,28 @@
expect(vanity_name_servers).to match_array(%w(ns1.example.com ns2.example.com))
end
end

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

before do
stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$}).
to_return(read_http_fixture("changeDomainDelegationFromVanity/success.http"))
end

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

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

it "returns empty response" do
response = subject.change_domain_delegation_from_vanity(account_id, "example.com")
expect(response).to be_a(Dnsimple::Response)

result = response.data
expect(result).to be_nil
end
end
end
17 changes: 17 additions & 0 deletions spec/fixtures.http/changeDomainDelegationFromVanity/success.http
@@ -0,0 +1,17 @@
HTTP/1.1 204 No Content
Server: nginx
Date: Mon, 11 Jul 2016 09:55:23 GMT
Connection: keep-alive
X-RateLimit-Limit: 2400
X-RateLimit-Remaining: 2398
X-RateLimit-Reset: 1468233619
Cache-Control: no-cache
X-Request-Id: 334a5c9c-8205-414c-bca2-db0469ed0b4a
X-Runtime: 0.385941
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000

0 comments on commit 36c48c4

Please sign in to comment.