Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug fixes for dealing with multiple domains returned.

Updated spec
  • Loading branch information...
commit ed6eec3a7b9a5bbdf0fbe149b92fc962d4537b65 1 parent ca14cf0
@Agiley Agiley authored
View
3  lib/namecheap/domain_check_response.rb
@@ -1,7 +1,8 @@
module Namecheap
class DomainCheckResponse < Namecheap::Response
def items
- super.collect {|item| DomainCheck.new(item[1])}
+ results = super["DomainCheckResult"]
+ return (results.is_a?(Hash)) ? [DomainCheck.new(results)] : results.collect {|item| DomainCheck.new(item) }
end
end
end
View
29 spec/namecheap/namecheap_domain_check_response_spec.rb
@@ -4,21 +4,24 @@
describe "successful response from namecheap" do
before(:each) do
- @domain_check_response_hash = {"ApiResponse"=>{"Status"=>"OK",
- "Errors"=>{},
- "CommandResponse" => {"Type" => "namecheap.domains.check",
- "DomainCheckResult1" => {"Domain" => "domain1.com", "Available" => "true"},
- "DomainCheckResult2" => {"Domain" => "domain2.com", "Available" => "false"},
- "DomainCheckResult3" => {"Domain" => "domain.wtf", "Available" => "error",
- "ErrorNo" => "750", "Description" => "No response from the registry"}},
- "GMTTimeDifference"=>"--6:00",
- "RequestedCommand"=>"namecheap.domains.check",
- "Server"=>"SERVER159",
- "ExecutionTime"=>"0.01",
- "xmlns"=>"http://api.namecheap.com/xml.response"}}
+ @domain_check_response_hash = {
+ "ApiResponse" =>
+ {"Status"=>"OK",
+ "Errors"=>{},
+ "CommandResponse" =>
+ {"Type" => "namecheap.domains.check",
+ "DomainCheckResult" => [
+ {"Domain" => "domain1.com", "Available" => "true"},
+ {"Domain" => "domain2.com", "Available" => "false"},
+ {"Domain" => "domain.wtf", "Available" => "error", "ErrorNo" => "750", "Description" => "No response from the registry"}
+ ]},
+ "GMTTimeDifference"=>"--6:00",
+ "RequestedCommand"=>"namecheap.domains.check",
+ "Server"=>"SERVER159",
+ "ExecutionTime"=>"0.01",
+ "xmlns"=>"http://api.namecheap.com/xml.response"}}
@response = Namecheap::DomainCheckResponse.new(@domain_check_response_hash)
-
end
it "should have a domain check result" do
Please sign in to comment.
Something went wrong with that request. Please try again.