whoisxmlapi 0.3.0 → 0.3.1
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 +4 -4
- data/lib/whoisxmlapi/client.rb +19 -12
- data/lib/whoisxmlapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2442b889d8fed140f51f7d83bf621f30403d81bace0d7fa3f16db5fba1c61ba5
|
4
|
+
data.tar.gz: 248927a9e820129a2cb6bfe0ba3656de0e361d9624ca375f0896fd55f1a774f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba31775e1e05d8b9c482ab67b52858d401defa81b746a8e5a7913a6da3536f38c2786337c9d0c47cb402779d90408445cf98ac3ebc2b9fd526dacea03efad509
|
7
|
+
data.tar.gz: 1e9d36cf33a50560a604ffdf5085228dbb7ff51f53b4721568a5da72095b1f507e05e97de5babd48149795bdfab5b6baedae7f822c5c0afc703711106612bcc2
|
data/lib/whoisxmlapi/client.rb
CHANGED
@@ -42,11 +42,14 @@ module WhoisXMLAPI
|
|
42
42
|
if r
|
43
43
|
if r.parsed_response.is_a?(String)
|
44
44
|
WhoisXMLAPI.logger.debug "WhoisXMLAPI#whois - WARNING: passed back parsed_response as a String instead of a Hash for \'#{domain}\'."
|
45
|
-
presponse = JSON.parse(r.parsed_response)
|
45
|
+
presponse = JSON.parse(r.parsed_response) rescue nil
|
46
46
|
else
|
47
47
|
presponse = r.parsed_response
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
|
+
if presponse.nil?
|
51
|
+
res = {:error => {message: 'Failed to parse response from API.'}}
|
52
|
+
elsif presponse.key? 'ErrorMessage'
|
50
53
|
WhoisXMLAPI.logger.info "WhoisXMLAPI#whois - Error getting Whois info: #{presponse['ErrorMessage']['msg']}"
|
51
54
|
res = WhoisXMLAPI::Unavailable.new(:whoisable => owner)
|
52
55
|
res.parse(domain) # parse will save document for Unavailable
|
@@ -112,12 +115,12 @@ module WhoisXMLAPI
|
|
112
115
|
# Logger message is to monitor whether WhoisXML and/or HTTParty will still return a string on occasion.
|
113
116
|
if r.parsed_response.is_a?(String)
|
114
117
|
WhoisXMLAPI.logger.debug "WhoisXMLAPI#exists? - passed back parsed_response as a String instead of a Hash for \'#{domain}\'."
|
115
|
-
|
118
|
+
presponse = JSON.parse(r.parsed_response) rescue nil
|
116
119
|
else
|
117
|
-
|
120
|
+
presponse = r.parsed_response
|
118
121
|
end
|
119
122
|
|
120
|
-
|
123
|
+
presponse && presponse["DomainInfo"]["domainAvailability"] == "UNAVAILABLE"
|
121
124
|
end
|
122
125
|
|
123
126
|
|
@@ -239,21 +242,25 @@ module WhoisXMLAPI
|
|
239
242
|
r = nil
|
240
243
|
end
|
241
244
|
|
242
|
-
if r.response.is_a?
|
243
|
-
if r
|
245
|
+
if r && r.response.is_a?(Net::HTTPOK)
|
246
|
+
if r.parsed_response
|
244
247
|
# WhoisXML and HTTParty are sometimes returning a Hash and not a JSON string as requested,
|
245
248
|
# which is causing an error of "no implicit conversion of Hash into String" when we call JSON.parse.
|
246
249
|
# Logger message is to monitor whether WhoisXML and/or HTTParty will still return a string on occasion.
|
247
250
|
if r.parsed_response.is_a?(String)
|
248
251
|
WhoisXMLAPI.logger.debug "WhoisXMLAPI#account_balance - passed back parsed_response as a String instead of a Hash."
|
249
|
-
JSON.parse(r.parsed_response)
|
252
|
+
presponse = JSON.parse(r.parsed_response) rescue nil
|
253
|
+
else
|
254
|
+
presponse = r.parsed_response
|
250
255
|
end
|
251
256
|
|
252
|
-
if
|
253
|
-
result = {:error => {message:
|
254
|
-
elsif
|
257
|
+
if presponse.nil?
|
258
|
+
result = {:error => {message: 'Failed to parse response from API.'}}
|
259
|
+
elsif presponse["error"]
|
260
|
+
result = {:error => {message: presponse["error"]}}
|
261
|
+
elsif presponse["data"]
|
255
262
|
result = {}
|
256
|
-
|
263
|
+
presponse["data"].each do |datum|
|
257
264
|
key = datum["product"]["name"]
|
258
265
|
result[key] = {product_id: datum["product_id"], credits: datum["credits"]}
|
259
266
|
end
|
data/lib/whoisxmlapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoisxmlapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hillard
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-
|
14
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|