whoisxmlapi2 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +25 -3
- data/lib/whoisxmlapi2/configuration.rb +5 -0
- data/lib/whoisxmlapi2/request.rb +35 -16
- data/lib/whoisxmlapi2/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: 8f3e0b0c78161a79947adaf6f7c19fd203de96584d569dc416c1d00a76d82beb
|
4
|
+
data.tar.gz: a7824f0d38b1faac430dea297d22e1fd83d4d3b6a677ce55561a66fe2fe23440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb032822ed9d0033af75ebcd04cf0a286bb64e2d170603c88731f18773f78b66b9cbb4a428cae62493265eed74d44ee797f5675758c9ac85cf44ff6a6e000eaf
|
7
|
+
data.tar.gz: 5ef1abb7b4f9236e0b1d097e4a406a95e742315993a7095d584214c7c234ce1d53422b72f44b520c60eb2ad25ae2b8a044a9748a0ca434d7673967eaa3114bb7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,28 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
+
### API version 2.0
|
20
|
+
|
21
|
+
Provide your credentials
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
WhoisXMLAPI2.configure do |config|
|
25
|
+
config.api_key = "your-api-key"
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
Make a request
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
WhoisXMLAPI2::Request.go("cnn.com")
|
33
|
+
# => {"WhoisRecord"=>{"createdDate"=>"1993-09-22T04:00:00Z", ...
|
34
|
+
```
|
35
|
+
|
36
|
+
The output is hash parsed from the the API's JSON response.
|
37
|
+
|
38
|
+
|
39
|
+
### API Version 1.0
|
40
|
+
|
19
41
|
Provide your credentials
|
20
42
|
|
21
43
|
```ruby
|
@@ -29,15 +51,15 @@ end
|
|
29
51
|
Make a request
|
30
52
|
|
31
53
|
```ruby
|
32
|
-
WhoisXMLAPI2::Request.go("cnn.com")
|
54
|
+
WhoisXMLAPI2::Request::V1.go("cnn.com")
|
33
55
|
# => {"WhoisRecord"=>{"createdDate"=>"1993-09-22T04:00:00Z", ...
|
34
56
|
```
|
35
57
|
|
36
|
-
The output is the API response.
|
58
|
+
The output is hash parsed from the the API's JSON response.
|
37
59
|
|
38
60
|
## Development
|
39
61
|
|
40
|
-
|
62
|
+
File bugs against the GitHub issue tracker and pull requests to match, where possible.
|
41
63
|
|
42
64
|
## Contributing
|
43
65
|
|
@@ -9,6 +9,11 @@ module WhoisXMLAPI2
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.set?
|
12
|
+
WhoisXMLAPI2.configuration.url && \
|
13
|
+
WhoisXMLAPI2.configuration.api_key
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.set_v1?
|
12
17
|
WhoisXMLAPI2.configuration.url && \
|
13
18
|
WhoisXMLAPI2.configuration.username && \
|
14
19
|
WhoisXMLAPI2.configuration.api_key && \
|
data/lib/whoisxmlapi2/request.rb
CHANGED
@@ -2,25 +2,12 @@ module WhoisXMLAPI2
|
|
2
2
|
class Request
|
3
3
|
class << self
|
4
4
|
def go(domain)
|
5
|
-
|
6
|
-
digest = generate_digest(timestamp)
|
7
|
-
|
8
|
-
JSON.parse(open(config.url + params(digest, domain, timestamp)).read)
|
5
|
+
JSON.parse(open(config.url + params(domain)).read)
|
9
6
|
end
|
10
7
|
|
11
8
|
private
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
URI.escape(OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, config.secret, digest))
|
16
|
-
end
|
17
|
-
|
18
|
-
def params(digest, domain, timestamp)
|
19
|
-
"requestObject=#{prepare_data(timestamp)}&digest=#{digest}&domainName=#{domain}&outputFormat=json"
|
20
|
-
end
|
21
|
-
|
22
|
-
def prepare_data(timestamp)
|
23
|
-
Base64.encode64( { u: config.username, t: timestamp }.to_json )
|
9
|
+
def params(domain)
|
10
|
+
"apiKey=#{config.api_key}&domainName=#{domain}&outputFormat=json"
|
24
11
|
end
|
25
12
|
|
26
13
|
def config
|
@@ -29,5 +16,37 @@ module WhoisXMLAPI2
|
|
29
16
|
WhoisXMLAPI2.configuration
|
30
17
|
end
|
31
18
|
end
|
19
|
+
|
20
|
+
class V1
|
21
|
+
class << self
|
22
|
+
def go(domain)
|
23
|
+
timestamp = (Time.now.to_f * 1000).to_i
|
24
|
+
digest = generate_digest(timestamp)
|
25
|
+
|
26
|
+
JSON.parse(open(config.url + params(digest, domain, timestamp)).read)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def generate_digest(timestamp)
|
31
|
+
digest = config.username + timestamp.to_s + config.api_key
|
32
|
+
|
33
|
+
URI.escape(OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, config.secret, digest))
|
34
|
+
end
|
35
|
+
|
36
|
+
def params(digest, domain, timestamp)
|
37
|
+
"requestObject=#{prepare_data(timestamp)}&digest=#{digest}&domainName=#{domain}&outputFormat=json"
|
38
|
+
end
|
39
|
+
|
40
|
+
def prepare_data(timestamp)
|
41
|
+
Base64.encode64( { u: config.username, t: timestamp }.to_json )
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
raise 'Missing configuration' unless WhoisXMLAPI2::Configuration.set_v1?
|
46
|
+
|
47
|
+
WhoisXMLAPI2.configuration
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
32
51
|
end
|
33
52
|
end
|
data/lib/whoisxmlapi2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoisxmlapi2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Nissen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|